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
cs_vpc_offering: listVPCOffering API returns any matching names #37783
cs_vpc_offering: listVPCOffering API returns any matching names #37783
Conversation
@@ -149,7 +149,9 @@ def get_vpc_offering(self): | |||
vo = self.query_api('listVPCOfferings', **args) | |||
|
|||
if vo: | |||
self.vpc_offering = vo['vpcoffering'][0] | |||
for index, vpc_offer in enumerate(vo['vpcoffering']): |
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.
any reason why we should not use a simplified loop?
for vpc_offer in vo['vpcoffering']:
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.
Indeed, a simplified loop do the same.
Thanks for this fix, are you aware of other queries (is this a general thing?) which have the same behaviour? |
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.
needs_info
From what I understand from the Cloudstack code, the following queries have the same behaviour:
|
cs_configuration always returns 'Changed' when name=workers for example. |
I created a separate issue #37824 |
shipit |
cherry-picked for 2.5.1 by #37832 |
SUMMARY
Make an explicit comparison between args['name'] and the result of listVPCOfferings API.
In some cases, get_vpc_offering() returns a bad VPC Offering since the Cloudstack listVPCOffering API returns a list of all VPC offerings that are matching "%name%" argument.
ISSUE TYPE
COMPONENT NAME
lib/ansible/modules/cloud/cloudstack/cs_vpc_offering.py
ANSIBLE VERSION
ADDITIONAL INFORMATION
As get_vpc_offering() returns the first offering that match the name '%test%', running this playbook twice is failing: