Giuseppe Vallarelli has uploaded a new change for review. Change subject: Update device hooks: ......................................................................
Update device hooks: Added before and after update device hooks. Bug-Url:https://bugzilla.redhat.com/show_bug.cgi?id=893576 Change-Id: I8fe7f5e6d8291cc227a323b324c977bcd5bc8295 Signed-off-by: Giuseppe Vallarelli <[email protected]> --- M vdsm/hooks.py M vdsm/libvirtvm.py M vdsm/vdsmd.8.in M vdsm_hooks/Makefile.am 4 files changed, 46 insertions(+), 2 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/72/13972/1 diff --git a/vdsm/hooks.py b/vdsm/hooks.py index c66bfef..4a5d053 100644 --- a/vdsm/hooks.py +++ b/vdsm/hooks.py @@ -194,6 +194,16 @@ raiseError=False, params=params) +def before_update_device(devxml, vmconf={}, params={}): + return _runHooksDir(devxml, 'before_update_device', vmconf=vmconf, + params=params) + + +def after_update_device(devxml, vmconf={}, params={}): + return _runHooksDir(devxml, 'after_update_device', vmconf=vmconf, + raiseError=False, params=params) + + def before_nic_hotplug(nicxml, vmconf={}, params={}): return _runHooksDir(nicxml, 'before_nic_hotplug', vmconf=vmconf, params=params) diff --git a/vdsm/libvirtvm.py b/vdsm/libvirtvm.py index 18ca5aa..02109ba 100644 --- a/vdsm/libvirtvm.py +++ b/vdsm/libvirtvm.py @@ -1712,11 +1712,42 @@ # Update the conf with the new mirroring. conf['portMirroring'] = networks + def _get_device(self, key): + """ + Retrieve nic device associated to its key (alias). + """ + + device = None + for nic_dev in self._devices[vm.NIC_DEVICES]: + if nic_dev.alias == key: + device = nic_dev + break + return device + def updateDevice(self, params): + update = None if params.get('deviceType') == vm.NIC_DEVICES: - return self._updateInterfaceDevice(params) + nic_to_update = self._get_device(params['alias']) + nic_xml = nic_to_update.getXML().toprettyxml(encoding='utf-8') + + self.log.debug('Nic to update: %s' % nic_xml) + nic_xml = hooks.before_update_device(nic_xml, self.conf) + + try: + self._dom.updateDeviceFlags( + nic_xml, libvirt.VIR_DOMAIN_AFFECT_LIVE) + except Exception: + self.log.debug('Request failed: %s', nic_xml, exc_info=True) + update = self._updateInterfaceDevice(params) + + nic_xml = nic_to_update.getXML().toprettyxml(encoding='utf-8') + self.log.debug("Nic has been updated: %s" % nic_xml) + + hooks.after_update_device(nic_xml, self.conf) else: - return errCode['noimpl'] + update = errCode['noimpl'] + + return update def hotunplugNic(self, params): if self.isMigrating(): diff --git a/vdsm/vdsmd.8.in b/vdsm/vdsmd.8.in index 7cd6c73..3796bb0 100644 --- a/vdsm/vdsmd.8.in +++ b/vdsm/vdsmd.8.in @@ -47,6 +47,7 @@ before_vm_migrate_destination, after_vm_migrate_destination, before_vm_destroy, after_vm_destroy, before_vm_set_ticket, after_vm_set_ticket, + before_update_device, after_update_device, before_device_create, after_device_create, before_device_destroy, after_device_destroy, before_nic_hotplug, after_nic_hotplug, after_nic_hotplug_fail, diff --git a/vdsm_hooks/Makefile.am b/vdsm_hooks/Makefile.am index 12bea50..cd2e77f 100644 --- a/vdsm_hooks/Makefile.am +++ b/vdsm_hooks/Makefile.am @@ -81,6 +81,8 @@ after_vm_destroy \ before_vm_set_ticket \ after_vm_set_ticket \ + before_update_device \ + after_update_device \ before_nic_hotplug \ after_nic_hotplug \ before_nic_hotunplug \ -- To view, visit http://gerrit.ovirt.org/13972 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8fe7f5e6d8291cc227a323b324c977bcd5bc8295 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Giuseppe Vallarelli <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
