Skip to content

Commit

Permalink
Closes #7176. (#7459)
Browse files Browse the repository at this point in the history
  • Loading branch information
tjprescott committed Oct 1, 2018
1 parent deb29c9 commit a537f49
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -616,8 +616,8 @@ def load_arguments(self, _):
c.argument('subnet', validator=get_subnet_validator(), help='Name or ID of an existing subnet. If name is specified, also specify --vnet-name.')
c.argument('virtual_network_name', help='The virtual network (VNet) associated with the subnet (Omit if supplying a subnet id).', id_part=None, metavar='')
c.argument('public_ip_address', help='Name or ID of the public IP to use.', validator=get_public_ip_validator())
c.argument('private_ip_address_allocation', ignore_type, default=IPAllocationMethod.dynamic.value)
c.argument('make_primary', action='store_true', help='Set to make this configuration the primary one for the NIC.')
c.argument('private_ip_address', private_ip_address_type, help='Static IP address to use or "" to use a dynamic address.')

with self.argument_context('network nic ip-config address-pool') as c:
c.argument('load_balancer_name', options_list=('--lb-name',), help='The name of the load balancer associated with the address pool (Omit if suppying an address pool ID).', completer=get_resource_name_completion_list('Microsoft.Network/loadBalancers'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2171,7 +2171,6 @@ def create_nic_ip_config(cmd, resource_group_name, network_interface_name, ip_co
load_balancer_backend_address_pool_ids=None,
load_balancer_inbound_nat_rule_ids=None,
private_ip_address=None,
private_ip_address_allocation=None,
private_ip_address_version=None,
make_primary=False,
application_security_groups=None):
Expand All @@ -2197,7 +2196,7 @@ def create_nic_ip_config(cmd, resource_group_name, network_interface_name, ip_co
'load_balancer_backend_address_pools': load_balancer_backend_address_pool_ids,
'load_balancer_inbound_nat_rules': load_balancer_inbound_nat_rule_ids,
'private_ip_address': private_ip_address,
'private_ip_allocation_method': private_ip_address_allocation,
'private_ip_allocation_method': 'Static' if private_ip_address else 'Dynamic'
}
if cmd.supported_api_version(min_api='2016-09-01'):
new_config_args['private_ip_address_version'] = private_ip_address_version
Expand All @@ -2216,8 +2215,8 @@ def set_nic_ip_config(cmd, instance, parent, ip_config_name, subnet=None,
virtual_network_name=None, public_ip_address=None, load_balancer_name=None,
load_balancer_backend_address_pool_ids=None,
load_balancer_inbound_nat_rule_ids=None,
private_ip_address=None, private_ip_address_allocation=None,
private_ip_address_version='ipv4', make_primary=False,
private_ip_address=None,
private_ip_address_version=None, make_primary=False,
application_security_groups=None):
PublicIPAddress, Subnet = cmd.get_models('PublicIPAddress', 'Subnet')

Expand All @@ -2227,11 +2226,13 @@ def set_nic_ip_config(cmd, instance, parent, ip_config_name, subnet=None,
instance.primary = True

if private_ip_address == '':
# switch private IP address allocation to Dynamic if empty string is used
instance.private_ip_address = None
instance.private_ip_allocation_method = 'dynamic'
if cmd.supported_api_version(min_api='2016-09-01'):
instance.private_ip_address_version = 'ipv4'
elif private_ip_address is not None:
# if specific address provided, allocation is static
instance.private_ip_address = private_ip_address
instance.private_ip_allocation_method = 'static'
if private_ip_address_version is not None:
Expand Down

0 comments on commit a537f49

Please sign in to comment.