File 0001-Robustify-determination-of-root-directory.patch of Package openstack-nova

From 9827045f7fe843330e384b76d325c00092cba902 Mon Sep 17 00:00:00 2001
From: Dirk Mueller <dirk@dmllr.de>
Date: Mon, 28 Oct 2013 17:16:03 +0100
Subject: [PATCH] Robustify determination of root directory

When tests are packaged into a different directory tree
than the nova module itself, traversing backwards to
the root directory does not work anymore with realpath/abspath.
Use normpath instead.

Change-Id: Ifbc3947a03029dcd4c02b6498a8d48f7849b8f1a
Fixes-Bug: 1245553
---
 nova/tests/virt/xenapi/test_xenapi.py | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

Index: nova-2014.2.3.dev15/nova/tests/virt/xenapi/test_xenapi.py
===================================================================
--- nova-2014.2.3.dev15.orig/nova/tests/virt/xenapi/test_xenapi.py
+++ nova-2014.2.3.dev15/nova/tests/virt/xenapi/test_xenapi.py
@@ -4040,16 +4040,17 @@ class XenAPISessionTestCase(test.NoDBTes
     def test_verify_current_version_matches(self):
         session = self._get_mock_xapisession({})
 
+        # Determine ROOTDIR relative to tests
+        TESTDIR = os.path.dirname(os.path.abspath(__file__))
+        ROOTDIR = os.path.normpath(os.path.join(
+            TESTDIR, '..', '..', '..', '..'))
         # Import the plugin to extract its version
-        path = os.path.dirname(__file__)
-        rel_path_elem = "../../../../plugins/xenserver/xenapi/etc/xapi.d/" \
-            "plugins/nova_plugin_version"
-        for elem in rel_path_elem.split('/'):
-            path = os.path.join(path, elem)
-        path = os.path.realpath(path)
+        XENPLUGIN = os.path.join(
+            ROOTDIR, *'plugins/xenserver/xenapi/etc/xapi.d/'
+                      'plugins/nova_plugin_version'.split('/'))
 
         plugin_version = None
-        with open(path) as plugin_file:
+        with open(XENPLUGIN) as plugin_file:
             for line in plugin_file:
                 if "PLUGIN_VERSION = " in line:
                     plugin_version = line.strip()[17:].strip('"')
openSUSE Build Service is sponsored by