-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Compute] Increase robustness of vm image list #12134
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,15 +40,28 @@ 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): | ||
offers = client.virtual_machine_images.list_offers(location, publisher) | ||
from msrestazure.azure_exceptions import CloudError | ||
try: | ||
offers = client.virtual_machine_images.list_offers(location, publisher) | ||
except CloudError as e: | ||
logger.warning(str(e)) | ||
return | ||
if offer: | ||
offers = [o for o in offers if _matched(offer, o.name)] | ||
for o in offers: | ||
skus = client.virtual_machine_images.list_skus(location, publisher, o.name) | ||
try: | ||
skus = client.virtual_machine_images.list_skus(location, publisher, o.name) | ||
except CloudError as e: | ||
logger.warning(str(e)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if meet exception for some There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. |
||
continue | ||
if sku: | ||
skus = [s for s in skus if _matched(sku, s.name)] | ||
for s in skus: | ||
images = client.virtual_machine_images.list(location, publisher, o.name, s.name) | ||
try: | ||
images = client.virtual_machine_images.list(location, publisher, o.name, s.name) | ||
except CloudError as e: | ||
logger.warning(str(e)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. e.message? I'm not familiar with it. What's the difference between There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I know, str(object) will call the object._str_() at last. and e.message is just a property of e. Whether these two values are the same depends on how to implement the function _str_(). If it return message directly, they will be the same. However, for most cases, _str_ will serialize all the properties of the object. @myronfanqiu There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. str(e) can tell more details including which publisher cannot be found. It's ok to use e.message here. The difference depends on specific implementation. |
||
continue | ||
for i in images: | ||
all_images.append({ | ||
'publisher': publisher, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously, if there is an exception, it will be treated as an error. After updating, it will be treated as a warning, right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. There are many publishers. This function will be invoked many times. An error will fail the command. But there are other valid publishers. So I catch it.