mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
ovirt_host_pm: Fix to powermanagement module (#47659)
This PR is fixing following issues: 1) Don't try to check password. 2) Check options. 3) Order wasn't adding at the end, as doc says. Signed-off-by: Ondra Machacek <omachace@redhat.com>
This commit is contained in:
parent
82f1438b14
commit
ec441cd4bc
1 changed files with 17 additions and 2 deletions
|
@ -144,7 +144,13 @@ class HostModule(BaseModule):
|
||||||
|
|
||||||
class HostPmModule(BaseModule):
|
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):
|
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(
|
return otypes.Agent(
|
||||||
address=self._module.params['address'],
|
address=self._module.params['address'],
|
||||||
encrypt_options=self._module.params['encrypt_options'],
|
encrypt_options=self._module.params['encrypt_options'],
|
||||||
|
@ -158,14 +164,23 @@ class HostPmModule(BaseModule):
|
||||||
port=self._module.params['port'],
|
port=self._module.params['port'],
|
||||||
type=self._module.params['type'],
|
type=self._module.params['type'],
|
||||||
username=self._module.params['username'],
|
username=self._module.params['username'],
|
||||||
order=self._module.params.get('order', 100),
|
order=order,
|
||||||
)
|
)
|
||||||
|
|
||||||
def update_check(self, entity):
|
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 (
|
return (
|
||||||
|
check_options() and
|
||||||
equal(self._module.params.get('address'), entity.address) 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('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('username'), entity.username) and
|
||||||
equal(self._module.params.get('port'), entity.port) and
|
equal(self._module.params.get('port'), entity.port) and
|
||||||
equal(self._module.params.get('type'), entity.type) and
|
equal(self._module.params.get('type'), entity.type) and
|
||||||
|
|
Loading…
Reference in a new issue