ovirt_host_networks: Fix label assignment (#31969)

This commit is contained in:
Ondra Machacek 2017-10-20 11:42:26 +02:00 committed by ansibot
parent 98eac19e81
commit d6b564966f

View file

@ -194,6 +194,7 @@ class HostNetworksModule(BaseModule):
update = False update = False
bond = self._module.params['bond'] bond = self._module.params['bond']
networks = self._module.params['networks'] networks = self._module.params['networks']
labels = self._module.params['labels']
nic = get_entity(nic_service) nic = get_entity(nic_service)
if nic is None: if nic is None:
@ -209,6 +210,12 @@ class HostNetworksModule(BaseModule):
) )
) )
# Check if labels need to be updated on interface/bond:
if labels:
net_labels = nic_service.network_labels_service().list()
if sorted(labels) != sorted([lbl.id for lbl in net_labels]):
return True
if not networks: if not networks:
return update return update
@ -307,7 +314,7 @@ def main():
] if bond else None, ] if bond else None,
modified_labels=[ modified_labels=[
otypes.NetworkLabel( otypes.NetworkLabel(
name=str(name), id=str(name),
host_nic=otypes.HostNic( host_nic=otypes.HostNic(
name=bond.get('name') if bond else interface name=bond.get('name') if bond else interface
), ),