mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Add power_manage_enabled option to ovirt_hosts module (#28154)
* cloud: ovirt: Add possibility to enable PM of host * cloud: ovirt_hosts: user self.param to get module params
This commit is contained in:
parent
5fec649052
commit
e9c9473819
1 changed files with 34 additions and 24 deletions
|
@ -103,6 +103,11 @@ options:
|
|||
- "If I(undeploy) it means this host should un-deploy hosted engine
|
||||
components and this host will not function as part of the High
|
||||
Availability cluster."
|
||||
power_management_enabled:
|
||||
description:
|
||||
- "Enable or disable power management of the host."
|
||||
- "For more comprehensive setup of PM use C(ovirt_host_pm) module."
|
||||
version_added: 2.4
|
||||
extends_documentation_fragment: ovirt
|
||||
'''
|
||||
|
||||
|
@ -204,38 +209,42 @@ class HostsModule(BaseModule):
|
|||
|
||||
def build_entity(self):
|
||||
return otypes.Host(
|
||||
name=self._module.params['name'],
|
||||
name=self.param('name'),
|
||||
cluster=otypes.Cluster(
|
||||
name=self._module.params['cluster']
|
||||
) if self._module.params['cluster'] else None,
|
||||
comment=self._module.params['comment'],
|
||||
address=self._module.params['address'],
|
||||
root_password=self._module.params['password'],
|
||||
name=self.param('cluster')
|
||||
) if self.param('cluster') else None,
|
||||
comment=self.param('comment'),
|
||||
address=self.param('address'),
|
||||
root_password=self.param('password'),
|
||||
ssh=otypes.Ssh(
|
||||
authentication_method=otypes.SshAuthenticationMethod.PUBLICKEY,
|
||||
) if self._module.params['public_key'] else None,
|
||||
) if self.param('public_key') else None,
|
||||
kdump_status=otypes.KdumpStatus(
|
||||
self._module.params['kdump_integration']
|
||||
) if self._module.params['kdump_integration'] else None,
|
||||
self.param('kdump_integration')
|
||||
) if self.param('kdump_integration') else None,
|
||||
spm=otypes.Spm(
|
||||
priority=self._module.params['spm_priority'],
|
||||
) if self._module.params['spm_priority'] else None,
|
||||
override_iptables=self._module.params['override_iptables'],
|
||||
priority=self.param('spm_priority'),
|
||||
) if self.param('spm_priority') else None,
|
||||
override_iptables=self.param('override_iptables'),
|
||||
display=otypes.Display(
|
||||
address=self._module.params['override_display'],
|
||||
) if self._module.params['override_display'] else None,
|
||||
address=self.param('override_display'),
|
||||
) if self.param('override_display') else None,
|
||||
os=otypes.OperatingSystem(
|
||||
custom_kernel_cmdline=' '.join(self._module.params['kernel_params']),
|
||||
) if self._module.params['kernel_params'] else None,
|
||||
custom_kernel_cmdline=' '.join(self.param('kernel_params')),
|
||||
) if self.param('kernel_params') else None,
|
||||
power_management=otypes.PowerManagement(
|
||||
enabled=self.param('power_management_enabled'),
|
||||
) if self.param('power_management_enabled') is not None else None,
|
||||
)
|
||||
|
||||
def update_check(self, entity):
|
||||
kernel_params = self._module.params.get('kernel_params')
|
||||
kernel_params = self.param('kernel_params')
|
||||
return (
|
||||
equal(self._module.params.get('comment'), entity.comment) and
|
||||
equal(self._module.params.get('kdump_integration'), entity.kdump_status) and
|
||||
equal(self._module.params.get('spm_priority'), entity.spm.priority) and
|
||||
equal(self._module.params.get('override_display'), getattr(entity.display, 'address', None)) and
|
||||
equal(self.param('comment'), entity.comment) and
|
||||
equal(self.param('kdump_integration'), entity.kdump_status) and
|
||||
equal(self.param('spm_priority'), entity.spm.priority) and
|
||||
equal(self.param('power_management_enabled'), entity.power_management.enabled) and
|
||||
equal(self.param('override_display'), getattr(entity.display, 'address', None)) and
|
||||
equal(
|
||||
sorted(kernel_params) if kernel_params else None,
|
||||
sorted(entity.os.custom_kernel_cmdline.split(' '))
|
||||
|
@ -251,7 +260,7 @@ class HostsModule(BaseModule):
|
|||
)
|
||||
|
||||
def post_update(self, entity):
|
||||
if entity.status != hoststate.UP and self._module.params['state'] == 'present':
|
||||
if entity.status != hoststate.UP and self.param('state') == 'present':
|
||||
if not self._module.check_mode:
|
||||
self._service.host_service(entity.id).activate()
|
||||
self.changed = True
|
||||
|
@ -261,8 +270,8 @@ class HostsModule(BaseModule):
|
|||
service=self._service.service(host.id),
|
||||
condition=lambda h: h.status != hoststate.MAINTENANCE,
|
||||
fail_condition=failed_state,
|
||||
wait=self._module.params['wait'],
|
||||
timeout=self._module.params['timeout'],
|
||||
wait=self.param('wait'),
|
||||
timeout=self.param('timeout'),
|
||||
)
|
||||
|
||||
|
||||
|
@ -336,6 +345,7 @@ def main():
|
|||
override_display=dict(default=None),
|
||||
kernel_params=dict(default=None, type='list'),
|
||||
hosted_engine=dict(default=None, choices=['deploy', 'undeploy']),
|
||||
power_management_enabled=dict(default=None, type='bool'),
|
||||
)
|
||||
module = AnsibleModule(
|
||||
argument_spec=argument_spec,
|
||||
|
|
Loading…
Reference in a new issue