Skip to content

Commit

Permalink
Incorporate a few review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
garnaat committed Nov 22, 2013
1 parent 50d4999 commit 927bb1c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
17 changes: 5 additions & 12 deletions awscli/customizations/ec2runinstances.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,8 @@
``--network-interfaces`` complex argument. This just makes two of
the most commonly used features available more easily.
"""
import logging

from awscli.arguments import CustomArgument

LOG = logging.getLogger(__name__)

# --secondary-private-ip-address
SECONDARY_PRIVATE_IP_ADDRESSES_DOCS = (
'[EC2-VPC] A secondary private IP address for the network interface '
Expand All @@ -46,8 +42,6 @@
'[EC2-VPC] If specified a public IP address will be assigned '
'to the new instance in a VPC.')



def _add_params(argument_table, operation, **kwargs):
arg = SecondaryPrivateIpAddressesArgument(
name='secondary-private-ip-addresses',
Expand Down Expand Up @@ -97,18 +91,17 @@ def _fix_subnet(operation, endpoint, params, **kwargs):
ni[0]['SubnetId'] = params['subnet_id']
del params['subnet_id']


EVENTS = [
('building-argument-table.ec2.run-instances', _add_params, None),
('operation-args-parsed.ec2.run-instances', _check_args, None),
('before-parameter-build.ec2.RunInstances', _fix_subnet, 'foobar'),
('building-argument-table.ec2.run-instances', _add_params),
('operation-args-parsed.ec2.run-instances', _check_args),
('before-parameter-build.ec2.RunInstances', _fix_subnet),
]


def register_runinstances(event_handler):
# Register all of the events for customizing BundleInstance
for event, handler, unique_id in EVENTS:
event_handler.register(event, handler, unique_id)
for event, handler in EVENTS:
event_handler.register(event, handler)


def _build_network_interfaces(params, key, value):
Expand Down
11 changes: 11 additions & 0 deletions tests/unit/ec2/test_run_instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,14 @@ def test_no_associate_public_ip_address(self):
}
self.assert_params_for_cmd(args_list, result)

def test_subnet_alone(self):
args = ' --image-id ami-foobar --count 1 --subnet-id subnet-12345678'
args_list = (self.prefix + args).split()
result = {
'SubnetId': 'subnet-12345678',
'ImageId': 'ami-foobar',
'MaxCount': '1',
'MinCount': '1'
}
self.assert_params_for_cmd(args_list, result)

0 comments on commit 927bb1c

Please sign in to comment.