summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVishvananda Ishaya <vishvananda@yahoo.com>2010-10-12 20:16:23 -0700
committerVishvananda Ishaya <vishvananda@yahoo.com>2010-10-12 20:16:23 -0700
commit36cb0de8905917b0d6789e49eaecd722319458f8 (patch)
tree67f8479ee4b293b4ff825387707dd6ca4a6a82bb
parent7ba0ab1e22b0453024b0b85be80d4e4544f95943 (diff)
parentd533d6414041437e642f2bbfbc7a86daa2527a65 (diff)
downloadnova-36cb0de8905917b0d6789e49eaecd722319458f8.tar.gz
nova-36cb0de8905917b0d6789e49eaecd722319458f8.tar.xz
nova-36cb0de8905917b0d6789e49eaecd722319458f8.zip
merged upstream
-rw-r--r--nova/test.py4
-rw-r--r--nova/tests/cloud_unittest.py4
-rw-r--r--nova/tests/network_unittest.py3
-rw-r--r--nova/tests/virt_unittest.py16
-rw-r--r--nova/virt/libvirt_conn.py3
5 files changed, 21 insertions, 9 deletions
diff --git a/nova/test.py b/nova/test.py
index 5cf2abd53..f6485377d 100644
--- a/nova/test.py
+++ b/nova/test.py
@@ -24,6 +24,7 @@ and some black magic for inline callbacks.
import sys
import time
+import datetime
import mox
import stubout
@@ -62,6 +63,7 @@ class TrialTestCase(unittest.TestCase):
# NOTE(vish): We need a better method for creating fixtures for tests
# now that we have some required db setup for the system
# to work properly.
+ self.start = datetime.datetime.utcnow()
if db.network_count(None) != 5:
network_manager.VlanManager().create_networks(None,
FLAGS.fixed_range,
@@ -84,6 +86,8 @@ class TrialTestCase(unittest.TestCase):
self.stubs.UnsetAll()
self.stubs.SmartUnsetAll()
self.mox.VerifyAll()
+ # NOTE(vish): Clean up any ips associated during the test.
+ db.fixed_ip_disassociate_all_by_timeout(None, FLAGS.host, self.start)
db.network_disassociate_all(None)
rpc.Consumer.attach_to_twisted = self.originalAttach
for x in self.injected:
diff --git a/nova/tests/cloud_unittest.py b/nova/tests/cloud_unittest.py
index 8e5881edb..a880237f2 100644
--- a/nova/tests/cloud_unittest.py
+++ b/nova/tests/cloud_unittest.py
@@ -64,12 +64,12 @@ class CloudTestCase(test.TrialTestCase):
self.cloud = cloud.CloudController()
# set up a service
- self.compute = utils.import_class(FLAGS.compute_manager)()
+ self.compute = utils.import_object(FLAGS.compute_manager)
self.compute_consumer = rpc.AdapterConsumer(connection=self.conn,
topic=FLAGS.compute_topic,
proxy=self.compute)
self.compute_consumer.attach_to_eventlet()
- self.network = utils.import_class(FLAGS.network_manager)()
+ self.network = utils.import_object(FLAGS.network_manager)
self.network_consumer = rpc.AdapterConsumer(connection=self.conn,
topic=FLAGS.network_topic,
proxy=self.network)
diff --git a/nova/tests/network_unittest.py b/nova/tests/network_unittest.py
index c81f93bb3..3afb4d19e 100644
--- a/nova/tests/network_unittest.py
+++ b/nova/tests/network_unittest.py
@@ -58,7 +58,8 @@ class NetworkTestCase(test.TrialTestCase):
user_context = context.APIRequestContext(project=self.projects[i],
user=self.user)
network_ref = self.network.get_network(user_context)
- self.network.set_network_host(user_context, network_ref['id'])
+ self.network.set_network_host(context.get_admin_context(),
+ network_ref['id'])
instance_ref = self._create_instance(0)
self.instance_id = instance_ref['id']
instance_ref = self._create_instance(1)
diff --git a/nova/tests/virt_unittest.py b/nova/tests/virt_unittest.py
index 684347473..edcdba425 100644
--- a/nova/tests/virt_unittest.py
+++ b/nova/tests/virt_unittest.py
@@ -20,21 +20,22 @@ from xml.dom.minidom import parseString as xml_to_dom
from nova import db
from nova import flags
from nova import test
+from nova import utils
from nova.api import context
from nova.api.ec2 import cloud
from nova.auth import manager
-
-# Needed to get FLAGS.instances_path defined:
-from nova.compute import manager as compute_manager
from nova.virt import libvirt_conn
FLAGS = flags.FLAGS
+flags.DECLARE('instances_path', 'nova.compute.manager')
class LibvirtConnTestCase(test.TrialTestCase):
def setUp(self):
+ super(LibvirtConnTestCase, self).setUp()
self.manager = manager.AuthManager()
self.user = self.manager.create_user('fake', 'fake', 'fake', admin=True)
self.project = self.manager.create_project('fake', 'fake', 'fake')
+ self.network = utils.import_object(FLAGS.network_manager)
FLAGS.instances_path = ''
def test_get_uri_and_template(self):
@@ -51,11 +52,15 @@ class LibvirtConnTestCase(test.TrialTestCase):
'instance_type' : 'm1.small'}
instance_ref = db.instance_create(None, instance)
- network_ref = db.project_get_network(None, self.project.id)
+ user_context = context.APIRequestContext(project=self.project,
+ user=self.user)
+ network_ref = self.network.get_network(user_context)
+ self.network.set_network_host(context.get_admin_context(),
+ network_ref['id'])
fixed_ip = { 'address' : ip,
'network_id' : network_ref['id'] }
-
+
fixed_ip_ref = db.fixed_ip_create(None, fixed_ip)
db.fixed_ip_update(None, ip, { 'allocated' : True,
'instance_id' : instance_ref['id'] })
@@ -113,6 +118,7 @@ class LibvirtConnTestCase(test.TrialTestCase):
def tearDown(self):
+ super(LibvirtConnTestCase, self).tearDown()
self.manager.delete_project(self.project)
self.manager.delete_user(self.user)
diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py
index 6ef5aa472..94a36a530 100644
--- a/nova/virt/libvirt_conn.py
+++ b/nova/virt/libvirt_conn.py
@@ -320,7 +320,8 @@ class LibvirtConnection(object):
def to_xml(self, instance):
# TODO(termie): cache?
logging.debug('instance %s: starting toXML method', instance['name'])
- network = db.instance_get_fixed_by_instance(None, inst['id'])
+ network = db.project_get_network(None,
+ instance['project_id'])
# FIXME(vish): stick this in db
instance_type = instance_types.INSTANCE_TYPES[instance['instance_type']]
ip_address = db.instance_get_fixed_address({}, instance['id'])