Vinzenz Feenstra has uploaded a new change for review.

Change subject: Make GuestAgentLinux2 patchable for unit tests
......................................................................

Make GuestAgentLinux2 patchable for unit tests

Change-Id: I6f0a927976272687b47f1e78e3a34eb6f23b64c9
Signed-off-by: Vinzenz Feenstra <[email protected]>
---
M ovirt-guest-agent/GuestAgentLinux2.py
M tests/guest_agent_test.py
2 files changed, 21 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-guest-agent 
refs/changes/37/28937/1

diff --git a/ovirt-guest-agent/GuestAgentLinux2.py 
b/ovirt-guest-agent/GuestAgentLinux2.py
index 7734bdc..2f37137 100644
--- a/ovirt-guest-agent/GuestAgentLinux2.py
+++ b/ovirt-guest-agent/GuestAgentLinux2.py
@@ -37,6 +37,13 @@
     CredServer = CredServerFake
 
 
+_GUEST_SCRIPTS_INSTALL_PATH = '/usr/share/ovirt-guest-agent'
+
+
+def _get_script_path(name):
+    return os.path.join(_GUEST_SCRIPTS_INSTALL_PATH, name)
+
+
 class PkgMgr(object):
 
     def rpm_list_packages(self, app_list):
@@ -153,7 +160,7 @@
         self.agent = agent
 
     def lock_screen(self):
-        cmd = ['/usr/share/ovirt-guest-agent/ovirt-locksession']
+        cmd = [_get_script_path('ovirt-locksession')]
         logging.debug("Executing lock session command: '%s'", cmd)
         subprocess.call(cmd)
 
@@ -172,14 +179,14 @@
         if reboot:
             param = '-r'
             action = 'reboot'
-        cmd = ['/usr/share/ovirt-guest-agent/ovirt-shutdown', param,
+        cmd = [_get_script_path('ovirt-shutdown'), param,
                "+%d" % (delay), "\"%s\"" % (msg)]
 
         logging.debug("Executing %s command: %s", action, cmd)
         subprocess.call(cmd)
 
     def hibernate(self, state):
-        cmd = ['/usr/share/ovirt-guest-agent/ovirt-hibernate', state]
+        cmd = [_get_script_path('ovirt-hibernate'), state]
         logging.debug("Executing hibernate command: %s", cmd)
         subprocess.call(cmd)
 
diff --git a/tests/guest_agent_test.py b/tests/guest_agent_test.py
index 1962e19..757ec69 100644
--- a/tests/guest_agent_test.py
+++ b/tests/guest_agent_test.py
@@ -4,12 +4,20 @@
 
 
 from ConfigParser import ConfigParser
+import inspect
+import os.path
 import platform
 
 from message_validator import MessageValidator
 from testrunner import GuestAgentTestCase
 
 import test_port
+
+
+def _get_scripts_path():
+    scriptpath = inspect.getfile(inspect.currentframe())
+    scriptdir = os.path.dirname(os.path.abspath(scriptpath))
+    return os.path.abspath(os.path.join(scriptdir, '../scripts'))
 
 
 def _linux_setup_test(conf):
@@ -22,8 +30,9 @@
              'nfds proc sysfs devtmpfs hugetlbfs rpc_pipefs devpts '
              'securityfs debugfs binfmt_misc fuse.gvfsd-fuse '
              'fuse.gvfs-fuse-daemon fusectl usbfs')
-    from GuestAgentLinux2 import LinuxVdsAgent
-    return port_name, LinuxVdsAgent
+    import GuestAgentLinux2
+    GuestAgentLinux2._GUEST_SCRIPTS_INSTALL_PATH = _get_scripts_path()
+    return port_name, GuestAgentLinux2.LinuxVdsAgent
 
 
 def _win32_setup_test(conf):


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6f0a927976272687b47f1e78e3a34eb6f23b64c9
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-guest-agent
Gerrit-Branch: master
Gerrit-Owner: Vinzenz Feenstra <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to