@@ -72,11 +72,14 @@ def get_network_watcher_from_location(cmd, watcher_name="watcher_name", rg_name=
7272
7373
7474def get_network_watcher_from_vm (cmd ):
75+ from ...vm .operations .vm import VMShow
7576 args = cmd .ctx .args
76- compute_client = get_mgmt_service_client (cmd .cli_ctx , ResourceType .MGMT_COMPUTE ).virtual_machines
7777 vm_name = parse_resource_id (args .vm .to_serialized_data ())["name" ]
78- vm = compute_client .get (args .resource_group_name , vm_name )
79- args .location = vm .location
78+ vm = VMShow (cli_ctx = cmd .cli_ctx )(command_args = {
79+ 'resource_group' : args .resource_group_name ,
80+ 'vm_name' : vm_name
81+ })
82+ args .location = vm .get ('location' )
8083 get_network_watcher_from_location (cmd )
8184
8285
@@ -88,11 +91,14 @@ def get_network_watcher_from_resource(cmd):
8891
8992
9093def get_network_watcher_from_vmss (cmd ):
94+ from ...vm .operations .vmss import VMSSShow
9195 args = cmd .ctx .args
92- compute_client = get_mgmt_service_client (cmd .cli_ctx , ResourceType .MGMT_COMPUTE ).virtual_machine_scale_sets
9396 vmss_name = parse_resource_id (args .target .to_serialized_data ())["name" ]
94- vmss = compute_client .get (args .resource_group_name , vmss_name )
95- args .location = vmss .location
97+ vmss = VMSSShow (cli_ctx = cmd .cli_ctx )(command_args = {
98+ 'resource_group' : args .resource_group_name ,
99+ 'vm_scale_set_name' : vmss_name
100+ })
101+ args .location = vmss .get ('location' )
96102 get_network_watcher_from_location (cmd )
97103
98104
@@ -387,16 +393,19 @@ def _build_arguments_schema(cls, *args, **kwargs):
387393 return args_schema
388394
389395 def pre_operations (self ):
396+ from ...vm .operations .vm import VMShow
390397 args = self .ctx .args
391- compute_client = get_mgmt_service_client (self .cli_ctx , ResourceType .MGMT_COMPUTE ).virtual_machines
392398 id_parts = parse_resource_id (args .source_resource .to_serialized_data ())
393399 vm_name = id_parts ["name" ]
394400 rg = args .resource_group_name or id_parts .get ("resource_group" , None )
395401 if not rg :
396402 raise ValidationError ("usage error: --source-resource ID | --source-resource NAME --resource-group NAME" )
397403
398- vm = compute_client .get (rg , vm_name )
399- args .location = vm .location
404+ vm = VMShow (cli_ctx = self .cli_ctx )(command_args = {
405+ 'resource_group' : rg ,
406+ 'vm_name' : vm_name
407+ })
408+ args .location = vm .get ('location' )
400409 get_network_watcher_from_location (self )
401410
402411 if has_value (args .source_resource ) and not is_valid_resource_id (args .source_resource .to_serialized_data ()):
0 commit comments