diff options
| author | Soren Hansen <soren.hansen@rackspace.com> | 2010-09-08 17:18:35 +0000 |
|---|---|---|
| committer | Tarmac <> | 2010-09-08 17:18:35 +0000 |
| commit | 30cec546812799fba09a2bab2b3aa4aad712ae3c (patch) | |
| tree | 77603477c8b7b3f3241672fd1c466840cb6f32ed | |
| parent | f62e2a6aafc1a3895238adce003926cca4bd3cd8 (diff) | |
| parent | f2a3f9a622613ec1575e70ac9fe9655b485d9a6d (diff) | |
| download | nova-30cec546812799fba09a2bab2b3aa4aad712ae3c.tar.gz nova-30cec546812799fba09a2bab2b3aa4aad712ae3c.tar.xz nova-30cec546812799fba09a2bab2b3aa4aad712ae3c.zip | |
It's annoying and confusing to have to set PYTHONPATH to point to your
development tree before you run any of the scripts.
If you're lucky, it just fails (because you don't have nova in the default
search path (i.e. don't have them installed in /usr/lib/blah)) so that you can
fix it up.
If you're less lucky, you spend at least a couple of minutes wondering
why the cool changes you made to one of the nova modules don't take effect
until you realise it's because it's using the nova stuff in /usr/lib.
So, to save myself (and probably others) a bit of time, this patch adds
a snippet to each of the scripts in bin/ to detect this and set up the PYTHONPATH.
| -rwxr-xr-x | bin/nova-api | 10 | ||||
| -rwxr-xr-x | bin/nova-api-new | 11 | ||||
| -rwxr-xr-x | bin/nova-compute | 11 | ||||
| -rwxr-xr-x | bin/nova-dhcpbridge | 11 | ||||
| -rwxr-xr-x | bin/nova-import-canonical-imagestore | 8 | ||||
| -rwxr-xr-x | bin/nova-instancemonitor | 10 | ||||
| -rwxr-xr-x | bin/nova-manage | 9 | ||||
| -rwxr-xr-x | bin/nova-network | 11 | ||||
| -rwxr-xr-x | bin/nova-objectstore | 11 | ||||
| -rwxr-xr-x | bin/nova-volume | 11 |
10 files changed, 99 insertions, 4 deletions
diff --git a/bin/nova-api b/bin/nova-api index a3ad5a0e1..ede09d38c 100755 --- a/bin/nova-api +++ b/bin/nova-api @@ -22,9 +22,19 @@ Tornado daemon for the main API endpoint. """ import logging +import os +import sys from tornado import httpserver from tornado import ioloop +# If ../nova/__init__.py exists, add ../ to Python search path, so that +# it will override what happens to be installed in /usr/(local/)lib/python... +possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), + os.pardir, + os.pardir)) +if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): + sys.path.insert(0, possible_topdir) + from nova import flags from nova import server from nova import utils diff --git a/bin/nova-api-new b/bin/nova-api-new index fda42339c..8625c487f 100755 --- a/bin/nova-api-new +++ b/bin/nova-api-new @@ -21,6 +21,17 @@ Nova API daemon. """ +import os +import sys + +# If ../nova/__init__.py exists, add ../ to Python search path, so that +# it will override what happens to be installed in /usr/(local/)lib/python... +possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), + os.pardir, + os.pardir)) +if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): + sys.path.insert(0, possible_topdir) + from nova import api from nova import flags from nova import utils diff --git a/bin/nova-compute b/bin/nova-compute index ed9a55565..631d2c85c 100755 --- a/bin/nova-compute +++ b/bin/nova-compute @@ -21,6 +21,17 @@ Twistd daemon for the nova compute nodes. """ +import os +import sys + +# If ../nova/__init__.py exists, add ../ to Python search path, so that +# it will override what happens to be installed in /usr/(local/)lib/python... +possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), + os.pardir, + os.pardir)) +if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): + sys.path.insert(0, possible_topdir) + from nova import twistd from nova.compute import service diff --git a/bin/nova-dhcpbridge b/bin/nova-dhcpbridge index 1f2ed4f89..0c3d987a7 100755 --- a/bin/nova-dhcpbridge +++ b/bin/nova-dhcpbridge @@ -25,10 +25,13 @@ import logging import os import sys -#TODO(joshua): there is concern that the user dnsmasq runs under will not -# have nova in the path. This should be verified and if it is -# not true the ugly line below can be removed -sys.path.append(os.path.abspath(os.path.join(__file__, "../../"))) +# If ../nova/__init__.py exists, add ../ to Python search path, so that +# it will override what happens to be installed in /usr/(local/)lib/python... +possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), + os.pardir, + os.pardir)) +if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): + sys.path.insert(0, possible_topdir) from nova import flags from nova import rpc diff --git a/bin/nova-import-canonical-imagestore b/bin/nova-import-canonical-imagestore index 2bc61cf0c..4ed9e8365 100755 --- a/bin/nova-import-canonical-imagestore +++ b/bin/nova-import-canonical-imagestore @@ -29,6 +29,14 @@ import subprocess import sys import urllib2 +# If ../nova/__init__.py exists, add ../ to Python search path, so that +# it will override what happens to be installed in /usr/(local/)lib/python... +possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), + os.pardir, + os.pardir)) +if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): + sys.path.insert(0, possible_topdir) + from nova import flags from nova import utils from nova.objectstore import image diff --git a/bin/nova-instancemonitor b/bin/nova-instancemonitor index fbac58889..094da4033 100755 --- a/bin/nova-instancemonitor +++ b/bin/nova-instancemonitor @@ -21,9 +21,19 @@ Daemon for Nova RRD based instance resource monitoring. """ +import os import logging +import sys from twisted.application import service +# If ../nova/__init__.py exists, add ../ to Python search path, so that +# it will override what happens to be installed in /usr/(local/)lib/python... +possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), + os.pardir, + os.pardir)) +if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): + sys.path.insert(0, possible_topdir) + from nova import twistd from nova.compute import monitor diff --git a/bin/nova-manage b/bin/nova-manage index 145294d3d..d2fd49d8d 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -22,9 +22,18 @@ Connects to the running ADMIN api in the api daemon. """ +import os import sys import time +# If ../nova/__init__.py exists, add ../ to Python search path, so that +# it will override what happens to be installed in /usr/(local/)lib/python... +possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), + os.pardir, + os.pardir)) +if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): + sys.path.insert(0, possible_topdir) + from nova import flags from nova import utils from nova.auth import manager diff --git a/bin/nova-network b/bin/nova-network index 5753aafbe..307795d7b 100755 --- a/bin/nova-network +++ b/bin/nova-network @@ -21,6 +21,17 @@ Twistd daemon for the nova network nodes. """ +import os +import sys + +# If ../nova/__init__.py exists, add ../ to Python search path, so that +# it will override what happens to be installed in /usr/(local/)lib/python... +possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), + os.pardir, + os.pardir)) +if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): + sys.path.insert(0, possible_topdir) + from nova import flags from nova import twistd diff --git a/bin/nova-objectstore b/bin/nova-objectstore index afcf13e24..447ef9055 100755 --- a/bin/nova-objectstore +++ b/bin/nova-objectstore @@ -21,6 +21,17 @@ Twisted daemon for nova objectstore. Supports S3 API. """ +import os +import sys + +# If ../nova/__init__.py exists, add ../ to Python search path, so that +# it will override what happens to be installed in /usr/(local/)lib/python... +possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), + os.pardir, + os.pardir)) +if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): + sys.path.insert(0, possible_topdir) + from nova import flags from nova import utils from nova import twistd diff --git a/bin/nova-volume b/bin/nova-volume index 8ef006ebc..f8e2e1744 100755 --- a/bin/nova-volume +++ b/bin/nova-volume @@ -21,6 +21,17 @@ Twistd daemon for the nova volume nodes. """ +import os +import sys + +# If ../nova/__init__.py exists, add ../ to Python search path, so that +# it will override what happens to be installed in /usr/(local/)lib/python... +possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), + os.pardir, + os.pardir)) +if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): + sys.path.insert(0, possible_topdir) + from nova import twistd from nova.volume import service |
