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

[network] az network routeserver create: Add --public-ip-address argument #18663

Merged
Show file tree
Hide file tree
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
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