Backports to 2.5 of recent oVirt fixes (#38835)
* ovirt_disks: Fix fail condition for LUN disk Fixes: https://github.com/ansible/ansible/issues/38661 * ovirt_host_networks: Fix removing of network attachments * ovirt: Support removing unmanaged networks * ovirt: FCP storage domains don't have to have target
This commit is contained in:
parent
cb27ed5a58
commit
757fb5263f
3 changed files with 18 additions and 5 deletions
|
@ -528,7 +528,7 @@ class DisksModule(BaseModule):
|
|||
def _update_check(self, entity):
|
||||
return (
|
||||
equal(self._module.params.get('description'), entity.description) and
|
||||
equal(self.param('quota_id'), getattr(entity.quota, 'id')) and
|
||||
equal(self.param('quota_id'), getattr(entity.quota, 'id', None)) and
|
||||
equal(convert_to_bytes(self._module.params.get('size')), entity.provisioned_size) and
|
||||
equal(self._module.params.get('shareable'), entity.shareable)
|
||||
)
|
||||
|
@ -616,7 +616,7 @@ def main():
|
|||
ret = disks_module.create(
|
||||
entity=disk,
|
||||
result_state=otypes.DiskStatus.OK if lun is None else None,
|
||||
fail_condition=lambda d: d.status == otypes.DiskStatus.ILLEGAL,
|
||||
fail_condition=lambda d: d.status == otypes.DiskStatus.ILLEGAL if lun is None else False,
|
||||
)
|
||||
is_new_disk = ret['changed']
|
||||
ret['changed'] = ret['changed'] or disks_module.update_storage_domains(ret['id'])
|
||||
|
|
|
@ -412,17 +412,27 @@ def main():
|
|||
] if networks else None,
|
||||
)
|
||||
elif state == 'absent' and nic:
|
||||
attachments = []
|
||||
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:
|
||||
attachments_service = nic_service.network_attachments_service()
|
||||
attachments = attachments_service.list()
|
||||
attachments = [
|
||||
attachment for attachment in attachments
|
||||
if get_link_name(connection, attachment.network) in network_names
|
||||
]
|
||||
|
||||
# Remove unmanaged networks:
|
||||
unmanaged_networks_service = host_service.unmanaged_networks_service()
|
||||
unmanaged_networks = [(u.id, u.name) for u in unmanaged_networks_service.list()]
|
||||
for net_id, net_name in unmanaged_networks:
|
||||
if net_name in network_names:
|
||||
if not module.check_mode:
|
||||
unmanaged_networks_service.unmanaged_network_service(net_id).remove()
|
||||
host_networks_module.changed = True
|
||||
|
||||
# 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:
|
||||
|
@ -439,7 +449,7 @@ def main():
|
|||
removed_labels=[
|
||||
otypes.NetworkLabel(id=str(name)) for name in labels
|
||||
] if labels else None,
|
||||
removed_network_attachments=list(attachments),
|
||||
removed_network_attachments=attachments if attachments else None,
|
||||
)
|
||||
|
||||
nic = search_by_name(nics_service, nic_name)
|
||||
|
|
|
@ -350,6 +350,9 @@ class StorageDomainModule(BaseModule):
|
|||
return [(lun_id, storage.get('target')) for lun_id in lun_ids]
|
||||
elif storage.get('target_lun_map'):
|
||||
return [(target_map.get('lun_id'), target_map.get('target')) for target_map in storage.get('target_lun_map')]
|
||||
else:
|
||||
lun_ids = storage.get('lun_id') if isinstance(storage.get('lun_id'), list) else [(storage.get('lun_id'))]
|
||||
return [(lun_id, None) for lun_id in lun_ids]
|
||||
|
||||
def build_entity(self):
|
||||
storage_type = self._get_storage_type()
|
||||
|
|
Loading…
Reference in a new issue