Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If --private-ip-address is specified with any other options that require... #521

Merged
merged 1 commit into from
Dec 2, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
If --private-ip-address is specified with any other options that requ…
…ire the creation of a NetworkInterfaces structure, move the value of --private-ip-address into the NetworkInterfaces structure. Fixes #520.
garnaat committed Dec 2, 2013
commit 7edca371a7f37a33f049629c658c7db0a70f7cae
5 changes: 5 additions & 0 deletions awscli/customizations/ec2runinstances.py
Original file line number Diff line number Diff line change
@@ -100,6 +100,11 @@ def _fix_args(operation, endpoint, params, **kwargs):
if 'security_group_ids' in params:
ni[0]['Groups'] = params['security_group_ids']
del params['security_group_ids']
if 'private_ip_address' in params:
ip_addr = {'PrivateIpAddress': params['private_ip_address'],
'Primary': True}
ni[0]['PrivateIpAddresses'] = [ip_addr]
del params['private_ip_address']


EVENTS = [
29 changes: 29 additions & 0 deletions tests/unit/ec2/test_run_instances.py
Original file line number Diff line number Diff line change
@@ -191,3 +191,32 @@ def test_group_id_alone(self):
}
self.assert_params_for_cmd(args_list, result)

def test_associate_public_ip_address_and_private_ip_address(self):
args = ' --image-id ami-foobar --count 1 '
args += '--private-ip-address 10.0.0.200 '
args += '--associate-public-ip-address --subnet-id subnet-12345678'
args_list = (self.prefix + args).split()
result = {
'NetworkInterface.1.DeviceIndex': '0',
'NetworkInterface.1.AssociatePublicIpAddress': 'true',
'NetworkInterface.1.SubnetId': 'subnet-12345678',
'NetworkInterface.1.PrivateIpAddresses.1.PrivateIpAddress': '10.0.0.200',
'NetworkInterface.1.PrivateIpAddresses.1.Primary': 'true',
'ImageId': 'ami-foobar',
'MaxCount': '1',
'MinCount': '1'
}
self.assert_params_for_cmd(args_list, result)

def test_private_ip_address_alone(self):
args = ' --image-id ami-foobar --count 1 '
args += '--private-ip-address 10.0.0.200'
args_list = (self.prefix + args).split()
result = {
'PrivateIpAddress': '10.0.0.200',
'ImageId': 'ami-foobar',
'MaxCount': '1',
'MinCount': '1'
}
self.assert_params_for_cmd(args_list, result)