Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ovirt-host-network: support commit on success #59212

Merged
merged 1 commit into from
Jul 18, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 16 additions & 8 deletions lib/ansible/modules/cloud/ovirt/ovirt_host_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@
get_link_name,
ovirt_full_argument_spec,
search_by_name,
engine_supported
)


Expand Down Expand Up @@ -323,10 +324,9 @@ def has_update(self, nic_service):
return update

def _action_save_configuration(self, entity):
if self._module.params['save']:
if not self._module.check_mode:
self._service.service(entity.id).commit_net_config()
self.changed = True
if not self._module.check_mode:
self._service.service(entity.id).commit_net_config()
self.changed = True


def needs_sync(nics_service):
Expand Down Expand Up @@ -414,10 +414,9 @@ def main():
removed_bonds.append(otypes.HostNic(id=host_nic.id))

# Assign the networks:
host_networks_module.action(
setup_params = dict(
entity=host,
action='setup_networks',
post_action=host_networks_module._action_save_configuration,
check_connectivity=module.params['check'],
removed_bonds=removed_bonds if removed_bonds else None,
modified_bonds=[
Expand Down Expand Up @@ -466,6 +465,11 @@ def main():
) for network in networks
] if networks else None,
)
if engine_supported(connection, '4.3'):
setup_params['commit_on_success'] = module.params['save']
elif module.params['save']:
setup_params['post_action'] = host_networks_module._action_save_configuration
host_networks_module.action(**setup_params)
elif state == 'absent' and nic:
attachments = []
nic_service = nics_service.nic_service(nic.id)
Expand All @@ -491,10 +495,9 @@ def main():
# 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(
setup_params = dict(
entity=host,
action='setup_networks',
post_action=host_networks_module._action_save_configuration,
check_connectivity=module.params['check'],
removed_bonds=[
otypes.HostNic(
Expand All @@ -506,6 +509,11 @@ def main():
] if labels else None,
removed_network_attachments=attachments if attachments else None,
)
if engine_supported(connection, '4.3'):
setup_params['commit_on_success'] = module.params['save']
elif module.params['save']:
setup_params['post_action'] = host_networks_module._action_save_configuration
host_networks_module.action(**setup_params)

nic = search_by_name(nics_service, nic_name)
module.exit_json(**{
Expand Down