diff --git a/src/ssh/HISTORY.md b/src/ssh/HISTORY.md index c681d5706c2..b83c5c8dc03 100644 --- a/src/ssh/HISTORY.md +++ b/src/ssh/HISTORY.md @@ -1,5 +1,9 @@ Release History =============== +2.1.0 +----- +* Migrate code from Azure SDK to AAZ based commands for compute operations (VM) + 2.0.6 ----- * Remove msrestazure dependency diff --git a/src/ssh/azext_ssh/ip_utils.py b/src/ssh/azext_ssh/ip_utils.py index d32042d1a7c..055e642edf3 100644 --- a/src/ssh/azext_ssh/ip_utils.py +++ b/src/ssh/azext_ssh/ip_utils.py @@ -3,8 +3,6 @@ # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- -from azure.cli.core.commands import client_factory -from azure.cli.core import profiles from azure.mgmt.core.tools import parse_resource_id from knack import log @@ -13,17 +11,20 @@ def get_ssh_ip(cmd, resource_group, vm_name, use_private_ip): - compute_client = client_factory.get_mgmt_service_client(cmd.cli_ctx, profiles.ResourceType.MGMT_COMPUTE) - vm_client = compute_client.virtual_machines from .aaz.latest.network.public_ip import Show as PublicIpShow from .aaz.latest.network.nic import Show as InterfaceShow + from azure.cli.command_modules.vm.aaz.latest.vm import Show as VMShow - vm = vm_client.get(resource_group, vm_name) + command_args = { + 'resource_group': resource_group, + 'vm_name': vm_name + } + vm = VMShow(cli_ctx=cmd.cli_ctx)(command_args=command_args) private_ips = [] - for nic_ref in vm.network_profile.network_interfaces: - parsed_id = parse_resource_id(nic_ref.id) + for nic_ref in vm.get('networkProfile', {}).get('networkInterfaces', []): + parsed_id = parse_resource_id(nic_ref.get('id')) get_args = { 'name': parsed_id['name'], 'resource_group': parsed_id['resource_group'] diff --git a/src/ssh/azext_ssh/target_os_utils.py b/src/ssh/azext_ssh/target_os_utils.py index efda19eb352..0a07929f90b 100644 --- a/src/ssh/azext_ssh/target_os_utils.py +++ b/src/ssh/azext_ssh/target_os_utils.py @@ -51,19 +51,20 @@ def handle_target_os_type(cmd, op_info): def _get_azure_vm_os(cmd, resource_group_name, vm_name): - from azure.cli.core.commands import client_factory - from azure.cli.core import profiles - vm = None + from azure.cli.command_modules.vm.aaz.latest.vm import Show as VMShow os_type = None # pylint: disable=broad-except try: - compute_client = client_factory.get_mgmt_service_client(cmd.cli_ctx, profiles.ResourceType.MGMT_COMPUTE) - vm = compute_client.virtual_machines.get(resource_group_name, vm_name) + command_args = { + 'resource_group': resource_group_name, + 'vm_name': vm_name + } + vm = VMShow(cli_ctx=cmd.cli_ctx)(command_args=command_args) except Exception: return None - if vm and vm.storage_profile and vm.storage_profile.os_disk and vm.storage_profile.os_disk.os_type: - os_type = vm.storage_profile.os_disk.os_type + if vm and vm.get('storageProfile', {}).get('osDisk', {}).get('osType'): + os_type = vm['storageProfile']['osDisk']['osType'] return os_type diff --git a/src/ssh/setup.py b/src/ssh/setup.py index 4ad30289af0..fe7d2e17745 100644 --- a/src/ssh/setup.py +++ b/src/ssh/setup.py @@ -7,7 +7,7 @@ from setuptools import setup, find_packages -VERSION = "2.0.6" +VERSION = "2.1.0" CLASSIFIERS = [ 'Development Status :: 4 - Beta',