Skip to content

Commit

Permalink
[network] az network routeserver create: Add --public-ip-address
Browse files Browse the repository at this point in the history
…argument (#18663)

* add public_ip_address parameter for 'az network routeserver create'

* change the default ip configuration name to align with powershell

* update recordings
  • Loading branch information
kairu-ms authored Jul 1, 2021
1 parent deeed22 commit cc10117
Show file tree
Hide file tree
Showing 5 changed files with 788 additions and 308 deletions.
2 changes: 1 addition & 1 deletion src/azure-cli/azure/cli/command_modules/network/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -6163,7 +6163,7 @@
examples:
- name: Create a route server.
text: |
az network routeserver create --resource-group myresourcegroup --name myrouteserver --hosted-subnet my_subnet_id
az network routeserver create --resource-group myresourcegroup --name myrouteserver --hosted-subnet my_subnet_id --public-ip-address my_public_ip
"""

helps['network routeserver update'] = """
Expand Down
4 changes: 4 additions & 0 deletions src/azure-cli/azure/cli/command_modules/network/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -2083,6 +2083,10 @@ def load_arguments(self, _):
c.argument('hosted_subnet', help='The ID of a subnet where Route Server would be deployed')
c.argument('allow_branch_to_branch_traffic', options_list=['--allow-b2b-traffic'],
arg_type=get_three_state_flag(), help='Allow branch to branch traffic.')
c.argument('public_ip_address', validator=get_public_ip_validator(),
help='The name or ID of the public IP address.',
completer=get_resource_name_completion_list('Microsoft.Network/publicIPAddresses'),
min_api='2021-02-01')

with self.argument_context('network routeserver create') as c:
c.argument('virtual_hub_name', id_part=None)
Expand Down
15 changes: 11 additions & 4 deletions src/azure-cli/azure/cli/command_modules/network/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -6989,7 +6989,8 @@ def remove_vnet_gateway_nat_rule(cmd, resource_group_name, gateway_name, name, n
def create_virtual_hub(cmd, client,
resource_group_name,
virtual_hub_name,
hosted_subnet=None,
hosted_subnet,
public_ip_address=None,
location=None,
tags=None):
from azure.core.exceptions import HttpResponseError
Expand All @@ -7012,7 +7013,10 @@ def create_virtual_hub(cmd, client,
vhub_poller = client.begin_create_or_update(resource_group_name, virtual_hub_name, hub)
LongRunningOperation(cmd.cli_ctx)(vhub_poller)

ip_config = HubIpConfiguration(subnet=SubResource(id=hosted_subnet))
ip_config = HubIpConfiguration(
subnet=SubResource(id=hosted_subnet),
public_ip_address=SubResource(id=public_ip_address) if public_ip_address else None,
)
vhub_ip_config_client = network_client_factory(cmd.cli_ctx).virtual_hub_ip_configuration
try:
vhub_ip_poller = vhub_ip_config_client.begin_create_or_update(
Expand Down Expand Up @@ -7046,8 +7050,11 @@ def update_virtual_hub(cmd, instance,
def delete_virtual_hub(cmd, client, resource_group_name, virtual_hub_name, no_wait=False):
from azure.cli.core.commands import LongRunningOperation
vhub_ip_config_client = network_client_factory(cmd.cli_ctx).virtual_hub_ip_configuration
poller = vhub_ip_config_client.begin_delete(resource_group_name, virtual_hub_name, 'Default')
LongRunningOperation(cmd.cli_ctx)(poller)
ip_configs = list(vhub_ip_config_client.list(resource_group_name, virtual_hub_name))
if ip_configs:
ip_config = ip_configs[0] # There will always be only 1
poller = vhub_ip_config_client.begin_delete(resource_group_name, virtual_hub_name, ip_config.name)
LongRunningOperation(cmd.cli_ctx)(poller)
return sdk_no_wait(no_wait, client.begin_delete, resource_group_name, virtual_hub_name)


Expand Down
Loading

0 comments on commit cc10117

Please sign in to comment.