Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ def cf_trustedaccess_role_binding(cli_ctx, *_):


# dependent clients
def get_compute_client(cli_ctx, *_):
return get_mgmt_service_client(cli_ctx, ResourceType.MGMT_COMPUTE)


def get_resource_groups_client(cli_ctx, subscription_id=None):
return get_mgmt_service_client(cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES,
subscription_id=subscription_id).resource_groups
Expand Down
6 changes: 0 additions & 6 deletions src/azure-cli/azure/cli/command_modules/acs/_completers.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ def get_k8s_versions(cli_ctx, location):
return search("values[*].patchVersions.keys(@)[]", results)


def get_vm_sizes(cli_ctx, location):
from azure.cli.command_modules.acs._client_factory import get_compute_client

return get_compute_client(cli_ctx).virtual_machine_sizes.list(location)


def _get_location(cli_ctx, namespace):
"""
Return an Azure location by using an explicit `--location` argument, then by `--resource-group`, and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -528,18 +528,18 @@ def check_if_new_storagepool_creation_required(
def generate_vm_sku_cache_for_region(cli_ctx, location=None):
result = _get_vm_sku_details(cli_ctx, location)
for vm_data in result:
sku_name = vm_data.name.lower()
capabilities = vm_data.capabilities
sku_name = vm_data['name'].lower()
capabilities = vm_data.get('capabilities', [])
cpu_value = -1
nvme_enabled = False
for entry in capabilities:
if entry.name == 'vCPUs' and cpu_value == -1:
cpu_value = int(entry.value)
if entry['name'] == 'vCPUs' and cpu_value == -1:
cpu_value = int(entry['value'])

if entry.name == 'vCPUsAvailable':
cpu_value = int(entry.value)
if entry['name'] == 'vCPUsAvailable':
cpu_value = int(entry['value'])

if entry.name == 'NvmeDiskSizeInMiB':
if entry['name'] == 'NvmeDiskSizeInMiB':
nvme_enabled = True

vm_sku_details_cache[sku_name] = (cpu_value, nvme_enabled)
Expand Down Expand Up @@ -652,9 +652,9 @@ def _is_vm_in_required_location(desired_location, location_list):
return True
return False

from azure.cli.command_modules.acs._client_factory import get_compute_client
result = get_compute_client(cli_ctx).resource_skus.list()
result = [x for x in result if x.resource_type.lower() == 'virtualmachines']
from azure.cli.command_modules.vm.aaz.latest.vm import ListSkus
result = ListSkus(cli_ctx=cli_ctx)(command_args={})
result = [x for x in result if x['resourceType'].lower() == 'virtualmachines']
if location:
result = [r for r in result if _is_vm_in_required_location(location, r.locations)]
result = [r for r in result if _is_vm_in_required_location(location, r['locations'])]
Comment on lines +655 to +659
return result
Loading