Path: blob/develop/awscli/customizations/ec2/protocolarg.py
1567 views
# Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.1#2# Licensed under the Apache License, Version 2.0 (the "License"). You3# may not use this file except in compliance with the License. A copy of4# the License is located at5#6# http://aws.amazon.com/apache2.0/7#8# or in the "license" file accompanying this file. This file is9# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF10# ANY KIND, either express or implied. See the License for the specific11# language governing permissions and limitations under the License.12"""13This customization allows the user to specify the values "tcp", "udp",14or "icmp" as values for the --protocol parameter. The actual Protocol15parameter of the operation accepts only integer protocol numbers.16"""171819def _fix_args(params, **kwargs):20key_name = 'Protocol'21if key_name in params:22if params[key_name] == 'tcp':23params[key_name] = '6'24elif params[key_name] == 'udp':25params[key_name] = '17'26elif params[key_name] == 'icmp':27params[key_name] = '1'28elif params[key_name] == 'all':29params[key_name] = '-1'303132def register_protocol_args(cli):33cli.register('before-parameter-build.ec2.CreateNetworkAclEntry',34_fix_args)35cli.register('before-parameter-build.ec2.ReplaceNetworkAclEntry',36_fix_args)373839