Dan Kenigsberg has uploaded a new change for review.

Change subject: hooks: introduce after_get_caps hook
......................................................................

hooks: introduce after_get_caps hook

This patches adds a hook point that allows to modify the capabilities
which Vdsm reports on its getVdsCapabilities API. This hook can become
useful if a hook writer would like to fake the existence of networks or
cpu flags.

Change-Id: I1d76730e84df491225023b27d3b12b879d310cdf
Signed-off-by: Dan Kenigsberg <dan...@redhat.com>
---
M debian/vdsm.dirs
M vdsm.spec.in
M vdsm/API.py
M vdsm/hooks.py
M vdsm/vdsmd.8.in
5 files changed, 14 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/79/27679/1

diff --git a/debian/vdsm.dirs b/debian/vdsm.dirs
index 5602e16..d8503de 100644
--- a/debian/vdsm.dirs
+++ b/debian/vdsm.dirs
@@ -16,6 +16,7 @@
 usr/libexec/vdsm/hooks/after_disk_hotplug
 usr/libexec/vdsm/hooks/after_disk_hotunplug
 usr/libexec/vdsm/hooks/after_get_all_vm_stats
+usr/libexec/vdsm/hooks/after_get_caps
 usr/libexec/vdsm/hooks/after_get_vm_stats
 usr/libexec/vdsm/hooks/after_network_setup
 usr/libexec/vdsm/hooks/after_nic_hotplug
diff --git a/vdsm.spec.in b/vdsm.spec.in
index ecc2c6b..085126a 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -1091,6 +1091,7 @@
 %dir %{_libexecdir}/%{vdsm_name}/hooks/after_get_vm_stats
 %dir %{_libexecdir}/%{vdsm_name}/hooks/before_get_all_vm_stats
 %dir %{_libexecdir}/%{vdsm_name}/hooks/after_get_all_vm_stats
+%dir %{_libexecdir}/%{vdsm_name}/hooks/after_get_caps
 %{_datadir}/%{vdsm_name}/addNetwork
 %{_datadir}/%{vdsm_name}/delNetwork
 %{_datadir}/%{vdsm_name}/dumpStorageTable.py*
diff --git a/vdsm/API.py b/vdsm/API.py
index 98988b3..e55343e 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -1189,6 +1189,7 @@
         _updateTimestamp()  # required for some ovirt-3.0.z Engines
         c = caps.get()
         c['netConfigDirty'] = str(self._cif._netConfigDirty)
+        c = hooks.after_get_caps(c)
 
         return {'status': doneCode, 'info': c}
 
diff --git a/vdsm/hooks.py b/vdsm/hooks.py
index 2128585..3bc8304 100644
--- a/vdsm/hooks.py
+++ b/vdsm/hooks.py
@@ -359,6 +359,11 @@
                         hookType=_JSON_HOOK)
 
 
+def after_get_caps(caps):
+    return _runHooksDir(caps, 'after_get_caps', raiseError=False,
+                        hookType=_JSON_HOOK)
+
+
 def _getScriptInfo(path):
     try:
         with file(path) as f:
diff --git a/vdsm/vdsmd.8.in b/vdsm/vdsmd.8.in
index 126e0cc..6e3f59d 100644
--- a/vdsm/vdsmd.8.in
+++ b/vdsm/vdsmd.8.in
@@ -60,7 +60,8 @@
     before_network_setup, after_network_setup,
     before_set_num_of_cpus, after_set_num_of_cpus,
     before_get_vm_stats, after_get_vm_stats,
-    before_get_all_vm_stats, after_get_all_vm_stats.
+    before_get_all_vm_stats, after_get_all_vm_stats,
+    after_get_caps.
 
 Each hook executes the scripts under
 .FN /usr/libexec/vdsm/hooks/<hook-name>/
@@ -69,7 +70,8 @@
 .SS Hook environment
 Each hook script (except before_vdsm_start, after_vdsm_stop, 
 before_network_setup and after_network_setup, before_get_vm_stats,
-after_get_vm_stats, before_get_all_vm_stats, after_get_all_vm_stats)) inherit
+after_get_vm_stats, before_get_all_vm_stats, after_get_all_vm_stats
+and after_get_caps) inherit
 the environment of the VDSM process, with an additional variable
 .B _hook_domxml
 which holds the path of libvirt's
@@ -156,6 +158,8 @@
 ]
 .fi
 
+after_get_caps is called after the getVdsCapabilities API request, and receive 
the complete capabilities dictionary within _hook_json.
+
 .SS Hook execution
 before_vdsm_start and after_vdsm_stop scripts are executed as user
 .I root.


-- 
To view, visit http://gerrit.ovirt.org/27679
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1d76730e84df491225023b27d3b12b879d310cdf
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dan Kenigsberg <dan...@redhat.com>
_______________________________________________
vdsm-patches mailing list
vdsm-patches@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to