Skip to content

Commit 40bb9a0

Browse files
committed
custom add --auto-scale-config
1 parent 1421726 commit 40bb9a0

File tree

6 files changed

+606
-523
lines changed

6 files changed

+606
-523
lines changed

src/azure-cli/azure/cli/command_modules/network/_help.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5720,6 +5720,12 @@
57205720
helps['network routeserver create'] = """
57215721
type: command
57225722
short-summary: Create a route server.
5723+
parameters:
5724+
- name: --auto-scale-config
5725+
short-summary: VirtualHub Router autoscale configuration. Use space-separated property=value [property=value ...].
5726+
long-summary: |
5727+
Supported properties:
5728+
min-capacity: The minimum number of scale units for VirtualHub Router.
57235729
examples:
57245730
- name: Create a route server.
57255731
text: |

src/azure-cli/azure/cli/command_modules/network/_params.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
validate_dns_record_type, validate_private_ip_address,
2121
get_servers_validator, get_public_ip_validator, get_nsg_validator,
2222
get_vnet_validator, validate_ip_tags, validate_ddos_name_or_id,
23+
auto_scale_config_validator,
2324
validate_service_endpoint_policy,
2425
validate_custom_error_pages,
2526
validate_custom_headers, validate_status_code_ranges, validate_subnet_ranges,
@@ -58,6 +59,11 @@ def load_arguments(self, _):
5859
help='Space-separated list of availability zones into which to provision the resource.',
5960
)
6061
edge_zone = CLIArgumentType(help='The name of edge zone.')
62+
auto_scale_config = CLIArgumentType(
63+
nargs='*',
64+
options_list='--auto-scale-config',
65+
validator=auto_scale_config_validator
66+
)
6167

6268
# region NetworkRoot
6369
with self.argument_context('network') as c:
@@ -789,6 +795,7 @@ def load_arguments(self, _):
789795

790796
with self.argument_context('network routeserver create') as c:
791797
c.argument('virtual_hub_name', id_part=None)
798+
c.argument('auto_scale_config', auto_scale_config)
792799
# endregion
793800

794801
# region Remove --ids from listsaz

src/azure-cli/azure/cli/command_modules/network/_validators.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,21 @@ def _validate_cert(namespace, param_name):
616616
setattr(namespace, param_name, read_base_64_file(attr))
617617

618618

619+
def auto_scale_config_validator(namespace):
620+
config_props = ['min-capacity']
621+
def _parse(item):
622+
prop, value = item.split('=', 1)
623+
if not prop in config_props:
624+
raise ValidationError(f"Invalid property '{prop}' in auto-scale-config. Supported: {config_props}")
625+
return {prop: value} if value else {prop: ""}
626+
627+
if isinstance(namespace.auto_scale_config, list):
628+
auto_scale_config = {}
629+
for item in namespace.auto_scale_config:
630+
auto_scale_config.update(_parse(item))
631+
namespace.auto_scale_config = auto_scale_config
632+
633+
619634
def process_vpn_connection_create_namespace(cmd, namespace):
620635
from azure.mgmt.core.tools import is_valid_resource_id, resource_id
621636
get_default_location_from_resource_group(cmd, namespace)

src/azure-cli/azure/cli/command_modules/network/custom.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6461,6 +6461,7 @@ def create_virtual_hub(cmd,
64616461
hosted_subnet,
64626462
public_ip_address,
64636463
hub_routing_preference=None,
6464+
auto_scale_config=None,
64646465
location=None,
64656466
tags=None):
64666467
from azure.core.exceptions import HttpResponseError
@@ -6480,7 +6481,8 @@ def create_virtual_hub(cmd,
64806481
'location': location,
64816482
'tags': tags,
64826483
'sku': 'Standard',
6483-
"hub_routing_preference": hub_routing_preference
6484+
"hub_routing_preference": hub_routing_preference,
6485+
"auto_scale_config": auto_scale_config
64846486
}
64856487
from .aaz.latest.network.routeserver import Create
64866488
vhub_poller = Create(cli_ctx=cmd.cli_ctx)(command_args=args)

0 commit comments

Comments
 (0)