|
|
|
@ -214,6 +214,19 @@ options:
|
|
|
|
|
- "C(Note:)"
|
|
|
|
|
- "This is supported since oVirt version 4.1."
|
|
|
|
|
version_added: 2.4
|
|
|
|
|
external_network_providers:
|
|
|
|
|
description:
|
|
|
|
|
- "List of references to the external network providers available
|
|
|
|
|
in the cluster. If the automatic deployment of the external
|
|
|
|
|
network provider is supported, the networks of the referenced
|
|
|
|
|
network provider are available on every host in the cluster."
|
|
|
|
|
- "External network provider is described by following dictionary:"
|
|
|
|
|
- "C(name) - Name of the external network provider. Either C(name)
|
|
|
|
|
or C(id) is required."
|
|
|
|
|
- "C(id) - ID of the external network provider. Either C(name) or
|
|
|
|
|
C(id) is required."
|
|
|
|
|
- "This is supported since oVirt version 4.2."
|
|
|
|
|
version_added: 2.5
|
|
|
|
|
extends_documentation_fragment: ovirt
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
@ -250,6 +263,14 @@ EXAMPLES = '''
|
|
|
|
|
- hwrng
|
|
|
|
|
- random
|
|
|
|
|
|
|
|
|
|
# Create cluster with default network provider
|
|
|
|
|
- ovirt_cluster:
|
|
|
|
|
name: mycluster
|
|
|
|
|
data_center: Default
|
|
|
|
|
cpu_type: Intel SandyBridge Family
|
|
|
|
|
external_network_providers:
|
|
|
|
|
- name: ovirt-provider-ovn
|
|
|
|
|
|
|
|
|
|
# Remove cluster
|
|
|
|
|
- ovirt_cluster:
|
|
|
|
|
state: absent
|
|
|
|
@ -352,6 +373,20 @@ class ClustersModule(BaseModule):
|
|
|
|
|
|
|
|
|
|
return mac_pool
|
|
|
|
|
|
|
|
|
|
def _get_external_network_providers(self):
|
|
|
|
|
return self.param('external_network_providers') or []
|
|
|
|
|
|
|
|
|
|
def _get_external_network_provider_id(self, external_provider):
|
|
|
|
|
return external_provider.get('id') or get_id_by_name(
|
|
|
|
|
self._connection.system_service().openstack_network_providers_service(),
|
|
|
|
|
external_provider.get('name')
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def _get_external_network_providers_entity(self):
|
|
|
|
|
if self.param('external_network_providers') is not None:
|
|
|
|
|
return [otypes.ExternalProvider(id=self._get_external_network_provider_id(external_provider))
|
|
|
|
|
for external_provider in self.param('external_network_providers')]
|
|
|
|
|
|
|
|
|
|
def build_entity(self):
|
|
|
|
|
sched_policy = self._get_sched_policy()
|
|
|
|
|
return otypes.Cluster(
|
|
|
|
@ -465,8 +500,30 @@ class ClustersModule(BaseModule):
|
|
|
|
|
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,
|
|
|
|
|
external_network_providers=self._get_external_network_providers_entity(),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def _matches_entity(self, item, entity):
|
|
|
|
|
return equal(item.get('id'), entity.id) and equal(item.get('name'), entity.name)
|
|
|
|
|
|
|
|
|
|
def _update_check_external_network_providers(self, entity):
|
|
|
|
|
if entity.external_network_providers is None:
|
|
|
|
|
return not self.param('external_network_providers')
|
|
|
|
|
entity_providers = self._connection.follow_link(entity.external_network_providers)
|
|
|
|
|
entity_provider_ids = [provider.id for provider in entity_providers]
|
|
|
|
|
entity_provider_names = [provider.name for provider in entity_providers]
|
|
|
|
|
for provider in self._get_external_network_providers():
|
|
|
|
|
if provider.get('id'):
|
|
|
|
|
if provider.get('id') not in entity_provider_ids:
|
|
|
|
|
return False
|
|
|
|
|
elif provider.get('name') and provider.get('name') not in entity_provider_names:
|
|
|
|
|
return False
|
|
|
|
|
for entity_provider in entity_providers:
|
|
|
|
|
if not any([self._matches_entity(provider, entity_provider)
|
|
|
|
|
for provider in self._get_external_network_providers()]):
|
|
|
|
|
return False
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def update_check(self, entity):
|
|
|
|
|
sched_policy = self._get_sched_policy()
|
|
|
|
|
migration_policy = getattr(entity.migration, 'policy', None)
|
|
|
|
@ -515,7 +572,8 @@ class ClustersModule(BaseModule):
|
|
|
|
|
equal(
|
|
|
|
|
get_id_by_name(self._connection.system_service().mac_pools_service(), self.param('mac_pool'), raise_error=False),
|
|
|
|
|
entity.mac_pool.id
|
|
|
|
|
)
|
|
|
|
|
) and
|
|
|
|
|
self._update_check_external_network_providers(entity)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -564,6 +622,7 @@ def main():
|
|
|
|
|
switch_type=dict(default=None, choices=['legacy', 'ovs']),
|
|
|
|
|
compatibility_version=dict(default=None),
|
|
|
|
|
mac_pool=dict(default=None),
|
|
|
|
|
external_network_providers=dict(default=None, type='list'),
|
|
|
|
|
)
|
|
|
|
|
module = AnsibleModule(
|
|
|
|
|
argument_spec=argument_spec,
|
|
|
|
|