Fixes for oVirt modules (#36846)
* ovirt_vms: Fix boot devices idempotence * ovirt_host_networks: Fix removing the label * ovirt_vms: Fix NoneType in placement policy check Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1549082 * int("255.255.255.0" does not work, fixes issue #33867 (#36271)
This commit is contained in:
parent
f14e0e7ee3
commit
3257fe28f3
2 changed files with 20 additions and 11 deletions
|
@ -180,7 +180,7 @@ class HostNetworksModule(BaseModule):
|
|||
if not equal(network.get('gateway'), ip.ip.gateway):
|
||||
ip.ip.gateway = network.get('gateway')
|
||||
changed = True
|
||||
if not equal(network.get('prefix'), int(ip.ip.netmask) if ip.ip.netmask else None):
|
||||
if not equal(network.get('prefix'), sum([bin(int(x)).count('1') for x in ip.ip.netmask.split('.')]) if ip.ip.netmask else None):
|
||||
ip.ip.netmask = str(network.get('prefix'))
|
||||
changed = True
|
||||
|
||||
|
@ -347,15 +347,21 @@ def main():
|
|||
] if networks else None,
|
||||
)
|
||||
elif state == 'absent' and nic:
|
||||
attachments_service = nics_service.nic_service(nic.id).network_attachments_service()
|
||||
nic_service = nics_service.nic_service(nic.id)
|
||||
|
||||
attachments_service = nic_service.network_attachments_service()
|
||||
attachments = attachments_service.list()
|
||||
attached_labels = set([str(lbl.id) for lbl in nic_service.network_labels_service().list()])
|
||||
if networks:
|
||||
network_names = [network['name'] for network in networks]
|
||||
attachments = [
|
||||
attachment for attachment in attachments
|
||||
if get_link_name(connection, attachment.network) in network_names
|
||||
]
|
||||
if labels or bond or attachments:
|
||||
|
||||
# Need to check if there are any labels to be removed, as backend fail
|
||||
# if we try to send remove non existing label, for bond and attachments it's OK:
|
||||
if (labels and set(labels).intersection(attached_labels)) or bond or attachments:
|
||||
host_networks_module.action(
|
||||
entity=host,
|
||||
action='setup_networks',
|
||||
|
@ -367,10 +373,8 @@ def main():
|
|||
),
|
||||
] if bond else None,
|
||||
removed_labels=[
|
||||
otypes.NetworkLabel(
|
||||
name=str(name),
|
||||
) for name in labels
|
||||
] if labels else None,
|
||||
otypes.NetworkLabel(id=str(name)) for name in labels
|
||||
],
|
||||
removed_network_attachments=list(attachments),
|
||||
)
|
||||
|
||||
|
|
|
@ -1068,11 +1068,17 @@ class VmsModule(BaseModule):
|
|||
return sorted(current) == sorted(passed)
|
||||
return True
|
||||
|
||||
def check_host():
|
||||
if self.param('host') is not None:
|
||||
return self.param('host') in [self._connection.follow_link(host).name for host in getattr(entity.placement_policy, 'hosts', None) or []]
|
||||
return True
|
||||
|
||||
cpu_mode = getattr(entity.cpu, 'mode')
|
||||
vm_display = entity.display
|
||||
return (
|
||||
check_cpu_pinning() and
|
||||
check_custom_properties() and
|
||||
check_host() and
|
||||
not self.param('cloud_init_persist') and
|
||||
equal(self.param('cluster'), get_link_name(self._connection, entity.cluster)) and equal(convert_to_bytes(self.param('memory')), entity.memory) and
|
||||
equal(convert_to_bytes(self.param('memory_guaranteed')), entity.memory_policy.guaranteed) and
|
||||
|
@ -1099,16 +1105,15 @@ class VmsModule(BaseModule):
|
|||
equal(self.param('cpu_shares'), entity.cpu_shares) and
|
||||
equal(self.param('delete_protected'), entity.delete_protected) and
|
||||
equal(self.param('use_latest_template_version'), entity.use_latest_template_version) and
|
||||
equal(self.param('boot_devices'), [str(dev) for dev in getattr(entity.os, 'devices', [])]) and
|
||||
equal(self.param('boot_devices'), [str(dev) for dev in getattr(entity.os.boot, 'devices', [])]) and
|
||||
equal(self.param('instance_type'), get_link_name(self._connection, entity.instance_type), ignore_case=True) and
|
||||
equal(self.param('description'), entity.description) and
|
||||
equal(self.param('comment'), entity.comment) and
|
||||
equal(self.param('timezone'), getattr(entity.time_zone, 'name', None)) and
|
||||
equal(self.param('serial_policy'), str(getattr(entity.serial_number, 'policy', None))) and
|
||||
equal(self.param('serial_policy_value'), getattr(entity.serial_number, 'value', None)) and
|
||||
equal(self.param('placement_policy'), str(entity.placement_policy.affinity)) and
|
||||
equal(self.param('rng_device'), str(entity.rng_device.source) if entity.rng_device else None) and
|
||||
self.param('host') in [self._connection.follow_link(host).name for host in entity.placement_policy.hosts or []]
|
||||
equal(self.param('placement_policy'), str(entity.placement_policy.affinity) if entity.placement_policy else None) and
|
||||
equal(self.param('rng_device'), str(entity.rng_device.source) if entity.rng_device else None)
|
||||
)
|
||||
|
||||
def pre_create(self, entity):
|
||||
|
|
Loading…
Reference in a new issue