summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Authors1
-rwxr-xr-xbin/nova-import-canonical-imagestore3
-rwxr-xr-xbin/nova-instancemonitor3
-rwxr-xr-xbin/nova-manage3
-rwxr-xr-xbin/nova-network3
-rwxr-xr-xbin/nova-objectstore3
-rwxr-xr-xbin/nova-scheduler3
-rwxr-xr-xbin/nova-volume3
-rwxr-xr-xcontrib/nova.sh2
-rw-r--r--doc/source/adminguide/managing.networks.rst2
-rw-r--r--doc/source/adminguide/multi.node.install.rst30
-rw-r--r--doc/source/adminguide/single.node.install.rst4
-rw-r--r--doc/source/cloud101.rst9
-rw-r--r--doc/source/images/novascreens.pngbin0 -> 27949 bytes
-rw-r--r--doc/source/images/novashvirtually.pngbin0 -> 39000 bytes
-rw-r--r--doc/source/index.rst4
-rw-r--r--doc/source/livecd.rst46
-rw-r--r--nova/api/ec2/cloud.py6
-rw-r--r--nova/api/openstack/__init__.py9
-rw-r--r--nova/api/openstack/auth.py4
-rw-r--r--nova/api/openstack/images.py9
-rw-r--r--nova/api/openstack/servers.py41
-rw-r--r--nova/compute/instance_types.py1
-rw-r--r--nova/objectstore/image.py9
-rw-r--r--nova/tests/api/openstack/fakes.py13
-rw-r--r--nova/tests/api/openstack/test_auth.py3
-rw-r--r--nova/tests/cloud_unittest.py13
-rw-r--r--nova/tests/misc_unittest.py43
-rw-r--r--smoketests/admin_smoketests.py92
-rw-r--r--smoketests/base.py (renamed from smoketests/novatestcase.py)114
-rw-r--r--smoketests/flags.py13
-rw-r--r--smoketests/smoketest.py566
-rw-r--r--smoketests/user_smoketests.py326
33 files changed, 660 insertions, 721 deletions
diff --git a/Authors b/Authors
index c9bf3b67c..4a526d849 100644
--- a/Authors
+++ b/Authors
@@ -3,6 +3,7 @@ Anne Gentle <anne@openstack.org>
Anthony Young <sleepsonthefloor@gmail.com>
Armando Migliaccio <Armando.Migliaccio@eu.citrix.com>
Chris Behrens <cbehrens@codestud.com>
+Chmouel Boudjnah <chmouel@chmouel.com>
Dean Troyer <dtroyer@gmail.com>
Devin Carlen <devin.carlen@gmail.com>
Eric Day <eday@oddments.org>
diff --git a/bin/nova-import-canonical-imagestore b/bin/nova-import-canonical-imagestore
index 4ed9e8365..036b41e48 100755
--- a/bin/nova-import-canonical-imagestore
+++ b/bin/nova-import-canonical-imagestore
@@ -21,6 +21,7 @@
Download images from Canonical Image Store
"""
+import gettext
import json
import os
import tempfile
@@ -37,6 +38,8 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
sys.path.insert(0, possible_topdir)
+gettext.install('nova', unicode=1)
+
from nova import flags
from nova import utils
from nova.objectstore import image
diff --git a/bin/nova-instancemonitor b/bin/nova-instancemonitor
index 9b6c40e82..5dac3ffe6 100755
--- a/bin/nova-instancemonitor
+++ b/bin/nova-instancemonitor
@@ -21,6 +21,7 @@
Daemon for Nova RRD based instance resource monitoring.
"""
+import gettext
import os
import logging
import sys
@@ -34,6 +35,8 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
sys.path.insert(0, possible_topdir)
+gettext.install('nova', unicode=1)
+
from nova import utils
from nova import twistd
from nova.compute import monitor
diff --git a/bin/nova-manage b/bin/nova-manage
index 62eec8353..0c1b621ed 100755
--- a/bin/nova-manage
+++ b/bin/nova-manage
@@ -53,6 +53,7 @@
CLI interface for nova management.
"""
+import gettext
import logging
import os
import sys
@@ -68,6 +69,8 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
sys.path.insert(0, possible_topdir)
+gettext.install('nova', unicode=1)
+
from nova import context
from nova import db
from nova import exception
diff --git a/bin/nova-network b/bin/nova-network
index d1fb55261..86d04c723 100755
--- a/bin/nova-network
+++ b/bin/nova-network
@@ -21,6 +21,7 @@
Twistd daemon for the nova network nodes.
"""
+import gettext
import os
import sys
@@ -32,6 +33,8 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
sys.path.insert(0, possible_topdir)
+gettext.install('nova', unicode=1)
+
from nova import service
from nova import twistd
from nova import utils
diff --git a/bin/nova-objectstore b/bin/nova-objectstore
index 00ae27af9..9fbe228a2 100755
--- a/bin/nova-objectstore
+++ b/bin/nova-objectstore
@@ -21,6 +21,7 @@
Twisted daemon for nova objectstore. Supports S3 API.
"""
+import gettext
import os
import sys
@@ -32,6 +33,8 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
sys.path.insert(0, possible_topdir)
+gettext.install('nova', unicode=1)
+
from nova import flags
from nova import utils
from nova import twistd
diff --git a/bin/nova-scheduler b/bin/nova-scheduler
index 4d1a40cf1..41e1937c1 100755
--- a/bin/nova-scheduler
+++ b/bin/nova-scheduler
@@ -21,6 +21,7 @@
Twistd daemon for the nova scheduler nodes.
"""
+import gettext
import os
import sys
@@ -32,6 +33,8 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
sys.path.insert(0, possible_topdir)
+gettext.install('nova', unicode=1)
+
from nova import service
from nova import twistd
from nova import utils
diff --git a/bin/nova-volume b/bin/nova-volume
index e7281d6c0..4f2e96268 100755
--- a/bin/nova-volume
+++ b/bin/nova-volume
@@ -21,6 +21,7 @@
Twistd daemon for the nova volume nodes.
"""
+import gettext
import os
import sys
@@ -32,6 +33,8 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
sys.path.insert(0, possible_topdir)
+gettext.install('nova', unicode=1)
+
from nova import service
from nova import twistd
from nova import utils
diff --git a/contrib/nova.sh b/contrib/nova.sh
index 7eb934eca..30df4edb6 100755
--- a/contrib/nova.sh
+++ b/contrib/nova.sh
@@ -72,7 +72,7 @@ fi
# You should only have to run this once
if [ "$CMD" == "install" ]; then
sudo apt-get install -y python-software-properties
- sudo add-apt-repository ppa:nova-core/ppa
+ sudo add-apt-repository ppa:nova-core/trunk
sudo apt-get update
sudo apt-get install -y dnsmasq kpartx kvm gawk iptables ebtables
sudo apt-get install -y user-mode-linux kvm libvirt-bin
diff --git a/doc/source/adminguide/managing.networks.rst b/doc/source/adminguide/managing.networks.rst
index b8563637e..38c1cba78 100644
--- a/doc/source/adminguide/managing.networks.rst
+++ b/doc/source/adminguide/managing.networks.rst
@@ -23,7 +23,7 @@ In Nova, users organize their cloud resources in projects. A Nova project consis
Nova Network Strategies
-----------------------
-Currently, Nova supports three kinds of networks, implemented in three "Network Manager" types respectively: Flat Network Manager, Flat DHCP Network Manager, and VLAN Network Manager. The three kinds of networks can c-exist in a cloud system. However, the scheduler for selecting the type of network for a given project is not yet implemented. Here is a brief description of each of the different network strategies, with a focus on the VLAN Manager in a separate section.
+Currently, Nova supports three kinds of networks, implemented in three "Network Manager" types respectively: Flat Network Manager, Flat DHCP Network Manager, and VLAN Network Manager. The three kinds of networks can co-exist in a cloud system. However, the scheduler for selecting the type of network for a given project is not yet implemented. Here is a brief description of each of the different network strategies, with a focus on the VLAN Manager in a separate section.
Read more about Nova network strategies here:
diff --git a/doc/source/adminguide/multi.node.install.rst b/doc/source/adminguide/multi.node.install.rst
index 1eed30c5b..fcb76c5e5 100644
--- a/doc/source/adminguide/multi.node.install.rst
+++ b/doc/source/adminguide/multi.node.install.rst
@@ -35,7 +35,6 @@ Requirements for a multi-node installation
* For a recommended HA setup, consider a MySQL master/slave replication, with as many slaves as you like, and probably a heartbeat to kick one of the slaves into being a master if it dies.
* For performance optimization, split reads and writes to the database. MySQL proxy is the easiest way to make this work if running MySQL.
-
Assumptions
^^^^^^^^^^^
@@ -69,14 +68,14 @@ Step 1 Use apt-get to get the latest code
It is highly likely that there will be errors when the nova services come up since they are not yet configured. Don't worry, you're only at step 1!
-Step 2 Setup configuration files (installed in /etc/nova)
+Step 2 Setup configuration file (installed in /etc/nova)
---------------------------------------------------------
Note: CC_ADDR=<the external IP address of your cloud controller>
-1. These need to be defined in EACH configuration file
+Nova development has consolidated all .conf files to nova.conf as of November 2010. References to specific .conf files may be ignored.
-::
+#. These need to be defined in the nova.conf configuration file::
--sql_connection=mysql://root:nova@$CC_ADDR/nova # location of nova sql db
--s3_host=$CC_ADDR # This is where nova is hosting the objectstore service, which
@@ -87,31 +86,14 @@ Note: CC_ADDR=<the external IP address of your cloud controller>
--ec2_url=http://$CC_ADDR:8773/services/Cloud
--network_manager=nova.network.manager.FlatManager # simple, no-vlan networking type
-
-2. nova-manage specific flags
-
-::
-
- --fixed_range=<network/prefix> # ip network to use for VM guests, ex 192.168.2.64/26
- --network_size=<# of addrs> # number of ip addrs to use for VM guests, ex 64
-
-
-3. nova-network specific flags
-
-::
-
--fixed_range=<network/prefix> # ip network to use for VM guests, ex 192.168.2.64/26
--network_size=<# of addrs> # number of ip addrs to use for VM guests, ex 64
-4. Create a nova group
-
-::
+#. Create a nova group::
sudo addgroup nova
-5. nova-objectstore specific flags < no specific config needed >
-
-Config files should be have their owner set to root:nova, and mode set to 0640, since they contain your MySQL server's root password.
+The Nova config file should have its owner set to root:nova, and mode set to 0640, since they contain your MySQL server's root password.
::
@@ -121,7 +103,7 @@ Config files should be have their owner set to root:nova, and mode set to 0640,
Step 3 Setup the sql db
-----------------------
-1. First you 'preseed' (using vishy's :doc:`../quickstart`). Run this as root.
+1. First you 'preseed' (using the Quick Start method :doc:`../quickstart`). Run this as root.
::
diff --git a/doc/source/adminguide/single.node.install.rst b/doc/source/adminguide/single.node.install.rst
index f6b2290bc..8572c5a4a 100644
--- a/doc/source/adminguide/single.node.install.rst
+++ b/doc/source/adminguide/single.node.install.rst
@@ -9,7 +9,7 @@ The fastest way to get a test cloud running is through our :doc:`../quickstart`.
Step 1 and 2: Get the latest Nova code system software
------------------------------------------------------
-Depending on your system, the mehod for accomplishing this varies
+Depending on your system, the method for accomplishing this varies
.. toctree::
:maxdepth: 1
@@ -139,7 +139,7 @@ Type or copy/paste the following to source the novarc file in your current worki
Step 9: Pat yourself on the back :)
-----------------------------------
-Congratulations, your cloud is up and running, you’ve created an admin user, retrieved the user's credentials and put them in your environment.
+Congratulations, your cloud is up and running, you’ve created an admin user, created a network, retrieved the user's credentials and put them in your environment.
Now you need an image.
diff --git a/doc/source/cloud101.rst b/doc/source/cloud101.rst
index 87db5af1e..7c79d2a70 100644
--- a/doc/source/cloud101.rst
+++ b/doc/source/cloud101.rst
@@ -54,6 +54,8 @@ Cloud computing offers different service models depending on the capabilities a
The US-based National Institute of Standards and Technology offers definitions for cloud computing
and the service models that are emerging.
+These definitions are summarized from http://csrc.nist.gov/groups/SNS/cloud-computing/.
+
SaaS - Software as a Service
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -72,12 +74,15 @@ IaaS - Infrastructure as a Service
Provides infrastructure such as computer instances, network connections, and storage so that people
can run any software or operating system.
-.. todo:: Use definitions from http://csrc.nist.gov/groups/SNS/cloud-computing/ and attribute NIST
Types of Cloud Deployments
--------------------------
-.. todo:: describe public/private/hybrid/etc
+When you hear terms such as public cloud or private cloud, these refer to the deployment model for the cloud. A private cloud operates for a single organization, but can be managed on-premise or off-premise. A public cloud has an infrastructure that is available to the general public or a large industry group and is likely owned by a cloud services company.
+
+The NIST also defines community cloud as shared by several organizations supporting a specific community with shared concerns.
+
+A hybrid cloud can be a deployment model, as a composition of both public and private clouds, or a hybrid model for cloud computing may involve both virtual and physical servers.
Work in the Clouds
------------------
diff --git a/doc/source/images/novascreens.png b/doc/source/images/novascreens.png
new file mode 100644
index 000000000..0fe3279cf
--- /dev/null
+++ b/doc/source/images/novascreens.png
Binary files differ
diff --git a/doc/source/images/novashvirtually.png b/doc/source/images/novashvirtually.png
new file mode 100644
index 000000000..02c7e767c
--- /dev/null
+++ b/doc/source/images/novashvirtually.png
Binary files differ
diff --git a/doc/source/index.rst b/doc/source/index.rst
index 9b2c8e1f8..b9ba6208a 100644
--- a/doc/source/index.rst
+++ b/doc/source/index.rst
@@ -26,7 +26,7 @@ Nova is written with the following design guidelines in mind:
* **Component based architecture**: Quickly add new behaviors
* **Highly available**: Scale to very serious workloads
-* **Fault-Tollerant**: Isloated processes avoid cascading failures
+* **Fault-Tolerant**: Isolated processes avoid cascading failures
* **Recoverable**: Failures should be easy to diagnose, debug, and rectify
* **Open Standards**: Be a reference implementation for a community-driven api
* **API Compatibility**: Nova strives to provide API-compatible with popular systems like Amazon EC2
@@ -62,8 +62,6 @@ Administrator's Documentation
adminguide/single.node.install
adminguide/multi.node.install
-.. todo:: add swiftadmin
-
Developer Docs
==============
diff --git a/doc/source/livecd.rst b/doc/source/livecd.rst
index 82cf4658a..b355fa180 100644
--- a/doc/source/livecd.rst
+++ b/doc/source/livecd.rst
@@ -1,2 +1,48 @@
Installing the Live CD
======================
+
+If you'd like to set up a sandbox installation of Nova, you can use one of these Live CD images.
+
+If you don't already have VirtualBox installed, you can download it from http://www.virtualbox.org/wiki/Downloads.
+
+Download the zip or iso file and then follow these steps to try Nova in a virtual environment.
+
+http://c0047913.cdn1.cloudfiles.rackspacecloud.com/OpenStackNova.x86_64-2010.1.2.iso (OpenSUSE image; root password is "linux" for this image)
+
+http://c0028699.cdn1.cloudfiles.rackspacecloud.com/nova-vm.zip (~900 MB) (log in information is nova/nova)
+
+Once a VM is configured and started, here are the basics:
+
+ #. Login to Ubuntu using ID nova and Password nova.
+
+ #. Switch to running as sudo (enter nova when prompted for the password)::
+
+ sudo -s
+
+ #. To run Nova for the first time, enter::
+
+ cd /var/openstack/
+
+ #. Now that you're in the correct directory, enter::
+
+ ./nova.sh run
+
+ .. image:: images/novashvirtually.png
+
+If it's already running, use screen -ls, and when the nova screen is presented,then enter screen -d -r nova.
+
+These are the steps to get an instance running (the image is already provided in this environment). Enter these commands in the "test" screen.
+
+::
+
+ euca-add-keypair test > test.pem
+ chmod 600 test.pem
+ euca-run-instances -k test -t m1.tiny ami-tiny
+ euca-describe-instances
+
+ ssh -i test.pem root@10.0.0.3
+
+To see output from the various workers, switch screen windows with Ctrl+A " (quotation mark).
+
+ .. image:: images/novascreens.png
+
diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py
index 896e6c223..4b8b85b4c 100644
--- a/nova/api/ec2/cloud.py
+++ b/nova/api/ec2/cloud.py
@@ -450,13 +450,15 @@ class CloudController(object):
"Timestamp": now,
"output": base64.b64encode(output)}
- def describe_volumes(self, context, **kwargs):
+ def describe_volumes(self, context, volume_id=None, **kwargs):
if context.user.is_admin():
volumes = db.volume_get_all(context)
else:
volumes = db.volume_get_all_by_project(context, context.project_id)
- volumes = [self._format_volume(context, v) for v in volumes]
+ # NOTE(vish): volume_id is an optional list of volume ids to filter by.
+ volumes = [self._format_volume(context, v) for v in volumes
+ if volume_id is None or v['ec2_id'] in volume_id]
return {'volumeSet': volumes}
diff --git a/nova/api/openstack/__init__.py b/nova/api/openstack/__init__.py
index 45a2549c0..b21db0aa8 100644
--- a/nova/api/openstack/__init__.py
+++ b/nova/api/openstack/__init__.py
@@ -30,6 +30,7 @@ import webob.dec
import webob.exc
import webob
+from nova import context
from nova import flags
from nova import utils
from nova import wsgi
@@ -88,9 +89,7 @@ class AuthMiddleware(wsgi.Middleware):
if not user:
return faults.Fault(webob.exc.HTTPUnauthorized())
- if 'nova.context' not in req.environ:
- req.environ['nova.context'] = {}
- req.environ['nova.context']['user'] = user
+ req.environ['nova.context'] = context.RequestContext(user, user)
return self.application
@@ -125,12 +124,12 @@ class RateLimitingMiddleware(wsgi.Middleware):
If the request should be rate limited, return a 413 status with a
Retry-After header giving the time when the request would succeed.
"""
- user_id = req.environ['nova.context']['user']['id']
action_name = self.get_action_name(req)
if not action_name:
# Not rate limited
return self.application
- delay = self.get_delay(action_name, user_id)
+ delay = self.get_delay(action_name,
+ req.environ['nova.context'].user_id)
if delay:
# TODO(gundlach): Get the retry-after format correct.
exc = webob.exc.HTTPRequestEntityTooLarge(
diff --git a/nova/api/openstack/auth.py b/nova/api/openstack/auth.py
index 205035915..fcda97ab1 100644
--- a/nova/api/openstack/auth.py
+++ b/nova/api/openstack/auth.py
@@ -74,9 +74,7 @@ class BasicApiAuthManager(object):
if delta.days >= 2:
self.db.auth_destroy_token(self.context, token)
else:
- #TODO(gundlach): Why not just return dict(id=token.user_id)?
- user = self.auth.get_user(token.user_id)
- return {'id': user.id}
+ return self.auth.get_user(token.user_id)
return None
def _authorize_user(self, username, key, req):
diff --git a/nova/api/openstack/images.py b/nova/api/openstack/images.py
index cdbdc9bdd..4a0a8e6f1 100644
--- a/nova/api/openstack/images.py
+++ b/nova/api/openstack/images.py
@@ -17,7 +17,6 @@
from webob import exc
-from nova import context
from nova import flags
from nova import utils
from nova import wsgi
@@ -47,10 +46,8 @@ class Controller(wsgi.Controller):
def detail(self, req):
"""Return all public images in detail."""
- user_id = req.environ['nova.context']['user']['id']
- ctxt = context.RequestContext(user_id, user_id)
try:
- images = self._service.detail(ctxt)
+ images = self._service.detail(req.environ['nova.context'])
images = nova.api.openstack.limited(images, req)
except NotImplementedError:
# Emulate detail() using repeated calls to show()
@@ -61,9 +58,7 @@ class Controller(wsgi.Controller):
def show(self, req, id):
"""Return data about the given image id."""
- user_id = req.environ['nova.context']['user']['id']
- ctxt = context.RequestContext(user_id, user_id)
- return dict(image=self._service.show(ctxt, id))
+ return dict(image=self._service.show(req.environ['nova.context'], id))
def delete(self, req, id):
# Only public images are supported for now.
diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py
index 6f2f6fed9..7704f48f1 100644
--- a/nova/api/openstack/servers.py
+++ b/nova/api/openstack/servers.py
@@ -17,7 +17,6 @@
from webob import exc
-from nova import context
from nova import exception
from nova import wsgi
from nova.api.openstack import faults
@@ -90,29 +89,26 @@ class Controller(wsgi.Controller):
entity_maker - either _entity_detail or _entity_inst
"""
- user_id = req.environ['nova.context']['user']['id']
- ctxt = context.RequestContext(user_id, user_id)
- instance_list = self.compute_api.get_instances(ctxt)
+ instance_list = self.compute_api.get_instances(
+ req.environ['nova.context'])
limited_list = nova.api.openstack.limited(instance_list, req)
res = [entity_maker(inst)['server'] for inst in limited_list]
return _entity_list(res)
def show(self, req, id):
""" Returns server details by server id """
- user_id = req.environ['nova.context']['user']['id']
- ctxt = context.RequestContext(user_id, user_id)
- inst = self.compute_api.get_instance(ctxt, int(id))
- if inst:
- if inst.user_id == user_id:
- return _entity_detail(inst)
- raise faults.Fault(exc.HTTPNotFound())
+ try:
+ instance = self.compute_api.get_instance(
+ req.environ['nova.context'], int(id))
+ return _entity_detail(instance)
+ except exception.NotFound:
+ return faults.Fault(exc.HTTPNotFound())
def delete(self, req, id):
""" Destroys a server """
- user_id = req.environ['nova.context']['user']['id']
- ctxt = context.RequestContext(user_id, user_id)
try:
- self.compute_api.delete_instance(ctxt, int(id))
+ self.compute_api.delete_instance(req.environ['nova.context'],
+ int(id))
except exception.NotFound:
return faults.Fault(exc.HTTPNotFound())
return exc.HTTPAccepted()
@@ -123,10 +119,10 @@ class Controller(wsgi.Controller):
if not env:
return faults.Fault(exc.HTTPUnprocessableEntity())
- user_id = req.environ['nova.context']['user']['id']
- ctxt = context.RequestContext(user_id, user_id)
- key_pair = auth_manager.AuthManager.get_key_pairs(ctxt)[0]
- instances = self.compute_api.create_instances(ctxt,
+ key_pair = auth_manager.AuthManager.get_key_pairs(
+ req.environ['nova.context'])[0]
+ instances = self.compute_api.create_instances(
+ req.environ['nova.context'],
instance_types.get_by_flavor_id(env['server']['flavorId']),
env['server']['imageId'],
display_name=env['server']['name'],
@@ -137,8 +133,6 @@ class Controller(wsgi.Controller):
def update(self, req, id):
""" Updates the server name or password """
- user_id = req.environ['nova.context']['user']['id']
- ctxt = context.RequestContext(user_id, user_id)
inst_dict = self._deserialize(req.body, req)
if not inst_dict:
return faults.Fault(exc.HTTPUnprocessableEntity())
@@ -150,7 +144,8 @@ class Controller(wsgi.Controller):
update_dict['display_name'] = inst_dict['server']['name']
try:
- self.compute_api.update_instance(ctxt, instance['id'],
+ self.compute_api.update_instance(req.environ['nova.context'],
+ instance['id'],
**update_dict)
except exception.NotFound:
return faults.Fault(exc.HTTPNotFound())
@@ -159,8 +154,6 @@ class Controller(wsgi.Controller):
def action(self, req, id):
""" Multi-purpose method used to reboot, rebuild, and
resize a server """
- user_id = req.environ['nova.context']['user']['id']
- ctxt = context.RequestContext(user_id, user_id)
input_dict = self._deserialize(req.body, req)
try:
reboot_type = input_dict['reboot']['type']
@@ -169,7 +162,7 @@ class Controller(wsgi.Controller):
try:
# TODO(gundlach): pass reboot_type, support soft reboot in
# virt driver
- self.compute_api.reboot(ctxt, id)
+ self.compute_api.reboot(req.environ['nova.context'], id)
except:
return faults.Fault(exc.HTTPUnprocessableEntity())
return exc.HTTPAccepted()
diff --git a/nova/compute/instance_types.py b/nova/compute/instance_types.py
index 000b3a6d9..196d6a8df 100644
--- a/nova/compute/instance_types.py
+++ b/nova/compute/instance_types.py
@@ -22,6 +22,7 @@ The built-in instance properties.
"""
from nova import flags
+from nova import exception
FLAGS = flags.FLAGS
INSTANCE_TYPES = {
diff --git a/nova/objectstore/image.py b/nova/objectstore/image.py
index 7292dbab8..34a90b0a2 100644
--- a/nova/objectstore/image.py
+++ b/nova/objectstore/image.py
@@ -21,7 +21,6 @@ Take uploaded bucket contents and register them as disk images (AMIs).
Requires decryption using keys in the manifest.
"""
-# TODO(jesse): Got these from Euca2ools, will need to revisit them
import binascii
import glob
@@ -29,7 +28,6 @@ import json
import os
import shutil
import tarfile
-import tempfile
from xml.etree import ElementTree
from nova import exception
@@ -199,12 +197,17 @@ class Image(object):
except:
ramdisk_id = None
+ try:
+ arch = manifest.find("machine_configuration/architecture").text
+ except:
+ arch = 'x86_64'
+
info = {
'imageId': image_id,
'imageLocation': image_location,
'imageOwnerId': context.project_id,
'isPublic': False, # FIXME: grab public from manifest
- 'architecture': 'x86_64', # FIXME: grab architecture from manifest
+ 'architecture': arch,
'imageType': image_type}
if kernel_id:
diff --git a/nova/tests/api/openstack/fakes.py b/nova/tests/api/openstack/fakes.py
index c3f129a32..21b8aac1c 100644
--- a/nova/tests/api/openstack/fakes.py
+++ b/nova/tests/api/openstack/fakes.py
@@ -24,9 +24,10 @@ import webob
import webob.dec
from nova import auth
-from nova import utils
-from nova import flags
+from nova import context
from nova import exception as exc
+from nova import flags
+from nova import utils
import nova.api.openstack.auth
from nova.image import service
from nova.image import glance
@@ -58,7 +59,7 @@ def fake_auth_init(self):
@webob.dec.wsgify
def fake_wsgi(self, req):
- req.environ['nova.context'] = dict(user=dict(id=1))
+ req.environ['nova.context'] = context.RequestContext(1, 1)
if req.body:
req.environ['inst_dict'] = json.loads(req.body)
return self.application
@@ -171,6 +172,12 @@ class FakeToken(object):
setattr(self, k, v)
+class FakeRequestContext(object):
+ def __init__(self, user, project):
+ self.user_id = 1
+ self.project_id = 1
+
+
class FakeAuthDatabase(object):
data = {}
diff --git a/nova/tests/api/openstack/test_auth.py b/nova/tests/api/openstack/test_auth.py
index 14e720be4..7b427c2db 100644
--- a/nova/tests/api/openstack/test_auth.py
+++ b/nova/tests/api/openstack/test_auth.py
@@ -26,6 +26,7 @@ import nova.api
import nova.api.openstack.auth
import nova.auth.manager
from nova import auth
+from nova import context
from nova.tests.api.openstack import fakes
@@ -35,6 +36,7 @@ class Test(unittest.TestCase):
self.stubs = stubout.StubOutForTesting()
self.stubs.Set(nova.api.openstack.auth.BasicApiAuthManager,
'__init__', fakes.fake_auth_init)
+ self.stubs.Set(context, 'RequestContext', fakes.FakeRequestContext)
fakes.FakeAuthManager.auth_data = {}
fakes.FakeAuthDatabase.data = {}
fakes.stub_out_rate_limiting(self.stubs)
@@ -131,6 +133,7 @@ class TestLimiter(unittest.TestCase):
self.stubs = stubout.StubOutForTesting()
self.stubs.Set(nova.api.openstack.auth.BasicApiAuthManager,
'__init__', fakes.fake_auth_init)
+ self.stubs.Set(context, 'RequestContext', fakes.FakeRequestContext)
fakes.FakeAuthManager.auth_data = {}
fakes.FakeAuthDatabase.data = {}
fakes.stub_out_networking(self.stubs)
diff --git a/nova/tests/cloud_unittest.py b/nova/tests/cloud_unittest.py
index 9886a2449..770c94219 100644
--- a/nova/tests/cloud_unittest.py
+++ b/nova/tests/cloud_unittest.py
@@ -126,6 +126,19 @@ class CloudTestCase(test.TrialTestCase):
db.instance_destroy(self.context, inst['id'])
db.floating_ip_destroy(self.context, address)
+ def test_describe_volumes(self):
+ """Makes sure describe_volumes works and filters results."""
+ vol1 = db.volume_create(self.context, {})
+ vol2 = db.volume_create(self.context, {})
+ result = self.cloud.describe_volumes(self.context)
+ self.assertEqual(len(result['volumeSet']), 2)
+ result = self.cloud.describe_volumes(self.context,
+ volume_id=[vol2['ec2_id']])
+ self.assertEqual(len(result['volumeSet']), 1)
+ self.assertEqual(result['volumeSet'][0]['volumeId'], vol2['ec2_id'])
+ db.volume_destroy(self.context, vol1['id'])
+ db.volume_destroy(self.context, vol2['id'])
+
def test_console_output(self):
image_id = FLAGS.default_image
instance_type = FLAGS.default_instance_type
diff --git a/nova/tests/misc_unittest.py b/nova/tests/misc_unittest.py
index 667c63ad0..2758276e5 100644
--- a/nova/tests/misc_unittest.py
+++ b/nova/tests/misc_unittest.py
@@ -30,23 +30,26 @@ class ProjectTestCase(test.TrialTestCase):
import bzrlib.workingtree
tree = bzrlib.workingtree.WorkingTree.open('..')
tree.lock_read()
- parents = tree.get_parent_ids()
- g = tree.branch.repository.get_graph()
- for p in parents[1:]:
- rev_ids = [r for r, _ in g.iter_ancestry(parents)
- if r != "null:"]
- revs = tree.branch.repository.get_revisions(rev_ids)
- for r in revs:
- for author in r.get_apparent_authors():
- email = author.split(' ')[-1]
- contributors.add(str_dict_replace(email, mailmap))
-
- authors_file = open('../Authors', 'r').read()
-
- missing = set()
- for contributor in contributors:
- if not contributor in authors_file:
- missing.add(contributor)
-
- self.assertTrue(len(missing) == 0,
- '%r not listed in Authors' % missing)
+ try:
+ parents = tree.get_parent_ids()
+ g = tree.branch.repository.get_graph()
+ for p in parents[1:]:
+ rev_ids = [r for r, _ in g.iter_ancestry(parents)
+ if r != "null:"]
+ revs = tree.branch.repository.get_revisions(rev_ids)
+ for r in revs:
+ for author in r.get_apparent_authors():
+ email = author.split(' ')[-1]
+ contributors.add(str_dict_replace(email, mailmap))
+
+ authors_file = open('../Authors', 'r').read()
+
+ missing = set()
+ for contributor in contributors:
+ if not contributor in authors_file:
+ missing.add(contributor)
+
+ self.assertTrue(len(missing) == 0,
+ '%r not listed in Authors' % missing)
+ finally:
+ tree.unlock()
diff --git a/smoketests/admin_smoketests.py b/smoketests/admin_smoketests.py
new file mode 100644
index 000000000..50bb3fa2e
--- /dev/null
+++ b/smoketests/admin_smoketests.py
@@ -0,0 +1,92 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2010 United States Government as represented by the
+# Administrator of the National Aeronautics and Space Administration.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import os
+import random
+import sys
+import time
+import unittest
+import zipfile
+
+from nova import adminclient
+from smoketests import flags
+from smoketests import base
+
+
+SUITE_NAMES = '[user]'
+
+FLAGS = flags.FLAGS
+flags.DEFINE_string('suite', None, 'Specific test suite to run ' + SUITE_NAMES)
+
+# TODO(devamcar): Use random tempfile
+ZIP_FILENAME = '/tmp/nova-me-x509.zip'
+
+TEST_PREFIX = 'test%s' % int(random.random()*1000000)
+TEST_USERNAME = '%suser' % TEST_PREFIX
+TEST_PROJECTNAME = '%sproject' % TEST_PREFIX
+
+
+class AdminSmokeTestCase(base.SmokeTestCase):
+ def setUp(self):
+ self.admin = adminclient.NovaAdminClient(
+ access_key=os.getenv('EC2_ACCESS_KEY'),
+ secret_key=os.getenv('EC2_SECRET_KEY'),
+ clc_url=os.getenv('EC2_URL'),
+ region=FLAGS.region)
+
+
+class UserTests(AdminSmokeTestCase):
+ """ Test admin credentials and user creation. """
+
+ def test_001_admin_can_connect(self):
+ conn = self.admin.connection_for('admin', 'admin')
+ self.assert_(conn)
+
+ def test_002_admin_can_create_user(self):
+ user = self.admin.create_user(TEST_USERNAME)
+ self.assertEqual(user.username, TEST_USERNAME)
+
+ def test_003_admin_can_create_project(self):
+ project = self.admin.create_project(TEST_PROJECTNAME,
+ TEST_USERNAME)
+ self.assertEqual(project.projectname, TEST_PROJECTNAME)
+
+ def test_004_user_can_download_credentials(self):
+ buf = self.admin.get_zip(TEST_USERNAME, TEST_PROJECTNAME)
+ output = open(ZIP_FILENAME, 'w')
+ output.write(buf)
+ output.close()
+
+ zip = zipfile.ZipFile(ZIP_FILENAME, 'a', zipfile.ZIP_DEFLATED)
+ bad = zip.testzip()
+ zip.close()
+
+ self.failIf(bad)
+
+ def test_999_tearDown(self):
+ self.admin.delete_project(TEST_PROJECTNAME)
+ self.admin.delete_user(TEST_USERNAME)
+ try:
+ os.remove(ZIP_FILENAME)
+ except:
+ pass
+
+if __name__ == "__main__":
+ suites = {'user': unittest.makeSuite(UserTests)}
+ sys.exit(base.run_tests(suites))
+
diff --git a/smoketests/novatestcase.py b/smoketests/base.py
index 513e0ca91..5a14d3e09 100644
--- a/smoketests/novatestcase.py
+++ b/smoketests/base.py
@@ -16,36 +16,26 @@
# License for the specific language governing permissions and limitations
# under the License.
+import boto
import commands
+import httplib
import os
+import paramiko
import random
import sys
import unittest
+from boto.ec2.regioninfo import RegionInfo
-
-import paramiko
-
-from nova import adminclient
from smoketests import flags
FLAGS = flags.FLAGS
-class NovaTestCase(unittest.TestCase):
- def setUp(self):
- self.nova_admin = adminclient.NovaAdminClient(
- access_key=FLAGS.admin_access_key,
- secret_key=FLAGS.admin_secret_key,
- clc_ip=FLAGS.clc_ip)
-
- def tearDown(self):
- pass
-
+class SmokeTestCase(unittest.TestCase):
def connect_ssh(self, ip, key_name):
# TODO(devcamcar): set a more reasonable connection timeout time
key = paramiko.RSAKey.from_private_key_file('/tmp/%s.pem' % key_name)
client = paramiko.SSHClient()
- client.load_system_host_keys()
client.set_missing_host_key_policy(paramiko.WarningPolicy())
client.connect(ip, username='root', pkey=key)
stdin, stdout, stderr = client.exec_command('uptime')
@@ -53,26 +43,50 @@ class NovaTestCase(unittest.TestCase):
return client
def can_ping(self, ip):
- return commands.getstatusoutput('ping -c 1 %s' % ip)[0] == 0
-
- @property
- def admin(self):
- return self.nova_admin.connection_for('admin')
-
- def connection_for(self, username):
- return self.nova_admin.connection_for(username)
-
- def create_user(self, username):
- return self.nova_admin.create_user(username)
-
- def get_user(self, username):
- return self.nova_admin.get_user(username)
-
- def delete_user(self, username):
- return self.nova_admin.delete_user(username)
-
- def get_signed_zip(self, username):
- return self.nova_admin.get_zip(username)
+ """ Attempt to ping the specified IP, and give up after 1 second. """
+
+ # NOTE(devcamcar): ping timeout flag is different in OSX.
+ if sys.platform == 'darwin':
+ timeout_flag = 't'
+ else:
+ timeout_flag = 'w'
+
+ status, output = commands.getstatusoutput('ping -c1 -%s1 %s' %
+ (timeout_flag, ip))
+ return status == 0
+
+ def connection_for_env(self, **kwargs):
+ """
+ Returns a boto ec2 connection for the current environment.
+ """
+ access_key = os.getenv('EC2_ACCESS_KEY')
+ secret_key = os.getenv('EC2_SECRET_KEY')
+ clc_url = os.getenv('EC2_URL')
+
+ if not access_key or not secret_key or not clc_url:
+ raise Exception('Missing EC2 environment variables. Please source '
+ 'the appropriate novarc file before running this '
+ 'test.')
+
+ parts = self.split_clc_url(clc_url)
+ return boto.connect_ec2(aws_access_key_id=access_key,
+ aws_secret_access_key=secret_key,
+ is_secure=parts['is_secure'],
+ region=RegionInfo(None,
+ 'nova',
+ parts['ip']),
+ port=parts['port'],
+ path='/services/Cloud',
+ **kwargs)
+
+ def split_clc_url(self, clc_url):
+ """
+ Splits a cloud controller endpoint url.
+ """
+ parts = httplib.urlsplit(clc_url)
+ is_secure = parts.scheme == 'https'
+ ip, port = parts.netloc.split(':')
+ return {'ip': ip, 'port': int(port), 'is_secure': is_secure}
def create_key_pair(self, conn, key_name):
try:
@@ -116,15 +130,25 @@ class NovaTestCase(unittest.TestCase):
raise Exception(output)
return True
- def register_image(self, bucket_name, manifest):
- conn = nova_admin.connection_for('admin')
- return conn.register_image("%s/%s.manifest.xml" % (bucket_name, manifest))
+def run_tests(suites):
+ argv = FLAGS(sys.argv)
+
+ if not os.getenv('EC2_ACCESS_KEY'):
+ print >> sys.stderr, 'Missing EC2 environment variables. Please ' \
+ 'source the appropriate novarc file before ' \
+ 'running this test.'
+ return 1
+
+ if FLAGS.suite:
+ try:
+ suite = suites[FLAGS.suite]
+ except KeyError:
+ print >> sys.stderr, 'Available test suites:', \
+ ', '.join(suites.keys())
+ return 1
- def setUp_test_image(self, image, kernel=False):
- self.bundle_image(image, kernel=kernel)
- bucket = "auto_test_%s" % int(random.random() * 1000000)
- self.upload_image(bucket, image)
- return self.register_image(bucket, image)
+ unittest.TextTestRunner(verbosity=2).run(suite)
+ else:
+ for suite in suites.itervalues():
+ unittest.TextTestRunner(verbosity=2).run(suite)
- def tearDown_test_image(self, conn, image_id):
- conn.deregister_image(image_id)
diff --git a/smoketests/flags.py b/smoketests/flags.py
index 3617fb797..ae4d09508 100644
--- a/smoketests/flags.py
+++ b/smoketests/flags.py
@@ -1,7 +1,7 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2010 United States Government as represented by the
-# Administrator of the National Aeronautics and Space Administration.
+# Administrator of the National Aeronautics and Space Administration.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -33,13 +33,6 @@ DEFINE_bool = DEFINE_bool
# __GLOBAL FLAGS ONLY__
# Define any app-specific flags in their own files, docs at:
# http://code.google.com/p/python-gflags/source/browse/trunk/gflags.py#39
-DEFINE_string('admin_access_key', 'admin', 'Access key for admin user')
-DEFINE_string('admin_secret_key', 'admin', 'Secret key for admin user')
-DEFINE_string('clc_ip', '127.0.0.1', 'IP of cloud controller API')
-DEFINE_string('bundle_kernel', 'openwrt-x86-vmlinuz',
- 'Local kernel file to use for bundling tests')
-DEFINE_string('bundle_image', 'openwrt-x86-ext2.image',
- 'Local image file to use for bundling tests')
-#DEFINE_string('vpn_image_id', 'ami-CLOUDPIPE',
-# 'AMI for cloudpipe vpn server')
+DEFINE_string('region', 'nova', 'Region to use')
+DEFINE_string('test_image', 'ami-tiny', 'Image to use for launch tests')
diff --git a/smoketests/smoketest.py b/smoketests/smoketest.py
deleted file mode 100644
index ad95114d4..000000000
--- a/smoketests/smoketest.py
+++ /dev/null
@@ -1,566 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2010 United States Government as represented by the
-# Administrator of the National Aeronautics and Space Administration.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import commands
-import os
-import random
-import re
-import sys
-import time
-import unittest
-import zipfile
-
-
-import paramiko
-
-from smoketests import flags
-from smoketests import novatestcase
-
-SUITE_NAMES = '[user, image, security, public_network, volume]'
-
-FLAGS = flags.FLAGS
-flags.DEFINE_string('suite', None, 'Specific test suite to run ' + SUITE_NAMES)
-
-# TODO(devamcar): Use random tempfile
-ZIP_FILENAME = '/tmp/nova-me-x509.zip'
-
-data = {}
-
-test_prefix = 'test%s' % int(random.random()*1000000)
-test_username = '%suser' % test_prefix
-test_bucket = '%s_bucket' % test_prefix
-test_key = '%s_key' % test_prefix
-
-# Test admin credentials and user creation
-class UserTests(novatestcase.NovaTestCase):
- def test_001_admin_can_connect(self):
- conn = self.connection_for('admin')
- self.assert_(conn)
-
- def test_002_admin_can_create_user(self):
- userinfo = self.create_user(test_username)
- self.assertEqual(userinfo.username, test_username)
-
- def test_003_user_can_download_credentials(self):
- buf = self.get_signed_zip(test_username)
- output = open(ZIP_FILENAME, 'w')
- output.write(buf)
- output.close()
-
- zip = zipfile.ZipFile(ZIP_FILENAME, 'a', zipfile.ZIP_DEFLATED)
- bad = zip.testzip()
- zip.close()
-
- self.failIf(bad)
-
- def test_999_tearDown(self):
- self.delete_user(test_username)
- user = self.get_user(test_username)
- self.assert_(user is None)
- try:
- os.remove(ZIP_FILENAME)
- except:
- pass
-
-# Test image bundling, registration, and launching
-class ImageTests(novatestcase.NovaTestCase):
- def test_000_setUp(self):
- self.create_user(test_username)
-
- def test_001_admin_can_bundle_image(self):
- self.assertTrue(self.bundle_image(FLAGS.bundle_image))
-
- def test_002_admin_can_upload_image(self):
- self.assertTrue(self.upload_image(test_bucket, FLAGS.bundle_image))
-
- def test_003_admin_can_register_image(self):
- image_id = self.register_image(test_bucket, FLAGS.bundle_image)
- self.assert_(image_id is not None)
- data['image_id'] = image_id
-
- def test_004_admin_can_bundle_kernel(self):
- self.assertTrue(self.bundle_image(FLAGS.bundle_kernel, kernel=True))
-
- def test_005_admin_can_upload_kernel(self):
- self.assertTrue(self.upload_image(test_bucket, FLAGS.bundle_kernel))
-
- def test_006_admin_can_register_kernel(self):
- # FIXME(devcamcar): registration should verify that bucket/manifest
- # exists before returning successfully.
- kernel_id = self.register_image(test_bucket, FLAGS.bundle_kernel)
- self.assert_(kernel_id is not None)
- data['kernel_id'] = kernel_id
-
- def test_007_admin_images_are_available_within_10_seconds(self):
- for i in xrange(10):
- image = self.admin.get_image(data['image_id'])
- if image and image.state == 'available':
- break
- time.sleep(1)
- else:
- print image.state
- self.assert_(False) # wasn't available within 10 seconds
- self.assert_(image.type == 'machine')
-
- for i in xrange(10):
- kernel = self.admin.get_image(data['kernel_id'])
- if kernel and kernel.state == 'available':
- break
- time.sleep(1)
- else:
- self.assert_(False) # wasn't available within 10 seconds
- self.assert_(kernel.type == 'kernel')
-
- def test_008_admin_can_describe_image_attribute(self):
- attrs = self.admin.get_image_attribute(data['image_id'],
- 'launchPermission')
- self.assert_(attrs.name, 'launch_permission')
-
- def test_009_me_cannot_see_non_public_images(self):
- conn = self.connection_for(test_username)
- images = conn.get_all_images(image_ids=[data['image_id']])
- self.assertEqual(len(images), 0)
-
- def test_010_admin_can_modify_image_launch_permission(self):
- conn = self.connection_for(test_username)
-
- self.admin.modify_image_attribute(image_id=data['image_id'],
- operation='add',
- attribute='launchPermission',
- groups='all')
-
- image = conn.get_image(data['image_id'])
- self.assertEqual(image.id, data['image_id'])
-
- def test_011_me_can_list_public_images(self):
- conn = self.connection_for(test_username)
- images = conn.get_all_images(image_ids=[data['image_id']])
- self.assertEqual(len(images), 1)
- pass
-
- def test_012_me_can_see_launch_permission(self):
- attrs = self.admin.get_image_attribute(data['image_id'],
- 'launchPermission')
- self.assert_(attrs.name, 'launch_permission')
- self.assert_(attrs.groups[0], 'all')
-
- # FIXME: add tests that user can launch image
-
-# def test_013_user_can_launch_admin_public_image(self):
-# # TODO: Use openwrt kernel instead of default kernel
-# conn = self.connection_for(test_username)
-# reservation = conn.run_instances(data['image_id'])
-# self.assertEqual(len(reservation.instances), 1)
-# data['my_instance_id'] = reservation.instances[0].id
-
-# def test_014_instances_launch_within_30_seconds(self):
-# pass
-
-# def test_015_user_can_terminate(self):
-# conn = self.connection_for(test_username)
-# terminated = conn.terminate_instances(
-# instance_ids=[data['my_instance_id']])
-# self.assertEqual(len(terminated), 1)
-
- def test_016_admin_can_deregister_kernel(self):
- self.assertTrue(self.admin.deregister_image(data['kernel_id']))
-
- def test_017_admin_can_deregister_image(self):
- self.assertTrue(self.admin.deregister_image(data['image_id']))
-
- def test_018_admin_can_delete_bundle(self):
- self.assertTrue(self.delete_bundle_bucket(test_bucket))
-
- def test_999_tearDown(self):
- data = {}
- self.delete_user(test_username)
-
-
-# Test key pairs and security groups
-class SecurityTests(novatestcase.NovaTestCase):
- def test_000_setUp(self):
- self.create_user(test_username + '_me')
- self.create_user(test_username + '_you')
- data['image_id'] = 'ami-tiny'
-
- def test_001_me_can_create_keypair(self):
- conn = self.connection_for(test_username + '_me')
- key = self.create_key_pair(conn, test_key)
- self.assertEqual(key.name, test_key)
-
- def test_002_you_can_create_keypair(self):
- conn = self.connection_for(test_username + '_you')
- key = self.create_key_pair(conn, test_key+ 'yourkey')
- self.assertEqual(key.name, test_key+'yourkey')
-
- def test_003_me_can_create_instance_with_keypair(self):
- conn = self.connection_for(test_username + '_me')
- reservation = conn.run_instances(data['image_id'], key_name=test_key)
- self.assertEqual(len(reservation.instances), 1)
- data['my_instance_id'] = reservation.instances[0].id
-
- def test_004_me_can_obtain_private_ip_within_60_seconds(self):
- conn = self.connection_for(test_username + '_me')
- reservations = conn.get_all_instances([data['my_instance_id']])
- instance = reservations[0].instances[0]
- # allow 60 seconds to exit pending with IP
- for x in xrange(60):
- instance.update()
- if instance.state != u'pending':
- break
- time.sleep(1)
- else:
- self.assert_(False)
- # self.assertEqual(instance.state, u'running')
- ip = reservations[0].instances[0].private_dns_name
- self.failIf(ip == '0.0.0.0')
- data['my_private_ip'] = ip
- print data['my_private_ip'],
-
- def test_005_can_ping_private_ip(self):
- for x in xrange(120):
- # ping waits for 1 second
- status, output = commands.getstatusoutput(
- 'ping -c1 -w1 %s' % data['my_private_ip'])
- if status == 0:
- break
- else:
- self.assert_('could not ping instance')
- #def test_005_me_cannot_ssh_when_unauthorized(self):
- # self.assertRaises(paramiko.SSHException, self.connect_ssh,
- # data['my_private_ip'], 'mykey')
-
- #def test_006_me_can_authorize_ssh(self):
- # conn = self.connection_for(test_username + '_me')
- # self.assertTrue(
- # conn.authorize_security_group(
- # 'default',
- # ip_protocol='tcp',
- # from_port=22,
- # to_port=22,
- # cidr_ip='0.0.0.0/0'
- # )
- # )
-
- def test_007_me_can_ssh_when_authorized(self):
- conn = self.connect_ssh(data['my_private_ip'], test_key)
- conn.close()
-
- #def test_008_me_can_revoke_ssh_authorization(self):
- # conn = self.connection_for('me')
- # self.assertTrue(
- # conn.revoke_security_group(
- # 'default',
- # ip_protocol='tcp',
- # from_port=22,
- # to_port=22,
- # cidr_ip='0.0.0.0/0'
- # )
- # )
-
- #def test_009_you_cannot_ping_my_instance(self):
- # TODO: should ping my_private_ip from with an instance started by you.
- #self.assertFalse(self.can_ping(data['my_private_ip']))
-
- def test_010_you_cannot_ssh_to_my_instance(self):
- try:
- conn = self.connect_ssh(data['my_private_ip'],
- test_key + 'yourkey')
- conn.close()
- except paramiko.SSHException:
- pass
- else:
- self.fail("expected SSHException")
-
- def test_999_tearDown(self):
- conn = self.connection_for(test_username + '_me')
- self.delete_key_pair(conn, test_key)
- if data.has_key('my_instance_id'):
- conn.terminate_instances([data['my_instance_id']])
-
- conn = self.connection_for(test_username + '_you')
- self.delete_key_pair(conn, test_key + 'yourkey')
-
- conn = self.connection_for('admin')
- self.delete_user(test_username + '_me')
- self.delete_user(test_username + '_you')
- #self.tearDown_test_image(conn, data['image_id'])
-
-# TODO: verify wrt image boots
-# build python into wrt image
-# build boto/m2crypto into wrt image
-# build euca2ools into wrt image
-# build a script to download and unpack credentials
-# - return "ok" to stdout for comparison in self.assertEqual()
-# build a script to bundle the instance
-# build a script to upload the bundle
-
-# status, output = commands.getstatusoutput('cmd')
-# if status == 0:
-# print 'ok'
-# else:
-# print output
-
-# Testing rebundling
-class RebundlingTests(novatestcase.NovaTestCase):
- def test_000_setUp(self):
- self.create_user('me')
- self.create_user('you')
- # TODO: create keypair for me
- # upload smoketest img
- # run instance
-
- def test_001_me_can_download_credentials_within_instance(self):
- conn = self.connect_ssh(data['my_private_ip'], 'mykey')
- stdin, stdout = conn.exec_command(
- 'python ~/smoketests/install-credentials.py')
- conn.close()
- self.assertEqual(stdout, 'ok')
-
- def test_002_me_can_rebundle_within_instance(self):
- conn = self.connect_ssh(data['my_private_ip'], 'mykey')
- stdin, stdout = conn.exec_command(
- 'python ~/smoketests/rebundle-instance.py')
- conn.close()
- self.assertEqual(stdout, 'ok')
-
- def test_003_me_can_upload_image_within_instance(self):
- conn = self.connect_ssh(data['my_private_ip'], 'mykey')
- stdin, stdout = conn.exec_command(
- 'python ~/smoketests/upload-bundle.py')
- conn.close()
- self.assertEqual(stdout, 'ok')
-
- def test_004_me_can_register_image_within_instance(self):
- conn = self.connect_ssh(data['my_private_ip'], 'mykey')
- stdin, stdout = conn.exec_command(
- 'python ~/smoketests/register-image.py')
- conn.close()
- if re.matches('ami-{\w+}', stdout):
- data['my_image_id'] = stdout.strip()
- else:
- self.fail('expected ami-nnnnnn, got:\n ' + stdout)
-
- def test_005_you_cannot_see_my_private_image(self):
- conn = self.connection_for('you')
- image = conn.get_image(data['my_image_id'])
- self.assertEqual(image, None)
-
- def test_006_me_can_make_image_public(self):
- conn = self.connection_for(test_username)
- conn.modify_image_attribute(image_id=data['my_image_id'],
- operation='add',
- attribute='launchPermission',
- groups='all')
-
- def test_007_you_can_see_my_public_image(self):
- conn = self.connection_for('you')
- image = conn.get_image(data['my_image_id'])
- self.assertEqual(image.id, data['my_image_id'])
-
- def test_999_tearDown(self):
- self.delete_user('me')
- self.delete_user('you')
-
- #if data.has_key('image_id'):
- # deregister rebundled image
-
- # TODO: tear down instance
- # delete keypairs
- data = {}
-
-# Test elastic IPs
-class ElasticIPTests(novatestcase.NovaTestCase):
- def test_000_setUp(self):
- data['image_id'] = 'ami-tiny'
-
- self.create_user('me')
- conn = self.connection_for('me')
- self.create_key_pair(conn, 'mykey')
-
- conn = self.connection_for('admin')
- #data['image_id'] = self.setUp_test_image(FLAGS.bundle_image)
-
- def test_001_me_can_launch_image_with_keypair(self):
- conn = self.connection_for('me')
- reservation = conn.run_instances(data['image_id'], key_name='mykey')
- self.assertEqual(len(reservation.instances), 1)
- data['my_instance_id'] = reservation.instances[0].id
-
- def test_002_me_can_allocate_elastic_ip(self):
- conn = self.connection_for('me')
- data['my_public_ip'] = conn.allocate_address()
- self.assert_(data['my_public_ip'].public_ip)
-
- def test_003_me_can_associate_ip_with_instance(self):
- self.assertTrue(data['my_public_ip'].associate(data['my_instance_id']))
-
- def test_004_me_can_ssh_with_public_ip(self):
- conn = self.connect_ssh(data['my_public_ip'].public_ip, 'mykey')
- conn.close()
-
- def test_005_me_can_disassociate_ip_from_instance(self):
- self.assertTrue(data['my_public_ip'].disassociate())
-
- def test_006_me_can_deallocate_elastic_ip(self):
- self.assertTrue(data['my_public_ip'].delete())
-
- def test_999_tearDown(self):
- conn = self.connection_for('me')
- self.delete_key_pair(conn, 'mykey')
-
- conn = self.connection_for('admin')
- #self.tearDown_test_image(conn, data['image_id'])
- data = {}
-
-ZONE = 'nova'
-DEVICE = 'vdb'
-# Test iscsi volumes
-class VolumeTests(novatestcase.NovaTestCase):
- def test_000_setUp(self):
- self.create_user(test_username)
- data['image_id'] = 'ami-tiny' # A7370FE3
-
- conn = self.connection_for(test_username)
- self.create_key_pair(conn, test_key)
- reservation = conn.run_instances(data['image_id'],
- instance_type='m1.tiny',
- key_name=test_key)
- data['instance_id'] = reservation.instances[0].id
- data['private_ip'] = reservation.instances[0].private_dns_name
- # wait for instance to show up
- for x in xrange(120):
- # ping waits for 1 second
- status, output = commands.getstatusoutput(
- 'ping -c1 -w1 %s' % data['private_ip'])
- if status == 0:
- break
- else:
- self.fail('unable to ping instance')
-
- def test_001_me_can_create_volume(self):
- conn = self.connection_for(test_username)
- volume = conn.create_volume(1, ZONE)
- self.assertEqual(volume.size, 1)
- data['volume_id'] = volume.id
- # give network time to find volume
- time.sleep(5)
-
- def test_002_me_can_attach_volume(self):
- conn = self.connection_for(test_username)
- conn.attach_volume(
- volume_id = data['volume_id'],
- instance_id = data['instance_id'],
- device = '/dev/%s' % DEVICE
- )
- # give instance time to recognize volume
- time.sleep(5)
-
- def test_003_me_can_mount_volume(self):
- conn = self.connect_ssh(data['private_ip'], test_key)
- # FIXME(devcamcar): the tiny image doesn't create the node properly
- # this will make /dev/vd* if it doesn't exist
- stdin, stdout, stderr = conn.exec_command(
- 'grep %s /proc/partitions |' + \
- '`awk \'{print "mknod /dev/"$4" b "$1" "$2}\'`' % DEVICE)
- commands = []
- commands.append('mkdir -p /mnt/vol')
- commands.append('mkfs.ext2 /dev/%s' % DEVICE)
- commands.append('mount /dev/%s /mnt/vol' % DEVICE)
- commands.append('echo success')
- stdin, stdout, stderr = conn.exec_command(' && '.join(commands))
- out = stdout.read()
- conn.close()
- if not out.strip().endswith('success'):
- self.fail('Unable to mount: %s %s' % (out, stderr.read()))
-
- def test_004_me_can_write_to_volume(self):
- conn = self.connect_ssh(data['private_ip'], test_key)
- # FIXME(devcamcar): This doesn't fail if the volume hasn't been mounted
- stdin, stdout, stderr = conn.exec_command(
- 'echo hello > /mnt/vol/test.txt')
- err = stderr.read()
- conn.close()
- if len(err) > 0:
- self.fail('Unable to write to mount: %s' % (err))
-
- def test_005_volume_is_correct_size(self):
- conn = self.connect_ssh(data['private_ip'], test_key)
- stdin, stdout, stderr = conn.exec_command(
- "df -h | grep %s | awk {'print $2'}" % DEVICE)
- out = stdout.read()
- conn.close()
- if not out.strip() == '1007.9M':
- self.fail('Volume is not the right size: %s %s' % (out, stderr.read()))
-
- def test_006_me_can_umount_volume(self):
- conn = self.connect_ssh(data['private_ip'], test_key)
- stdin, stdout, stderr = conn.exec_command('umount /mnt/vol')
- err = stderr.read()
- conn.close()
- if len(err) > 0:
- self.fail('Unable to unmount: %s' % (err))
-
- def test_007_me_can_detach_volume(self):
- conn = self.connection_for(test_username)
- self.assertTrue(conn.detach_volume(volume_id = data['volume_id']))
-
- def test_008_me_can_delete_volume(self):
- conn = self.connection_for(test_username)
- self.assertTrue(conn.delete_volume(data['volume_id']))
-
- def test_009_volume_size_must_be_int(self):
- conn = self.connection_for(test_username)
- self.assertRaises(Exception, conn.create_volume, 'foo', ZONE)
-
- def test_999_tearDown(self):
- global data
- conn = self.connection_for(test_username)
- self.delete_key_pair(conn, test_key)
- if data.has_key('instance_id'):
- conn.terminate_instances([data['instance_id']])
- self.delete_user(test_username)
- data = {}
-
-def build_suites():
- return {
- 'user': unittest.makeSuite(UserTests),
- 'image': unittest.makeSuite(ImageTests),
- 'security': unittest.makeSuite(SecurityTests),
- 'public_network': unittest.makeSuite(ElasticIPTests),
- 'volume': unittest.makeSuite(VolumeTests),
- }
-
-def main():
- argv = FLAGS(sys.argv)
- suites = build_suites()
-
- if FLAGS.suite:
- try:
- suite = suites[FLAGS.suite]
- except KeyError:
- print >> sys.stderr, 'Available test suites:', SUITE_NAMES
- return 1
-
- unittest.TextTestRunner(verbosity=2).run(suite)
- else:
- for suite in suites.itervalues():
- unittest.TextTestRunner(verbosity=2).run(suite)
-
-if __name__ == "__main__":
- sys.exit(main())
diff --git a/smoketests/user_smoketests.py b/smoketests/user_smoketests.py
new file mode 100644
index 000000000..d29e3aea3
--- /dev/null
+++ b/smoketests/user_smoketests.py
@@ -0,0 +1,326 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2010 United States Government as represented by the
+# Administrator of the National Aeronautics and Space Administration.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import commands
+import os
+import random
+import socket
+import sys
+import time
+import unittest
+
+from smoketests import flags
+from smoketests import base
+
+
+SUITE_NAMES = '[image, instance, volume]'
+
+FLAGS = flags.FLAGS
+flags.DEFINE_string('suite', None, 'Specific test suite to run ' + SUITE_NAMES)
+flags.DEFINE_string('bundle_kernel', 'openwrt-x86-vmlinuz',
+ 'Local kernel file to use for bundling tests')
+flags.DEFINE_string('bundle_image', 'openwrt-x86-ext2.image',
+ 'Local image file to use for bundling tests')
+
+TEST_PREFIX = 'test%s' % int (random.random()*1000000)
+TEST_BUCKET = '%s_bucket' % TEST_PREFIX
+TEST_KEY = '%s_key' % TEST_PREFIX
+TEST_DATA = {}
+
+
+class UserSmokeTestCase(base.SmokeTestCase):
+ def setUp(self):
+ global TEST_DATA
+ self.conn = self.connection_for_env()
+ self.data = TEST_DATA
+
+
+class ImageTests(UserSmokeTestCase):
+ def test_001_can_bundle_image(self):
+ self.assertTrue(self.bundle_image(FLAGS.bundle_image))
+
+ def test_002_can_upload_image(self):
+ self.assertTrue(self.upload_image(TEST_BUCKET, FLAGS.bundle_image))
+
+ def test_003_can_register_image(self):
+ image_id = self.conn.register_image('%s/%s.manifest.xml' %
+ (TEST_BUCKET, FLAGS.bundle_image))
+ self.assert_(image_id is not None)
+ self.data['image_id'] = image_id
+
+ def test_004_can_bundle_kernel(self):
+ self.assertTrue(self.bundle_image(FLAGS.bundle_kernel, kernel=True))
+
+ def test_005_can_upload_kernel(self):
+ self.assertTrue(self.upload_image(TEST_BUCKET, FLAGS.bundle_kernel))
+
+ def test_006_can_register_kernel(self):
+ kernel_id = self.conn.register_image('%s/%s.manifest.xml' %
+ (TEST_BUCKET, FLAGS.bundle_kernel))
+ self.assert_(kernel_id is not None)
+ self.data['kernel_id'] = kernel_id
+
+ def test_007_images_are_available_within_10_seconds(self):
+ for i in xrange(10):
+ image = self.conn.get_image(self.data['image_id'])
+ if image and image.state == 'available':
+ break
+ time.sleep(1)
+ else:
+ print image.state
+ self.assert_(False) # wasn't available within 10 seconds
+ self.assert_(image.type == 'machine')
+
+ for i in xrange(10):
+ kernel = self.conn.get_image(self.data['kernel_id'])
+ if kernel and kernel.state == 'available':
+ break
+ time.sleep(1)
+ else:
+ self.assert_(False) # wasn't available within 10 seconds
+ self.assert_(kernel.type == 'kernel')
+
+ def test_008_can_describe_image_attribute(self):
+ attrs = self.conn.get_image_attribute(self.data['image_id'],
+ 'launchPermission')
+ self.assert_(attrs.name, 'launch_permission')
+
+ def test_009_can_modify_image_launch_permission(self):
+ self.conn.modify_image_attribute(image_id=self.data['image_id'],
+ operation='add',
+ attribute='launchPermission',
+ groups='all')
+ image = self.conn.get_image(self.data['image_id'])
+ self.assertEqual(image.id, self.data['image_id'])
+
+ def test_010_can_see_launch_permission(self):
+ attrs = self.conn.get_image_attribute(self.data['image_id'],
+ 'launchPermission')
+ self.assert_(attrs.name, 'launch_permission')
+ self.assert_(attrs.attrs['groups'][0], 'all')
+
+ def test_011_user_can_deregister_kernel(self):
+ self.assertTrue(self.conn.deregister_image(self.data['kernel_id']))
+
+ def test_012_can_deregister_image(self):
+ self.assertTrue(self.conn.deregister_image(self.data['image_id']))
+
+ def test_013_can_delete_bundle(self):
+ self.assertTrue(self.delete_bundle_bucket(TEST_BUCKET))
+
+
+class InstanceTests(UserSmokeTestCase):
+ def test_001_can_create_keypair(self):
+ key = self.create_key_pair(self.conn, TEST_KEY)
+ self.assertEqual(key.name, TEST_KEY)
+
+ def test_002_can_create_instance_with_keypair(self):
+ reservation = self.conn.run_instances(FLAGS.test_image,
+ key_name=TEST_KEY,
+ instance_type='m1.tiny')
+ self.assertEqual(len(reservation.instances), 1)
+ self.data['instance_id'] = reservation.instances[0].id
+
+ def test_003_instance_runs_within_60_seconds(self):
+ reservations = self.conn.get_all_instances([data['instance_id']])
+ instance = reservations[0].instances[0]
+ # allow 60 seconds to exit pending with IP
+ for x in xrange(60):
+ instance.update()
+ if instance.state == u'running':
+ break
+ time.sleep(1)
+ else:
+ self.fail('instance failed to start')
+ ip = reservations[0].instances[0].private_dns_name
+ self.failIf(ip == '0.0.0.0')
+ self.data['private_ip'] = ip
+ print self.data['private_ip']
+
+ def test_004_can_ping_private_ip(self):
+ for x in xrange(120):
+ # ping waits for 1 second
+ status, output = commands.getstatusoutput(
+ 'ping -c1 %s' % self.data['private_ip'])
+ if status == 0:
+ break
+ else:
+ self.fail('could not ping instance')
+
+ def test_005_can_ssh_to_private_ip(self):
+ for x in xrange(30):
+ try:
+ conn = self.connect_ssh(self.data['private_ip'], TEST_KEY)
+ conn.close()
+ except Exception:
+ time.sleep(1)
+ else:
+ break
+ else:
+ self.fail('could not ssh to instance')
+
+ def test_006_can_allocate_elastic_ip(self):
+ result = self.conn.allocate_address()
+ self.assertTrue(hasattr(result, 'public_ip'))
+ self.data['public_ip'] = result.public_ip
+
+ def test_007_can_associate_ip_with_instance(self):
+ result = self.conn.associate_address(self.data['instance_id'],
+ self.data['public_ip'])
+ self.assertTrue(result)
+
+ def test_008_can_ssh_with_public_ip(self):
+ for x in xrange(30):
+ try:
+ conn = self.connect_ssh(self.data['public_ip'], TEST_KEY)
+ conn.close()
+ except socket.error:
+ time.sleep(1)
+ else:
+ break
+ else:
+ self.fail('could not ssh to instance')
+
+ def test_009_can_disassociate_ip_from_instance(self):
+ result = self.conn.disassociate_address(self.data['public_ip'])
+ self.assertTrue(result)
+
+ def test_010_can_deallocate_elastic_ip(self):
+ result = self.conn.release_address(self.data['public_ip'])
+ self.assertTrue(result)
+
+ def test_999_tearDown(self):
+ self.delete_key_pair(self.conn, TEST_KEY)
+ if self.data.has_key('instance_id'):
+ self.conn.terminate_instances([data['instance_id']])
+
+
+class VolumeTests(UserSmokeTestCase):
+ def setUp(self):
+ super(VolumeTests, self).setUp()
+ self.device = '/dev/vdb'
+
+ def test_000_setUp(self):
+ self.create_key_pair(self.conn, TEST_KEY)
+ reservation = self.conn.run_instances(FLAGS.test_image,
+ instance_type='m1.tiny',
+ key_name=TEST_KEY)
+ instance = reservation.instances[0]
+ self.data['instance'] = instance
+ for x in xrange(120):
+ if self.can_ping(instance.private_dns_name):
+ break
+ else:
+ self.fail('unable to start instance')
+
+ def test_001_can_create_volume(self):
+ volume = self.conn.create_volume(1, 'nova')
+ self.assertEqual(volume.size, 1)
+ self.data['volume'] = volume
+ # Give network time to find volume.
+ time.sleep(5)
+
+ def test_002_can_attach_volume(self):
+ volume = self.data['volume']
+
+ for x in xrange(10):
+ if volume.status == u'available':
+ break
+ time.sleep(5)
+ volume.update()
+ else:
+ self.fail('cannot attach volume with state %s' % volume.status)
+
+ volume.attach(self.data['instance'].id, self.device)
+
+ # Volumes seems to report "available" too soon.
+ for x in xrange(10):
+ if volume.status == u'in-use':
+ break
+ time.sleep(5)
+ volume.update()
+
+ self.assertEqual(volume.status, u'in-use')
+
+ # Give instance time to recognize volume.
+ time.sleep(5)
+
+ def test_003_can_mount_volume(self):
+ ip = self.data['instance'].private_dns_name
+ conn = self.connect_ssh(ip, TEST_KEY)
+ commands = []
+ commands.append('mkdir -p /mnt/vol')
+ commands.append('mkfs.ext2 %s' % self.device)
+ commands.append('mount %s /mnt/vol' % self.device)
+ commands.append('echo success')
+ stdin, stdout, stderr = conn.exec_command(' && '.join(commands))
+ out = stdout.read()
+ conn.close()
+ if not out.strip().endswith('success'):
+ self.fail('Unable to mount: %s %s' % (out, stderr.read()))
+
+ def test_004_can_write_to_volume(self):
+ ip = self.data['instance'].private_dns_name
+ conn = self.connect_ssh(ip, TEST_KEY)
+ # FIXME(devcamcar): This doesn't fail if the volume hasn't been mounted
+ stdin, stdout, stderr = conn.exec_command(
+ 'echo hello > /mnt/vol/test.txt')
+ err = stderr.read()
+ conn.close()
+ if len(err) > 0:
+ self.fail('Unable to write to mount: %s' % (err))
+
+ def test_005_volume_is_correct_size(self):
+ ip = self.data['instance'].private_dns_name
+ conn = self.connect_ssh(ip, TEST_KEY)
+ stdin, stdout, stderr = conn.exec_command(
+ "df -h | grep %s | awk {'print $2'}" % self.device)
+ out = stdout.read()
+ conn.close()
+ if not out.strip() == '1008M':
+ self.fail('Volume is not the right size: %s %s' %
+ (out, stderr.read()))
+
+ def test_006_me_can_umount_volume(self):
+ ip = self.data['instance'].private_dns_name
+ conn = self.connect_ssh(ip, TEST_KEY)
+ stdin, stdout, stderr = conn.exec_command('umount /mnt/vol')
+ err = stderr.read()
+ conn.close()
+ if len(err) > 0:
+ self.fail('Unable to unmount: %s' % (err))
+
+ def test_007_me_can_detach_volume(self):
+ result = self.conn.detach_volume(volume_id=self.data['volume'].id)
+ self.assertTrue(result)
+ time.sleep(5)
+
+ def test_008_me_can_delete_volume(self):
+ result = self.conn.delete_volume(self.data['volume'].id)
+ self.assertTrue(result)
+
+ def test_999_tearDown(self):
+ self.conn.terminate_instances([self.data['instance'].id])
+ self.conn.delete_key_pair(TEST_KEY)
+
+
+if __name__ == "__main__":
+ suites = {'image': unittest.makeSuite(ImageTests),
+ 'instance': unittest.makeSuite(InstanceTests),
+ 'volume': unittest.makeSuite(VolumeTests)}
+ sys.exit(base.run_tests(suites))