Marcin Mirecki has uploaded a new change for review. Change subject: network: add ifcfg write hook ......................................................................
network: add ifcfg write hook Added a new hook point which is executed before and after an ifcfg file is writen on the host as a result of executing setupNetworks. The hook script receives a json file containing the following dict: name: the name of the interface being configured ifcfg_file: full path of the interface file being written config: the contents of the config file being written Change-Id: I2206ccf97b210bd58f03777d4ccd016785b02939 Signed-off-by: Marcin Mirecki <[email protected]> --- M vdsm.spec.in M vdsm/hooks.py M vdsm/network/configurators/ifcfg.py M vdsm_hooks/Makefile.am 4 files changed, 29 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/52/44552/1 diff --git a/vdsm.spec.in b/vdsm.spec.in index 0a44346..2037a89 100644 --- a/vdsm.spec.in +++ b/vdsm.spec.in @@ -986,6 +986,9 @@ %dir %{_libexecdir}/%{vdsm_name}/hooks/before_get_stats %dir %{_libexecdir}/%{vdsm_name}/hooks/after_get_stats %dir %{_libexecdir}/%{vdsm_name}/hooks/after_hostdev_list_by_caps +%dir %{_libexecdir}/%{vdsm_name}/hooks/before_ifcfg_write +%dir %{_libexecdir}/%{vdsm_name}/hooks/after_ifcfg_write + %{_datadir}/%{vdsm_name}/dumpStorageTable.py* %{_datadir}/%{vdsm_name}/get-conf-item %{_datadir}/%{vdsm_name}/kaxmlrpclib.py* diff --git a/vdsm/hooks.py b/vdsm/hooks.py index 5a4d25e..29d0271 100644 --- a/vdsm/hooks.py +++ b/vdsm/hooks.py @@ -391,6 +391,16 @@ hookType=_JSON_HOOK) +def before_ifcfg_write(hook_dict): + return _runHooksDir(hook_dict, 'before_ifcfg_write', raiseError=False, + hookType=_JSON_HOOK) + + +def after_ifcfg_write(hook_dict): + return _runHooksDir(hook_dict, 'after_ifcfg_write', raiseError=False, + hookType=_JSON_HOOK) + + def after_hostdev_list_by_caps(devices): return _runHooksDir(devices, 'after_hostdev_list_by_caps', raiseError=False, hookType=_JSON_HOOK) diff --git a/vdsm/network/configurators/ifcfg.py b/vdsm/network/configurators/ifcfg.py index e1cb96d..cb1acdf 100644 --- a/vdsm/network/configurators/ifcfg.py +++ b/vdsm/network/configurators/ifcfg.py @@ -21,6 +21,7 @@ import copy import errno import glob +import hooks import logging import os import pipes @@ -542,7 +543,13 @@ cfg += '%s=%s\n' % (k.upper(), pipes.quote(kwargs[k])) else: logging.debug('ignoring variable %s', k) + + hook_dict = _build_ifcfg_write_hook_dict(name, + netinfo.NET_CONF_PREF + name, + cfg) + hooks.before_ifcfg_write(hook_dict) self.writeConfFile(netinfo.NET_CONF_PREF + name, cfg) + hooks.after_ifcfg_write(hook_dict) def addBridge(self, bridge, **opts): """ Create ifcfg-* file with proper fields for bridge """ @@ -903,3 +910,10 @@ ifcfgs.add(ROUTE_PATH % top_level_device) return ifcfgs + + +def _build_ifcfg_write_hook_dict(name, ifcfg_file, conf): + hook_dict = {'name': name, + 'ifcfg_file': ifcfg_file, + 'config': conf} + return hook_dict diff --git a/vdsm_hooks/Makefile.am b/vdsm_hooks/Makefile.am index 7dc9ff2..900933d 100644 --- a/vdsm_hooks/Makefile.am +++ b/vdsm_hooks/Makefile.am @@ -130,6 +130,8 @@ after_hostdev_list_by_caps \ before_memory_hotplug \ after_memory_hotplug \ + before_ifcfg_write \ + after_ifcfg_write \ $(NULL) all-local: \ -- To view, visit https://gerrit.ovirt.org/44552 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I2206ccf97b210bd58f03777d4ccd016785b02939 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Marcin Mirecki <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
