-
Notifications
You must be signed in to change notification settings - Fork 334
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
766 fixing azure rm virtualmachine top issue #767
766 fixing azure rm virtualmachine top issue #767
Conversation
@pgmgb I think your idea is correct, but it should not be changed in this way. My suggestions are as follows,
|
@Fred-sun thank you for the review. |
@pgmgb Thank you for your reply, your change is not very reasonable. I still recommend following the comments above to change. First, please put the "import" statement back to its original position, in accordance with code design specifications. Second, wrap your code. This is not necessary, but 160 characters per line is fine. Third, do not delete "top=1", otherwise the first version returned is not "latest", |
@Fred-sun def get_marketplace_image_version(self):
try:
versions = self.compute_client.virtual_machine_images.list(self.location,
self.image['publisher'],
self.image['offer'],
self.image['sku'],
top=1, # -> Not needed because the list would return all the time one result and disables the followed code
orderby='name desc') # -> "desc" not needed because of the followed code (return versions[len(versions) - 1]) will not work
except Exception as exc:
self.fail("Error fetching image {0} {1} {2} - {3}".format(self.image['publisher'],
self.image['offer'],
self.image['sku'],
str(exc)))
if versions and len(versions) > 0:
if self.image['version'] == 'latest':
return versions[len(versions) - 1] # -> Will return the latest image which resists on the last position inside the array
for version in versions:
if version.name == self.image['version']:
return version
self.fail("Error could not find image {0} {1} {2} {3}".format(self.image['publisher'],
self.image['offer'],
self.image['sku'],
self.image['version']))
return None If my understanding is wrong or the code needs still some rewriting, I would suggest that I close this pull request and only provide the test cases to the issue #766. I'm also fine if someone else fixes the issue. |
@pgmgb Thank you very much for your contribution, other changes are ok, please put the import statement back. Thank you very much!
|
@pgmgb can you revert the format changes? Too many changes. Also please help resolve the file conflicts. |
@pgmgb Small change requests.
|
ready_for_review |
1 similar comment
ready_for_review |
LGTM |
SUMMARY
Fixes #766
top=1
and adjustedorderby
forazure_rm_virtualmachine
/get_marketplace_image_version
azure_rm_virtualmachine
to cover latest and specific imagesISSUE TYPE
COMPONENT NAME
azure_rm_virtualmachine
ADDITIONAL INFORMATION