summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorDan Prince <dan.prince@rackspace.com>2011-05-26 09:05:14 -0400
committerDan Prince <dan.prince@rackspace.com>2011-05-26 09:05:14 -0400
commita021b43b7d45f8cc803721002a0b2e7d9ea9a06d (patch)
tree6c3f6274d91a511a04a322a46d8678f4ad18d71a /tools
parent9d2513ea3a6d586e1fe3deae778a02bb089b9a5e (diff)
parentdb18a792414240cbdb1221d0e79e8a63313f103e (diff)
downloadnova-a021b43b7d45f8cc803721002a0b2e7d9ea9a06d.tar.gz
nova-a021b43b7d45f8cc803721002a0b2e7d9ea9a06d.tar.xz
nova-a021b43b7d45f8cc803721002a0b2e7d9ea9a06d.zip
Merge w/ trunk.
Diffstat (limited to 'tools')
-rw-r--r--tools/esx/guest_tool.py2
-rw-r--r--tools/install_venv.py172
-rw-r--r--tools/pip-requires6
3 files changed, 97 insertions, 83 deletions
diff --git a/tools/esx/guest_tool.py b/tools/esx/guest_tool.py
index bbf3ea908..13b0f8d33 100644
--- a/tools/esx/guest_tool.py
+++ b/tools/esx/guest_tool.py
@@ -209,7 +209,7 @@ def _execute(cmd_list, process_input=None, check_exit_code=True):
obj = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env)
result = None
- if process_input != None:
+ if process_input is not None:
result = obj.communicate(process_input)
else:
result = obj.communicate()
diff --git a/tools/install_venv.py b/tools/install_venv.py
index 30ec85374..812b1dd0f 100644
--- a/tools/install_venv.py
+++ b/tools/install_venv.py
@@ -1,3 +1,4 @@
+
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2010 United States Government as represented by the
@@ -30,114 +31,125 @@ import sys
ROOT = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
VENV = os.path.join(ROOT, '.nova-venv')
PIP_REQUIRES = os.path.join(ROOT, 'tools', 'pip-requires')
-TWISTED_NOVA='http://nova.openstack.org/Twisted-10.0.0Nova.tar.gz'
+TWISTED_NOVA = 'http://nova.openstack.org/Twisted-10.0.0Nova.tar.gz'
+PY_VERSION = "python%s.%s" % (sys.version_info[0], sys.version_info[1])
+
def die(message, *args):
- print >>sys.stderr, message % args
- sys.exit(1)
+ print >>sys.stderr, message % args
+ sys.exit(1)
+
+
+def check_python_version():
+ if sys.version_info < (2, 6):
+ die("Need Python Version >= 2.6")
def run_command(cmd, redirect_output=True, check_exit_code=True):
- """
- Runs a command in an out-of-process shell, returning the
- output of that command. Working directory is ROOT.
- """
- if redirect_output:
- stdout = subprocess.PIPE
- else:
- stdout = None
+ """
+ Runs a command in an out-of-process shell, returning the
+ output of that command. Working directory is ROOT.
+ """
+ if redirect_output:
+ stdout = subprocess.PIPE
+ else:
+ stdout = None
- proc = subprocess.Popen(cmd, cwd=ROOT, stdout=stdout)
- output = proc.communicate()[0]
- if check_exit_code and proc.returncode != 0:
- die('Command "%s" failed.\n%s', ' '.join(cmd), output)
- return output
+ proc = subprocess.Popen(cmd, cwd=ROOT, stdout=stdout)
+ output = proc.communicate()[0]
+ if check_exit_code and proc.returncode != 0:
+ die('Command "%s" failed.\n%s', ' '.join(cmd), output)
+ return output
-HAS_EASY_INSTALL = bool(run_command(['which', 'easy_install'], check_exit_code=False).strip())
-HAS_VIRTUALENV = bool(run_command(['which', 'virtualenv'], check_exit_code=False).strip())
+HAS_EASY_INSTALL = bool(run_command(['which', 'easy_install'],
+ check_exit_code=False).strip())
+HAS_VIRTUALENV = bool(run_command(['which', 'virtualenv'],
+ check_exit_code=False).strip())
def check_dependencies():
- """Make sure virtualenv is in the path."""
-
- if not HAS_VIRTUALENV:
- print 'not found.'
- # Try installing it via easy_install...
- if HAS_EASY_INSTALL:
- print 'Installing virtualenv via easy_install...',
- if not (run_command(['which', 'easy_install']) and
- run_command(['easy_install', 'virtualenv'])):
- die('ERROR: virtualenv not found.\n\nNova development requires virtualenv,'
- ' please install it using your favorite package management tool')
- print 'done.'
- print 'done.'
+ """Make sure virtualenv is in the path."""
+
+ if not HAS_VIRTUALENV:
+ print 'not found.'
+ # Try installing it via easy_install...
+ if HAS_EASY_INSTALL:
+ print 'Installing virtualenv via easy_install...',
+ if not (run_command(['which', 'easy_install']) and
+ run_command(['easy_install', 'virtualenv'])):
+ die('ERROR: virtualenv not found.\n\nNova development'
+ ' requires virtualenv, please install it using your'
+ ' favorite package management tool')
+ print 'done.'
+ print 'done.'
def create_virtualenv(venv=VENV):
- """Creates the virtual environment and installs PIP only into the
- virtual environment
- """
- print 'Creating venv...',
- run_command(['virtualenv', '-q', '--no-site-packages', VENV])
- print 'done.'
- print 'Installing pip in virtualenv...',
- if not run_command(['tools/with_venv.sh', 'easy_install', 'pip']).strip():
- die("Failed to install pip.")
- print 'done.'
+ """Creates the virtual environment and installs PIP only into the
+ virtual environment
+ """
+ print 'Creating venv...',
+ run_command(['virtualenv', '-q', '--no-site-packages', VENV])
+ print 'done.'
+ print 'Installing pip in virtualenv...',
+ if not run_command(['tools/with_venv.sh', 'easy_install', 'pip']).strip():
+ die("Failed to install pip.")
+ print 'done.'
def install_dependencies(venv=VENV):
- print 'Installing dependencies with pip (this can take a while)...'
- # Install greenlet by hand - just listing it in the requires file does not
- # get it in stalled in the right order
- run_command(['tools/with_venv.sh', 'pip', 'install', '-E', venv, 'greenlet'],
- redirect_output=False)
- run_command(['tools/with_venv.sh', 'pip', 'install', '-E', venv, '-r', PIP_REQUIRES],
- redirect_output=False)
- run_command(['tools/with_venv.sh', 'pip', 'install', '-E', venv, TWISTED_NOVA],
- redirect_output=False)
-
-
- # Tell the virtual env how to "import nova"
- pthfile = os.path.join(venv, "lib", "python2.6", "site-packages", "nova.pth")
- f = open(pthfile, 'w')
- f.write("%s\n" % ROOT)
- # Patch eventlet (see FAQ # 1485)
- patchsrc = os.path.join(ROOT, 'tools', 'eventlet-patch')
- patchfile = os.path.join(venv, "lib", "python2.6", "site-packages", "eventlet",
- "green", "subprocess.py")
- patch_cmd = "patch %s %s" % (patchfile, patchsrc)
- os.system(patch_cmd)
+ print 'Installing dependencies with pip (this can take a while)...'
+ # Install greenlet by hand - just listing it in the requires file does not
+ # get it in stalled in the right order
+ run_command(['tools/with_venv.sh', 'pip', 'install', '-E', venv,
+ 'greenlet'], redirect_output=False)
+ run_command(['tools/with_venv.sh', 'pip', 'install', '-E', venv, '-r',
+ PIP_REQUIRES], redirect_output=False)
+ run_command(['tools/with_venv.sh', 'pip', 'install', '-E', venv,
+ TWISTED_NOVA], redirect_output=False)
+
+ # Tell the virtual env how to "import nova"
+ pthfile = os.path.join(venv, "lib", PY_VERSION, "site-packages",
+ "nova.pth")
+ f = open(pthfile, 'w')
+ f.write("%s\n" % ROOT)
+ # Patch eventlet (see FAQ # 1485)
+ patchsrc = os.path.join(ROOT, 'tools', 'eventlet-patch')
+ patchfile = os.path.join(venv, "lib", PY_VERSION, "site-packages",
+ "eventlet", "green", "subprocess.py")
+ patch_cmd = "patch %s %s" % (patchfile, patchsrc)
+ os.system(patch_cmd)
def print_help():
- help = """
- Nova development environment setup is complete.
+ help = """
+ Nova development environment setup is complete.
- Nova development uses virtualenv to track and manage Python dependencies
- while in development and testing.
+ Nova development uses virtualenv to track and manage Python dependencies
+ while in development and testing.
- To activate the Nova virtualenv for the extent of your current shell session
- you can run:
+ To activate the Nova virtualenv for the extent of your current shell
+ session you can run:
- $ source .nova-venv/bin/activate
+ $ source .nova-venv/bin/activate
- Or, if you prefer, you can run commands in the virtualenv on a case by case
- basis by running:
+ Or, if you prefer, you can run commands in the virtualenv on a case by case
+ basis by running:
- $ tools/with_venv.sh <your command>
+ $ tools/with_venv.sh <your command>
- Also, make test will automatically use the virtualenv.
- """
- print help
+ Also, make test will automatically use the virtualenv.
+ """
+ print help
def main(argv):
- check_dependencies()
- create_virtualenv()
- install_dependencies()
- print_help()
+ check_python_version()
+ check_dependencies()
+ create_virtualenv()
+ install_dependencies()
+ print_help()
if __name__ == '__main__':
- main(sys.argv)
+ main(sys.argv)
diff --git a/tools/pip-requires b/tools/pip-requires
index 6ea446493..8f8018765 100644
--- a/tools/pip-requires
+++ b/tools/pip-requires
@@ -2,7 +2,7 @@ SQLAlchemy==0.6.3
pep8==0.5.0
pylint==0.19
IPy==0.70
-Cheetah==2.4.2.1
+Cheetah==2.4.4
M2Crypto==0.20.2
amqplib==0.6.1
anyjson==0.2.4
@@ -17,7 +17,6 @@ redis==2.0.0
routes==1.12.3
WebOb==0.9.8
wsgiref==0.1.2
-zope.interface==3.6.1
mox==0.5.0
-f http://pymox.googlecode.com/files/mox-0.5.0.tar.gz
greenlet==0.3.1
@@ -32,3 +31,6 @@ sphinx
glance
nova-adminclient
suds==0.4
+coverage
+nosexcover
+GitPython