| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,12 +20,13 @@ | |||
| 20 | 20 | logger = logging.getLogger(__name__) | |
| 21 | 21 | ||
| 22 | 22 | ||
| 23 | + DEFAULT = 1 | ||
| 23 | 24 | HELP = """ | |
| 24 | 25 | <p>Number of instances to launch. If a single number is provided, it | |
| 25 | - is assumed to be the minimum to launch (defaults to 1). If a range is | ||
| 26 | + is assumed to be the minimum to launch (defaults to %d). If a range is | ||
| 26 | 27 | provided in the form <code>min:max</code> then the first number is | |
| 27 | 28 | interpreted as the minimum number of instances to launch and the second | |
| 28 | - is interpreted as the maximum number of instances to launch.</p>""" | ||
| 29 | + is interpreted as the maximum number of instances to launch.</p>""" % DEFAULT | ||
| 29 | 30 | ||
| 30 | 31 | ||
| 31 | 32 | def ec2_add_count(argument_table, **kwargs): | |
@@ -64,9 +65,15 @@ def documentation(self): | |||
| 64 | 65 | def add_to_parser(self, parser): | |
| 65 | 66 | parser.add_argument(self.cli_name, metavar=self.py_name, | |
| 66 | 67 | help='Number of instances to launch', | |
| 67 | - default='1') | ||
| 68 | + ## We will delegate the default value logic to | ||
| 69 | + ## ec2runinstances.py:_fix_args() | ||
| 70 | + # default=str(DEFAULT) | ||
| 71 | + ) | ||
| 68 | 72 | ||
| 69 | 73 | def add_to_params(self, parameters, value): | |
| 74 | + if value is None: | ||
| 75 | + # NO-OP if value is not explicitly set by user | ||
| 76 | + return | ||
| 70 | 77 | try: | |
| 71 | 78 | if ':' in value: | |
| 72 | 79 | minstr, maxstr = value.split(':') | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,6 +23,7 @@ | |||
| 23 | 23 | the most commonly used features available more easily. | |
| 24 | 24 | """ | |
| 25 | 25 | from awscli.arguments import CustomArgument | |
| 26 | + from awscli.customizations.ec2addcount import DEFAULT | ||
| 26 | 27 | ||
| 27 | 28 | # --secondary-private-ip-address | |
| 28 | 29 | SECONDARY_PRIVATE_IP_ADDRESSES_DOCS = ( | |
@@ -105,6 +106,8 @@ def _fix_args(params, **kwargs): | |||
| 105 | 106 | 'Primary': True} | |
| 106 | 107 | ni[0]['PrivateIpAddresses'] = [ip_addr] | |
| 107 | 108 | del params['PrivateIpAddress'] | |
| 109 | + params.setdefault('MaxCount', DEFAULT) | ||
| 110 | + params.setdefault('MinCount', DEFAULT) | ||
| 108 | 111 | ||
| 109 | 112 | ||
| 110 | 113 | EVENTS = [ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -68,6 +68,19 @@ def test_count_range(self): | |||
| 68 | 68 | } | |
| 69 | 69 | self.assert_params_for_cmd(args_list, result) | |
| 70 | 70 | ||
| 71 | + def test_count_in_json_only(self): | ||
| 72 | + input_json = '{"ImageId":"ami-xxxx","MaxCount":9,"MinCount":5}' | ||
| 73 | + args_list = (self.prefix + ' --cli-input-json ' + input_json).split() | ||
| 74 | + result = {'ImageId': 'ami-xxxx', 'MaxCount': 9, 'MinCount': 5} | ||
| 75 | + self.assert_params_for_cmd(args_list, result) | ||
| 76 | + | ||
| 77 | + def test_count_in_cli_and_in_json(self): | ||
| 78 | + input_json = '{"ImageId":"ami-xxxx","MaxCount":9,"MinCount":5}' | ||
| 79 | + args_list = ( | ||
| 80 | + self.prefix + ' --count 3 --cli-input-json ' + input_json).split() | ||
| 81 | + result = {'ImageId': 'ami-xxxx', 'MaxCount': 3, 'MinCount': 3} | ||
| 82 | + self.assert_params_for_cmd(args_list, result) | ||
| 83 | + | ||
| 71 | 84 | def test_block_device_mapping(self): | |
| 72 | 85 | args = ' --image-id ami-foobar --count 1' | |
| 73 | 86 | args_list = (self.prefix + args).split() | |
| Back | FazBrowse Home | New Git URL |
0 commit comments