From a537f4947f047252105f100d1f2f46eee8e9aa6b Mon Sep 17 00:00:00 2001 From: Travis Prescott Date: Mon, 1 Oct 2018 14:26:15 -0700 Subject: [PATCH] Closes #7176. (#7459) --- .../azure/cli/command_modules/network/_params.py | 2 +- .../azure/cli/command_modules/network/custom.py | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/command_modules/azure-cli-network/azure/cli/command_modules/network/_params.py b/src/command_modules/azure-cli-network/azure/cli/command_modules/network/_params.py index 031f6f7a9c5..cde050b5aac 100644 --- a/src/command_modules/azure-cli-network/azure/cli/command_modules/network/_params.py +++ b/src/command_modules/azure-cli-network/azure/cli/command_modules/network/_params.py @@ -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')) diff --git a/src/command_modules/azure-cli-network/azure/cli/command_modules/network/custom.py b/src/command_modules/azure-cli-network/azure/cli/command_modules/network/custom.py index 90fb3911ec9..ea73b3d58e4 100644 --- a/src/command_modules/azure-cli-network/azure/cli/command_modules/network/custom.py +++ b/src/command_modules/azure-cli-network/azure/cli/command_modules/network/custom.py @@ -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): @@ -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 @@ -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') @@ -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: