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

add old usages to network cluster (#47185)

* add old usages to network cluster

* set default value to old usages

* rename cluster_network_service to cluster_network_entity
This commit is contained in:
Martin Nečas 2018-11-06 16:36:27 +01:00 committed by ansibot
parent 602d02be5f
commit 1441c6ad3f

View file

@ -146,6 +146,7 @@ from ansible.module_utils.ovirt import (
search_by_name, search_by_name,
get_id_by_name, get_id_by_name,
get_dict_of_struct, get_dict_of_struct,
get_entity
) )
@ -213,6 +214,10 @@ class ClusterNetworksModule(BaseModule):
super(ClusterNetworksModule, self).__init__(*args, **kwargs) super(ClusterNetworksModule, self).__init__(*args, **kwargs)
self._network_id = network_id self._network_id = network_id
self._cluster_network = cluster_network self._cluster_network = cluster_network
self._old_usages = []
self._cluster_network_entity = get_entity(self._service.network_service(network_id))
if self._cluster_network_entity is not None:
self._old_usages = self._cluster_network_entity.usages
def build_entity(self): def build_entity(self):
return otypes.Network( return otypes.Network(
@ -220,11 +225,12 @@ class ClusterNetworksModule(BaseModule):
name=self._module.params['name'], name=self._module.params['name'],
required=self._cluster_network.get('required'), required=self._cluster_network.get('required'),
display=self._cluster_network.get('display'), display=self._cluster_network.get('display'),
usages=[ usages=list(set([
otypes.NetworkUsage(usage) otypes.NetworkUsage(usage)
for usage in ['display', 'gluster', 'migration'] for usage in ['display', 'gluster', 'migration']
if self._cluster_network.get(usage, False) if self._cluster_network.get(usage, False)
] if ( ] + self._old_usages))
if (
self._cluster_network.get('display') is not None or self._cluster_network.get('display') is not None or
self._cluster_network.get('gluster') is not None or self._cluster_network.get('gluster') is not None or
self._cluster_network.get('migration') is not None self._cluster_network.get('migration') is not None