Skip to content
Merged
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
23 changes: 14 additions & 9 deletions src/azure-cli/azure/cli/command_modules/vm/_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,26 +47,26 @@ def load_images_thru_services(cli_ctx, publisher, offer, sku, location):
location = get_one_of_subscription_locations(cli_ctx)

def _load_images_from_publisher(publisher):
from msrestazure.azure_exceptions import CloudError
from azure.core.exceptions import ResourceNotFoundError
try:
offers = client.virtual_machine_images.list_offers(location, publisher)
except CloudError as e:
except ResourceNotFoundError as e:
logger.warning(str(e))
return
if offer:
offers = [o for o in offers if _matched(offer, o.name)]
for o in offers:
try:
skus = client.virtual_machine_images.list_skus(location, publisher, o.name)
except CloudError as e:
except ResourceNotFoundError as e:
logger.warning(str(e))
continue
if sku:
skus = [s for s in skus if _matched(sku, s.name)]
for s in skus:
try:
images = client.virtual_machine_images.list(location, publisher, o.name, s.name)
except CloudError as e:
except ResourceNotFoundError as e:
logger.warning(str(e))
continue
for i in images:
Expand Down Expand Up @@ -148,17 +148,22 @@ def load_extension_images_thru_services(cli_ctx, publisher, name, version, locat
location = get_one_of_subscription_locations(cli_ctx)

def _load_extension_images_from_publisher(publisher):
from msrestazure.azure_exceptions import CloudError
from azure.core.exceptions import ResourceNotFoundError
try:
types = client.virtual_machine_extension_images.list_types(location, publisher)
except CloudError: # PIR image publishers might not have any extension images, exception could raise
except ResourceNotFoundError as e:
# PIR image publishers might not have any extension images, exception could raise
logger.warning(str(e))
types = []
if name:
types = [t for t in types if _matched(name, t.name, partial_match)]
for t in types:
versions = client.virtual_machine_extension_images.list_versions(location,
publisher,
t.name)
try:
versions = client.virtual_machine_extension_images.list_versions(
location, publisher, t.name)
except ResourceNotFoundError as e:
logger.warning(str(e))
continue
if version:
versions = [v for v in versions if _matched(version, v.name, partial_match)]

Expand Down