1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

cloud/ovirt: set mac pools via ovirt_clusters (#28120)

MAC pools are set per cluster since ovirt 4.1. Before that it was set
per data center.
This commit is contained in:
Tareq Alayan 2017-08-23 15:45:25 +03:00 committed by Ryan Brown
parent 3c1ee57155
commit abc5910d86

View file

@ -208,6 +208,12 @@ options:
description: description:
- "The compatibility version of the cluster. All hosts in this - "The compatibility version of the cluster. All hosts in this
cluster must support at least this compatibility version." cluster must support at least this compatibility version."
mac_pool:
description:
- "MAC pool to be used by this cluster."
- "C(Note:)"
- "This is supported since oVirt version 4.1."
version_added: 2.4
extends_documentation_fragment: ovirt extends_documentation_fragment: ovirt
''' '''
@ -278,6 +284,7 @@ from ansible.module_utils.ovirt import (
equal, equal,
ovirt_full_argument_spec, ovirt_full_argument_spec,
search_by_name, search_by_name,
get_id_by_name,
) )
@ -335,6 +342,16 @@ class ClustersModule(BaseModule):
return sched_policy return sched_policy
def _get_mac_pool(self):
mac_pool = None
if self._module.params.get('mac_pool'):
mac_pool = search_by_name(
self._connection.system_service().mac_pools_service(),
self._module.params.get('mac_pool'),
)
return mac_pool
def build_entity(self): def build_entity(self):
sched_policy = self._get_sched_policy() sched_policy = self._get_sched_policy()
return otypes.Cluster( return otypes.Cluster(
@ -449,6 +466,9 @@ class ClustersModule(BaseModule):
switch_type=otypes.SwitchType( switch_type=otypes.SwitchType(
self.param('switch_type') self.param('switch_type')
) if self.param('switch_type') else None, ) if self.param('switch_type') else None,
mac_pool=otypes.MacPool(
id=get_id_by_name(self._connection.system_service().mac_pools_service(), self.param('mac_pool'))
) if self.param('mac_pool') else None,
) )
def update_check(self, entity): def update_check(self, entity):
@ -495,6 +515,10 @@ class ClustersModule(BaseModule):
sorted([ sorted([
str(source) for source in entity.required_rng_sources str(source) for source in entity.required_rng_sources
]) ])
) and
equal(
get_id_by_name(self._connection.system_service().mac_pools_service(), self.param('mac_pool')),
entity.mac_pool.id
) )
) )
@ -543,6 +567,7 @@ def main():
cpu_type=dict(default=None), cpu_type=dict(default=None),
switch_type=dict(default=None, choices=['legacy', 'ovs']), switch_type=dict(default=None, choices=['legacy', 'ovs']),
compatibility_version=dict(default=None), compatibility_version=dict(default=None),
mac_pool=dict(default=None),
) )
module = AnsibleModule( module = AnsibleModule(
argument_spec=argument_spec, argument_spec=argument_spec,