Skip to content

Commit

Permalink
Fix bug with argument_object on arg object
Browse files Browse the repository at this point in the history
So there needs to be an argument_object on a param,
but it can be None.  The real fix is to update bcdocs
and the argprocess module to depend on this, but I'm setting
this to None in order to get the tests passing and this code
merged.
  • Loading branch information
jamesls committed Aug 19, 2013
1 parent 12972fe commit 31ea2fb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
5 changes: 5 additions & 0 deletions awscli/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ def __init__(self, name, help_text='', dest=None, default=None,
if choices is None:
choices = []
self._choices = choices
# TODO: We should eliminate this altogether.
# You should not have to depend on an argument_object
# as part of the interface. Currently the argprocess
# and docs code relies on this object.
self.argument_object = None

def add_to_parser(self, parser):
"""
Expand Down
24 changes: 12 additions & 12 deletions awscli/customizations/ec2runinstances.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
``--network-interfaces`` complex argument. This just makes two of
the most commonly used features available more easily.
"""
from awscli.customizations import CustomArgument
from awscli.arguments import CustomArgument


# --secondary-private-ip-address
Expand All @@ -33,20 +33,20 @@
'but do not need a specific address, use the '
'--secondary-private-ip-address-count option.')

# --secondary-private-ip-address-count
# --secondary-private-ip-address-count
SECONDARY_PRIVATE_IP_ADDRESS_COUNT_DOCS = (
'[EC2-VPC] The number of secondary IP addresses to assign to '
'the network interface or instance.')


def _add_params(argument_table, operation, **kwargs):
arg = SecondaryPrivateIpAddressesArgument(
operation=operation, name='secondary-private-ip-addresses',
documentation=SECONDARY_PRIVATE_IP_ADDRESSES_DOCS)
name='secondary-private-ip-addresses',
help_text=SECONDARY_PRIVATE_IP_ADDRESSES_DOCS)
argument_table['secondary-private-ip-addresses'] = arg
arg = SecondaryPrivateIpAddressCountArgument(
operation=operation, name='secondary-private-ip-address-count',
documentation=SECONDARY_PRIVATE_IP_ADDRESS_COUNT_DOCS)
name='secondary-private-ip-address-count',
help_text=SECONDARY_PRIVATE_IP_ADDRESS_COUNT_DOCS)
argument_table['secondary-private-ip-address-count'] = arg


Expand All @@ -55,9 +55,9 @@ def _check_args(parsed_args, **kwargs):
# the --network-interfaces option with any of the scalar options we
# raise an error.
arg_dict = vars(parsed_args)
if arg_dict['network-interfaces']:
for key in ('secondary-private-ip-addresses',
'secondary-private-ip-address-count'):
if arg_dict['network_interfaces']:
for key in ('secondary_private_ip_addresses',
'secondary_private_ip_address_count'):
if arg_dict[key]:
msg = ('Mixing the --network-interfaces option '
'with the simple, scalar options is '
Expand All @@ -80,7 +80,7 @@ def _build_network_interfaces(params, key, value):
# Build up the NetworkInterfaces data structure
if 'network_interfaces' not in params:
params['network_interfaces'] = [{'DeviceIndex': 0}]

if key == 'PrivateIpAddresses':
if 'PrivateIpAddresses' not in params['network_interfaces'][0]:
params['network_interfaces'][0]['PrivateIpAddresses'] = value
Expand All @@ -91,7 +91,7 @@ def _build_network_interfaces(params, key, value):
class SecondaryPrivateIpAddressesArgument(CustomArgument):

def add_to_parser(self, parser, cli_name=None):
parser.add_argument(self.cli_name, dest=self._name,
parser.add_argument(self.cli_name, dest=self.py_name,
default=self._default, nargs='*')

def add_to_params(self, parameters, value):
Expand All @@ -106,7 +106,7 @@ def add_to_params(self, parameters, value):
class SecondaryPrivateIpAddressCountArgument(CustomArgument):

def add_to_parser(self, parser, cli_name=None):
parser.add_argument(self.cli_name, dest=self._name,
parser.add_argument(self.cli_name, dest=self.py_name,
default=self._default, type=int)

def add_to_params(self, parameters, value):
Expand Down

0 comments on commit 31ea2fb

Please sign in to comment.