-
Notifications
You must be signed in to change notification settings - Fork 341
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
vmware_resource_pool: Add new allocation shares options for cpu and memory #461
Conversation
recheck |
9 similar comments
recheck |
recheck |
recheck |
recheck |
recheck |
recheck |
recheck |
recheck |
recheck |
@@ -0,0 +1,2 @@ | |||
minor_changes: | |||
- vmware_resource_pool - Add new allocation shares options for cpu and memory(https://github.com/ansible-collections/community.vmware/pull/461). |
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.
- vmware_resource_pool - Add new allocation shares options for cpu and memory(https://github.com/ansible-collections/community.vmware/pull/461). | |
- vmware_resource_pool - add new allocation shares options for cpu and memory(https://github.com/ansible-collections/community.vmware/pull/461). |
@@ -251,15 +263,24 @@ def state_add_rp(self): | |||
cpu_alloc.limit = int(self.cpu_limit) | |||
cpu_alloc.reservation = int(self.cpu_reservation) | |||
cpu_alloc_shares = vim.SharesInfo() | |||
cpu_alloc_shares.level = self.cpu_shares | |||
if self.cpu_shares == 'custom': | |||
cpu_alloc_shares.level = self.cpu_shares |
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.
if level
is common for both if
block, why not move them out of if
.
@@ -294,19 +315,25 @@ def main(): | |||
resource_pool=dict(required=True, type='str'), | |||
mem_shares=dict(type='str', default="normal", choices=[ | |||
'high', 'custom', 'normal', 'low']), | |||
mem_allocation_shares=dict(type='int'), |
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.
Can we set some default value just like other parameters?
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.
I added to the default value based on the normal value on vCenter 7.
@@ -97,3 +97,42 @@ | |||
assert: | |||
that: | |||
- "{{ resource_result_0004.changed == false }}" | |||
|
|||
# Testcase 0005: Add Resource pool with the mem_allocation_shares and cpu_allocation_shares parameters | |||
- name: add resource pool |
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.
Can you check idempotency here?
Thank you @Akasurde for reviewing this PR. |
recheck |
@Akasurde Done! |
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.
LGTM
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.
I'm not sure, but it looks like the module returns change=False
even if cpu_allocation_shares
or mem_allocation_shares
(or, in fact, anything else) differs from the current resource pool configuration. Is this correct? That would be an accident waiting to happen... but I'm not sure if this really needs to be fixed in this PR. Maybe we should open a new issue for this.
Otherwise, the code LGTM.
You're right. |
I'm thinking I'm going to work on this issue(#467) after merging this PR. |
I think your plan to implement new allocation shares options for cpu and memory in this PR and work on changing config values in another one makes sense. @Akasurde You asked for some idempotency tests. This hasn't been "officially" resolved, but since you said that the code looks good to you after the update the integration test commit, I'll add the |
Thank you @mariolenz @Akasurde |
SUMMARY
This PR is to add new allocation shares options for cpu and memory to the vmware_resource_pool module.
fixes: #444
ISSUE TYPE
COMPONENT NAME
plugins/modules/vmware_resource_pool.py
tests/integration/targets/vmware_resource_pool/tasks/main.yml
ADDITIONAL INFORMATION
tested on vCenter/ESXi 7.0