Skip to content
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

ovirt_host_pm: Bug fixes for power management #47659

Merged
merged 1 commit into from
Oct 26, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 17 additions & 2 deletions lib/ansible/modules/cloud/ovirt/ovirt_host_pm.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,13 @@ def update_check(self, entity):

class HostPmModule(BaseModule):

def pre_create(self, entity):
# Save the entity, so we know if Agent already existed
self.entity = entity

def build_entity(self):
last = next((s for s in sorted([a.order for a in self._service.list()])), 0)
order = self.param('order') if self.param('order') is not None else self.entity.order if self.entity else last + 1
return otypes.Agent(
address=self._module.params['address'],
encrypt_options=self._module.params['encrypt_options'],
Expand All @@ -158,14 +164,23 @@ def build_entity(self):
port=self._module.params['port'],
type=self._module.params['type'],
username=self._module.params['username'],
order=self._module.params.get('order', 100),
order=order,
)

def update_check(self, entity):
def check_options():
if self.param('options'):
current = []
if entity.options:
current = [(opt.name, str(opt.value)) for opt in entity.options]
passed = [(k, str(v)) for k, v in self.param('options').items()]
return sorted(current) == sorted(passed)
return True

return (
check_options() and
equal(self._module.params.get('address'), entity.address) and
equal(self._module.params.get('encrypt_options'), entity.encrypt_options) and
equal(self._module.params.get('password'), entity.password) and
equal(self._module.params.get('username'), entity.username) and
equal(self._module.params.get('port'), entity.port) and
equal(self._module.params.get('type'), entity.type) and
Expand Down