Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aws
GitHub Repository: aws/aws-cli
Path: blob/develop/awscli/customizations/ec2/protocolarg.py
1567 views
1
# Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
#
3
# Licensed under the Apache License, Version 2.0 (the "License"). You
4
# may not use this file except in compliance with the License. A copy of
5
# the License is located at
6
#
7
# http://aws.amazon.com/apache2.0/
8
#
9
# or in the "license" file accompanying this file. This file is
10
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
# ANY KIND, either express or implied. See the License for the specific
12
# language governing permissions and limitations under the License.
13
"""
14
This customization allows the user to specify the values "tcp", "udp",
15
or "icmp" as values for the --protocol parameter. The actual Protocol
16
parameter of the operation accepts only integer protocol numbers.
17
"""
18
19
20
def _fix_args(params, **kwargs):
21
key_name = 'Protocol'
22
if key_name in params:
23
if params[key_name] == 'tcp':
24
params[key_name] = '6'
25
elif params[key_name] == 'udp':
26
params[key_name] = '17'
27
elif params[key_name] == 'icmp':
28
params[key_name] = '1'
29
elif params[key_name] == 'all':
30
params[key_name] = '-1'
31
32
33
def register_protocol_args(cli):
34
cli.register('before-parameter-build.ec2.CreateNetworkAclEntry',
35
_fix_args)
36
cli.register('before-parameter-build.ec2.ReplaceNetworkAclEntry',
37
_fix_args)
38
39