HACKING fixes, all but sqlalchemy.

Looks like this fixes all HACKING problems that were around.
Thanks to Dina Belova and Alexander Kovalev for this work.

Change-Id: I8157f0d4890184c1216aab63ef7180ee8b7a184d
This commit is contained in:
Yuriy Taraday
2012-03-06 12:53:07 +04:00
parent 274259197a
commit cc0dd8d717
28 changed files with 153 additions and 136 deletions

View File

@@ -5,6 +5,7 @@ Adrian Smith <adrian_f_smith@dell.com>
Ahmad Hassan <ahmad.hassan@hp.com> Ahmad Hassan <ahmad.hassan@hp.com>
Alex Meade <alex.meade@rackspace.com> Alex Meade <alex.meade@rackspace.com>
Alexander Sakhnov <asakhnov@mirantis.com> Alexander Sakhnov <asakhnov@mirantis.com>
Alexander Kovalev <akovalev@mirantis.com>
Alvaro Lopez Garcia <aloga@ifca.unican.es> Alvaro Lopez Garcia <aloga@ifca.unican.es>
Andrew Bogott <abogott@wikimedia.org> Andrew Bogott <abogott@wikimedia.org>
Andrew Clay Shafer <acs@parvuscaptus.com> Andrew Clay Shafer <acs@parvuscaptus.com>
@@ -49,6 +50,7 @@ Derek Higgins <derekh@redhat.com>
Devdeep Singh <devdeep.singh@citrix.com> Devdeep Singh <devdeep.singh@citrix.com>
Devendra Modium <dmodium@isi.edu> Devendra Modium <dmodium@isi.edu>
Devin Carlen <devin.carlen@gmail.com> Devin Carlen <devin.carlen@gmail.com>
Dina Belova <dbelova@mirantis.com>
Donal Lafferty <donal.lafferty@citrix.com> Donal Lafferty <donal.lafferty@citrix.com>
Dong-In David Kang <dkang@isi.edu> Dong-In David Kang <dkang@isi.edu>
Doug Hellmann <doug.hellmann@dreamhost.com> Doug Hellmann <doug.hellmann@dreamhost.com>

View File

@@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import nova.exception from nova import exception
from nova import flags from nova import flags
from nova import log as logging from nova import log as logging
from nova.openstack.common import cfg from nova.openstack.common import cfg
@@ -50,7 +50,7 @@ def _get_drivers():
for notification_driver in FLAGS.list_notifier_drivers: for notification_driver in FLAGS.list_notifier_drivers:
try: try:
drivers.append(utils.import_object(notification_driver)) drivers.append(utils.import_object(notification_driver))
except nova.exception.ClassNotFound as e: except exception.ClassNotFound as e:
drivers.append(ImportFailureNotifier(e)) drivers.append(ImportFailureNotifier(e))
return drivers return drivers

View File

@@ -17,9 +17,11 @@
import nova.context import nova.context
from nova import flags from nova import flags
from nova import log as logging
from nova.openstack.common import cfg from nova.openstack.common import cfg
from nova import rpc from nova import rpc
LOG = logging.getLogger(__name__)
notification_topic_opt = cfg.ListOpt('notification_topics', notification_topic_opt = cfg.ListOpt('notification_topics',
default=['notifications', ], default=['notifications', ],

View File

@@ -19,8 +19,7 @@
from nova import flags from nova import flags
from nova.openstack.common import cfg from nova.openstack.common import cfg
from nova.rpc.common import RemoteError, LOG from nova import utils
from nova.utils import import_object
rpc_backend_opt = cfg.StrOpt('rpc_backend', rpc_backend_opt = cfg.StrOpt('rpc_backend',
@@ -199,5 +198,5 @@ def _get_impl():
"""Delay import of rpc_backend until FLAGS are loaded.""" """Delay import of rpc_backend until FLAGS are loaded."""
global _RPCIMPL global _RPCIMPL
if _RPCIMPL is None: if _RPCIMPL is None:
_RPCIMPL = import_object(FLAGS.rpc_backend) _RPCIMPL = utils.import_object(FLAGS.rpc_backend)
return _RPCIMPL return _RPCIMPL

View File

@@ -37,8 +37,10 @@ from nova import context
from nova import exception from nova import exception
from nova import flags from nova import flags
from nova import local from nova import local
from nova import log as logging
import nova.rpc.common as rpc_common import nova.rpc.common as rpc_common
from nova.rpc.common import LOG
LOG = logging.getLogger(__name__)
FLAGS = flags.FLAGS FLAGS = flags.FLAGS

View File

@@ -43,11 +43,12 @@ from nova import context
from nova import exception from nova import exception
from nova import flags from nova import flags
from nova import local from nova import local
from nova import log as logging
from nova.rpc import common as rpc_common from nova.rpc import common as rpc_common
from nova.rpc.common import RemoteError, LOG
from nova.testing import fake from nova.testing import fake
FLAGS = flags.FLAGS FLAGS = flags.FLAGS
LOG = logging.getLogger(__name__)
class Connection(carrot_connection.BrokerConnection, rpc_common.Connection): class Connection(carrot_connection.BrokerConnection, rpc_common.Connection):
@@ -558,7 +559,7 @@ class MulticallWaiter(object):
"""Acks message and sets result.""" """Acks message and sets result."""
message.ack() message.ack()
if data['failure']: if data['failure']:
self._results.put(RemoteError(*data['failure'])) self._results.put(rpc_common.RemoteError(*data['failure']))
elif data.get('ending', False): elif data.get('ending', False):
self._got_ending = True self._got_ending = True
else: else:

View File

@@ -26,11 +26,12 @@ import qpid.messaging
import qpid.messaging.exceptions import qpid.messaging.exceptions
from nova import flags from nova import flags
from nova import log as logging
from nova.openstack.common import cfg from nova.openstack.common import cfg
from nova.rpc import amqp as rpc_amqp from nova.rpc import amqp as rpc_amqp
from nova.rpc import common as rpc_common from nova.rpc import common as rpc_common
from nova.rpc.common import LOG
LOG = logging.getLogger(__name__)
qpid_opts = [ qpid_opts = [
cfg.StrOpt('qpid_hostname', cfg.StrOpt('qpid_hostname',

View File

@@ -29,8 +29,8 @@ from nova import rpc
from nova import utils from nova import utils
from nova.scheduler import driver from nova.scheduler import driver
from nova.scheduler import simple from nova.scheduler import simple
from nova.vsa.api import VsaState
from nova.volume import volume_types from nova.volume import volume_types
from nova.vsa import api as vsa_api
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@@ -297,7 +297,8 @@ class VsaScheduler(simple.SimpleScheduler):
except Exception: except Exception:
LOG.exception(_("Error creating volumes")) LOG.exception(_("Error creating volumes"))
if vsa_id: if vsa_id:
db.vsa_update(context, vsa_id, dict(status=VsaState.FAILED)) db.vsa_update(context, vsa_id,
dict(status=vsa_api.VsaState.FAILED))
for vol in volume_params: for vol in volume_params:
if 'capabilities' in vol: if 'capabilities' in vol:
@@ -351,7 +352,7 @@ class VsaScheduler(simple.SimpleScheduler):
LOG.exception(_("Error creating volume")) LOG.exception(_("Error creating volume"))
if volume_ref['to_vsa_id']: if volume_ref['to_vsa_id']:
db.vsa_update(context, volume_ref['to_vsa_id'], db.vsa_update(context, volume_ref['to_vsa_id'],
dict(status=VsaState.FAILED)) dict(status=vsa_api.VsaState.FAILED))
raise raise
if host: if host:

View File

@@ -132,13 +132,11 @@ class _Win32Colorizer(object):
See _AnsiColorizer docstring. See _AnsiColorizer docstring.
""" """
def __init__(self, stream): def __init__(self, stream):
from win32console import (GetStdHandle, STD_OUT_HANDLE, import win32console as win
FOREGROUND_RED, FOREGROUND_BLUE, red, green, blue, bold = (win.FOREGROUND_RED, win.FOREGROUND_GREEN,
FOREGROUND_GREEN, FOREGROUND_INTENSITY) win.FOREGROUND_BLUE, win.FOREGROUND_INTENSITY)
red, green, blue, bold = (FOREGROUND_RED, FOREGROUND_GREEN,
FOREGROUND_BLUE, FOREGROUND_INTENSITY)
self.stream = stream self.stream = stream
self.screenBuffer = GetStdHandle(STD_OUT_HANDLE) self.screenBuffer = win.GetStdHandle(win.STD_OUT_HANDLE)
self._colors = { self._colors = {
'normal': red | green | blue, 'normal': red | green | blue,
'red': red | bold, 'red': red | bold,

View File

@@ -14,11 +14,12 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from xml.etree.ElementTree import fromstring as xml_to_tree from xml.etree import ElementTree
try: try:
from xml.etree.ElementTree import ParseError ParseError = ElementTree.ParseError
except ImportError: except AttributeError:
from xml.parsers.expat import ExpatError as ParseError from xml.parsers import expat
ParseError = expat.ExpatError
import uuid import uuid
@@ -140,7 +141,7 @@ class NWFilter(object):
self._parse_xml(xml) self._parse_xml(xml)
def _parse_xml(self, xml): def _parse_xml(self, xml):
tree = xml_to_tree(xml) tree = ElementTree.fromstring(xml)
root = tree.find('.') root = tree.find('.')
self._name = root.get('name') self._name = root.get('name')
@@ -162,7 +163,7 @@ class Domain(object):
def _parse_definition(self, xml): def _parse_definition(self, xml):
try: try:
tree = xml_to_tree(xml) tree = ElementTree.fromstring(xml)
except ParseError: except ParseError:
raise libvirtError(VIR_ERR_XML_DETAIL, VIR_FROM_DOMAIN, raise libvirtError(VIR_ERR_XML_DETAIL, VIR_FROM_DOMAIN,
"Invalid XML.") "Invalid XML.")
@@ -300,13 +301,13 @@ class Domain(object):
123456789L] 123456789L]
def attachDevice(self, xml): def attachDevice(self, xml):
disk_info = _parse_disk_info(xml_to_tree(xml)) disk_info = _parse_disk_info(ElementTree.fromstring(xml))
disk_info['_attached'] = True disk_info['_attached'] = True
self._def['devices']['disks'] += [disk_info] self._def['devices']['disks'] += [disk_info]
return True return True
def detachDevice(self, xml): def detachDevice(self, xml):
disk_info = _parse_disk_info(xml_to_tree(xml)) disk_info = _parse_disk_info(ElementTree.fromstring(xml))
disk_info['_attached'] = True disk_info['_attached'] = True
return disk_info in self._def['devices']['disks'] return disk_info in self._def['devices']['disks']
@@ -398,7 +399,7 @@ class Domain(object):
self._state = VIR_DOMAIN_RUNNING self._state = VIR_DOMAIN_RUNNING
def snapshotCreateXML(self, xml, flags): def snapshotCreateXML(self, xml, flags):
tree = xml_to_tree(xml) tree = ElementTree.fromstring(xml)
name = tree.find('./name').text name = tree.find('./name').text
snapshot = DomainSnapshot(name, self) snapshot = DomainSnapshot(name, self)
self._snapshots[name] = snapshot self._snapshots[name] = snapshot
@@ -735,7 +736,7 @@ class Connection(object):
</capabilities>''' </capabilities>'''
def compareCPU(self, xml, flags): def compareCPU(self, xml, flags):
tree = xml_to_tree(xml) tree = ElementTree.fromstring(xml)
arch_node = tree.find('./arch') arch_node = tree.find('./arch')
if arch_node is not None: if arch_node is not None:

View File

@@ -16,7 +16,6 @@
import nova import nova
from nova import log as logging from nova import log as logging
import nova.notifier.api import nova.notifier.api
from nova.notifier.api import notify
import nova.notifier.log_notifier import nova.notifier.log_notifier
import nova.notifier.no_op_notifier import nova.notifier.no_op_notifier
from nova.notifier import list_notifier from nova.notifier import list_notifier
@@ -59,7 +58,7 @@ class NotifierListTestCase(test.TestCase):
self.flags(notification_driver='nova.notifier.list_notifier', self.flags(notification_driver='nova.notifier.list_notifier',
list_notifier_drivers=['nova.notifier.no_op_notifier', list_notifier_drivers=['nova.notifier.no_op_notifier',
'nova.notifier.no_op_notifier']) 'nova.notifier.no_op_notifier'])
notify('publisher_id', 'event_type', nova.notifier.api.notify('publisher_id', 'event_type',
nova.notifier.api.WARN, dict(a=3)) nova.notifier.api.WARN, dict(a=3))
self.assertEqual(self.notify_count, 2) self.assertEqual(self.notify_count, 2)
self.assertEqual(self.exception_count, 0) self.assertEqual(self.exception_count, 0)
@@ -69,7 +68,8 @@ class NotifierListTestCase(test.TestCase):
self.flags(notification_driver='nova.notifier.list_notifier', self.flags(notification_driver='nova.notifier.list_notifier',
list_notifier_drivers=['nova.notifier.no_op_notifier', list_notifier_drivers=['nova.notifier.no_op_notifier',
'nova.notifier.log_notifier']) 'nova.notifier.log_notifier'])
notify('publisher_id', 'event_type', nova.notifier.api.WARN, dict(a=3)) nova.notifier.api.notify('publisher_id',
'event_type', nova.notifier.api.WARN, dict(a=3))
self.assertEqual(self.notify_count, 1) self.assertEqual(self.notify_count, 1)
self.assertEqual(self.exception_count, 1) self.assertEqual(self.exception_count, 1)
@@ -78,6 +78,7 @@ class NotifierListTestCase(test.TestCase):
list_notifier_drivers=['nova.notifier.no_op_notifier', list_notifier_drivers=['nova.notifier.no_op_notifier',
'nova.notifier.logo_notifier', 'nova.notifier.logo_notifier',
'fdsjgsdfhjkhgsfkj']) 'fdsjgsdfhjkhgsfkj'])
notify('publisher_id', 'event_type', nova.notifier.api.WARN, dict(a=3)) nova.notifier.api.notify('publisher_id',
'event_type', nova.notifier.api.WARN, dict(a=3))
self.assertEqual(self.exception_count, 2) self.assertEqual(self.exception_count, 2)
self.assertEqual(self.notify_count, 1) self.assertEqual(self.notify_count, 1)

View File

@@ -25,7 +25,7 @@ import nose
from nova import context from nova import context
from nova import log as logging from nova import log as logging
from nova.rpc.common import RemoteError, Timeout from nova.rpc import common as rpc_common
from nova import test from nova import test
@@ -107,7 +107,7 @@ class _BaseRpcTestCase(test.TestCase):
""" """
value = 42 value = 42
self.assertRaises(RemoteError, self.assertRaises(rpc_common.RemoteError,
self.rpc.call, self.rpc.call,
self.context, self.context,
'test', 'test',
@@ -119,7 +119,7 @@ class _BaseRpcTestCase(test.TestCase):
{"method": "fail", {"method": "fail",
"args": {"value": value}}) "args": {"value": value}})
self.fail("should have thrown RemoteError") self.fail("should have thrown RemoteError")
except RemoteError as exc: except rpc_common.RemoteError as exc:
self.assertEqual(int(exc.value), value) self.assertEqual(int(exc.value), value)
def test_nested_calls(self): def test_nested_calls(self):
@@ -157,7 +157,7 @@ class _BaseRpcTestCase(test.TestCase):
raise nose.SkipTest(_("RPC backend does not support timeouts")) raise nose.SkipTest(_("RPC backend does not support timeouts"))
value = 42 value = 42
self.assertRaises(Timeout, self.assertRaises(rpc_common.Timeout,
self.rpc.call, self.rpc.call,
self.context, self.context,
'test', 'test',
@@ -170,7 +170,7 @@ class _BaseRpcTestCase(test.TestCase):
"args": {"value": value}}, "args": {"value": value}},
timeout=1) timeout=1)
self.fail("should have thrown Timeout") self.fail("should have thrown Timeout")
except Timeout as exc: except rpc_common.Timeout as exc:
pass pass

View File

@@ -17,7 +17,7 @@
from nova import exception from nova import exception
from nova import log as logging from nova import log as logging
from nova.volume.san import SolidFireSanISCSIDriver as SFID from nova.volume import san
from nova import test from nova import test
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@@ -90,19 +90,21 @@ class SolidFireVolumeTestCase(test.TestCase):
'id': 1} 'id': 1}
def test_create_volume(self): def test_create_volume(self):
SFID._issue_api_request = self.fake_issue_api_request self.stubs.Set(san.SolidFireSanISCSIDriver, '_issue_api_request',
self.fake_issue_api_request)
testvol = {'project_id': 'testprjid', testvol = {'project_id': 'testprjid',
'name': 'testvol', 'name': 'testvol',
'size': 1} 'size': 1}
sfv = SFID() sfv = san.SolidFireSanISCSIDriver()
model_update = sfv.create_volume(testvol) model_update = sfv.create_volume(testvol)
def test_create_volume_fails(self): def test_create_volume_fails(self):
SFID._issue_api_request = self.fake_issue_api_request_fails self.stubs.Set(san.SolidFireSanISCSIDriver, '_issue_api_request',
self.fake_issue_api_request_fails)
testvol = {'project_id': 'testprjid', testvol = {'project_id': 'testprjid',
'name': 'testvol', 'name': 'testvol',
'size': 1} 'size': 1}
sfv = SFID() sfv = san.SolidFireSanISCSIDriver()
try: try:
sfv.create_volume(testvol) sfv.create_volume(testvol)
self.fail("Should have thrown Error") self.fail("Should have thrown Error")
@@ -110,43 +112,49 @@ class SolidFireVolumeTestCase(test.TestCase):
pass pass
def test_create_sfaccount(self): def test_create_sfaccount(self):
sfv = SFID() sfv = san.SolidFireSanISCSIDriver()
SFID._issue_api_request = self.fake_issue_api_request self.stubs.Set(san.SolidFireSanISCSIDriver, '_issue_api_request',
self.fake_issue_api_request)
account = sfv._create_sfaccount('project-id') account = sfv._create_sfaccount('project-id')
self.assertNotEqual(account, None) self.assertNotEqual(account, None)
def test_create_sfaccount_fails(self): def test_create_sfaccount_fails(self):
sfv = SFID() sfv = san.SolidFireSanISCSIDriver()
SFID._issue_api_request = self.fake_issue_api_request_fails self.stubs.Set(san.SolidFireSanISCSIDriver, '_issue_api_request',
self.fake_issue_api_request_fails)
account = sfv._create_sfaccount('project-id') account = sfv._create_sfaccount('project-id')
self.assertEqual(account, None) self.assertEqual(account, None)
def test_get_sfaccount_by_name(self): def test_get_sfaccount_by_name(self):
sfv = SFID() sfv = san.SolidFireSanISCSIDriver()
SFID._issue_api_request = self.fake_issue_api_request self.stubs.Set(san.SolidFireSanISCSIDriver, '_issue_api_request',
self.fake_issue_api_request)
account = sfv._get_sfaccount_by_name('some-name') account = sfv._get_sfaccount_by_name('some-name')
self.assertNotEqual(account, None) self.assertNotEqual(account, None)
def test_get_sfaccount_by_name_fails(self): def test_get_sfaccount_by_name_fails(self):
sfv = SFID() sfv = san.SolidFireSanISCSIDriver()
SFID._issue_api_request = self.fake_issue_api_request_fails self.stubs.Set(san.SolidFireSanISCSIDriver, '_issue_api_request',
self.fake_issue_api_request_fails)
account = sfv._get_sfaccount_by_name('some-name') account = sfv._get_sfaccount_by_name('some-name')
self.assertEqual(account, None) self.assertEqual(account, None)
def test_delete_volume(self): def test_delete_volume(self):
SFID._issue_api_request = self.fake_issue_api_request self.stubs.Set(san.SolidFireSanISCSIDriver, '_issue_api_request',
self.fake_issue_api_request)
testvol = {'project_id': 'testprjid', testvol = {'project_id': 'testprjid',
'name': 'test_volume', 'name': 'test_volume',
'size': 1} 'size': 1}
sfv = SFID() sfv = san.SolidFireSanISCSIDriver()
model_update = sfv.delete_volume(testvol) model_update = sfv.delete_volume(testvol)
def test_delete_volume_fails_no_volume(self): def test_delete_volume_fails_no_volume(self):
SFID._issue_api_request = self.fake_issue_api_request self.stubs.Set(san.SolidFireSanISCSIDriver, '_issue_api_request',
self.fake_issue_api_request)
testvol = {'project_id': 'testprjid', testvol = {'project_id': 'testprjid',
'name': 'no-name', 'name': 'no-name',
'size': 1} 'size': 1}
sfv = SFID() sfv = san.SolidFireSanISCSIDriver()
try: try:
model_update = sfv.delete_volume(testvol) model_update = sfv.delete_volume(testvol)
self.fail("Should have thrown Error") self.fail("Should have thrown Error")
@@ -154,22 +162,25 @@ class SolidFireVolumeTestCase(test.TestCase):
pass pass
def test_delete_volume_fails_account_lookup(self): def test_delete_volume_fails_account_lookup(self):
SFID._issue_api_request = self.fake_issue_api_request self.stubs.Set(san.SolidFireSanISCSIDriver, '_issue_api_request',
self.fake_issue_api_request)
testvol = {'project_id': 'testprjid', testvol = {'project_id': 'testprjid',
'name': 'no-name', 'name': 'no-name',
'size': 1} 'size': 1}
sfv = SFID() sfv = san.SolidFireSanISCSIDriver()
self.assertRaises(exception.DuplicateSfVolumeNames, self.assertRaises(exception.DuplicateSfVolumeNames,
sfv.delete_volume, sfv.delete_volume,
testvol) testvol)
def test_get_cluster_info(self): def test_get_cluster_info(self):
SFID._issue_api_request = self.fake_issue_api_request self.stubs.Set(san.SolidFireSanISCSIDriver, '_issue_api_request',
sfv = SFID() self.fake_issue_api_request)
sfv = san.SolidFireSanISCSIDriver()
sfv._get_cluster_info() sfv._get_cluster_info()
def test_get_cluster_info_fail(self): def test_get_cluster_info_fail(self):
SFID._issue_api_request = self.fake_issue_api_request_fails self.stubs.Set(san.SolidFireSanISCSIDriver, '_issue_api_request',
sfv = SFID() self.fake_issue_api_request_fails)
sfv = san.SolidFireSanISCSIDriver()
self.assertRaises(exception.SolidFireAPIException, self.assertRaises(exception.SolidFireAPIException,
sfv._get_cluster_info) sfv._get_cluster_info)

View File

@@ -18,13 +18,14 @@
"""Unit tests for the API endpoint""" """Unit tests for the API endpoint"""
import boto
from boto.ec2 import regioninfo
from boto.exception import EC2ResponseError
import datetime import datetime
import httplib import httplib
import random import random
import StringIO import StringIO
import boto
from boto.ec2 import regioninfo
from boto import exception as boto_exc
import webob import webob
from nova import block_device from nova import block_device
@@ -271,8 +272,8 @@ class ApiEc2TestCase(test.TestCase):
"""Attempt to terminate an invalid instance""" """Attempt to terminate an invalid instance"""
self.expect_http() self.expect_http()
self.mox.ReplayAll() self.mox.ReplayAll()
self.assertRaises(EC2ResponseError, self.ec2.terminate_instances, self.assertRaises(boto_exc.EC2ResponseError,
"i-00000005") self.ec2.terminate_instances, "i-00000005")
def test_get_all_key_pairs(self): def test_get_all_key_pairs(self):
"""Test that, after creating a user and project and generating """Test that, after creating a user and project and generating
@@ -300,7 +301,7 @@ class ApiEc2TestCase(test.TestCase):
try: try:
self.ec2.create_key_pair('test') self.ec2.create_key_pair('test')
except EC2ResponseError, e: except boto_exc.EC2ResponseError, e:
if e.code == 'KeyPairExists': if e.code == 'KeyPairExists':
pass pass
else: else:
@@ -352,8 +353,10 @@ class ApiEc2TestCase(test.TestCase):
# dashes, and underscores. # dashes, and underscores.
security_group_name = "aa #^% -=99" security_group_name = "aa #^% -=99"
self.assertRaises(EC2ResponseError, self.ec2.create_security_group, self.assertRaises(boto_exc.EC2ResponseError,
security_group_name, 'test group') self.ec2.create_security_group,
security_group_name,
'test group')
def test_group_name_valid_length_security_group(self): def test_group_name_valid_length_security_group(self):
"""Test that we sanely handle invalid security group names. """Test that we sanely handle invalid security group names.
@@ -365,8 +368,10 @@ class ApiEc2TestCase(test.TestCase):
security_group_name = "".join(random.choice("poiuytrewqasdfghjklmnbvc") security_group_name = "".join(random.choice("poiuytrewqasdfghjklmnbvc")
for x in range(random.randint(256, 266))) for x in range(random.randint(256, 266)))
self.assertRaises(EC2ResponseError, self.ec2.create_security_group, self.assertRaises(boto_exc.EC2ResponseError,
security_group_name, 'test group') self.ec2.create_security_group,
security_group_name,
'test group')
def test_authorize_revoke_security_group_cidr(self): def test_authorize_revoke_security_group_cidr(self):
""" """
@@ -393,7 +398,7 @@ class ApiEc2TestCase(test.TestCase):
def _assert(message, *args): def _assert(message, *args):
try: try:
group.authorize(*args) group.authorize(*args)
except EC2ResponseError as e: except boto_exc.EC2ResponseError as e:
self.assertEqual(e.status, 400, 'Expected status to be 400') self.assertEqual(e.status, 400, 'Expected status to be 400')
self.assertIn(message, e.error_message, e.error_message) self.assertIn(message, e.error_message, e.error_message)
else: else:
@@ -569,7 +574,7 @@ class ApiEc2TestCase(test.TestCase):
# Can not delete the group while it is still used by # Can not delete the group while it is still used by
# another group. # another group.
self.assertRaises(EC2ResponseError, self.assertRaises(boto_exc.EC2ResponseError,
self.ec2.delete_security_group, self.ec2.delete_security_group,
other_security_group_name) other_security_group_name)

View File

@@ -29,7 +29,7 @@ import webob.exc
import nova import nova
import nova.common.policy import nova.common.policy
from nova import compute from nova import compute
import nova.compute.api from nova.compute import api as compute_api
from nova.compute import aggregate_states from nova.compute import aggregate_states
from nova.compute import instance_types from nova.compute import instance_types
from nova.compute import manager as compute_manager from nova.compute import manager as compute_manager
@@ -1419,7 +1419,7 @@ class ComputeTestCase(BaseTestCase):
# start test # start test
self.mox.ReplayAll() self.mox.ReplayAll()
self.assertRaises(rpc.RemoteError, self.assertRaises(rpc_common.RemoteError,
self.compute.live_migration, self.compute.live_migration,
c, instance_id, inst_ref['host'], True) c, instance_id, inst_ref['host'], True)
@@ -3316,7 +3316,7 @@ class ComputeAPIAggrTestCase(test.TestCase):
def setUp(self): def setUp(self):
super(ComputeAPIAggrTestCase, self).setUp() super(ComputeAPIAggrTestCase, self).setUp()
self.api = compute.AggregateAPI() self.api = compute_api.AggregateAPI()
self.context = context.get_admin_context() self.context = context.get_admin_context()
self.stubs.Set(rpc, 'call', fake_rpc_method) self.stubs.Set(rpc, 'call', fake_rpc_method)
self.stubs.Set(rpc, 'cast', fake_rpc_method) self.stubs.Set(rpc, 'cast', fake_rpc_method)

View File

@@ -16,7 +16,7 @@
from nova import test from nova import test
from xml.etree.ElementTree import fromstring as xml_to_tree from xml.etree import ElementTree
import fakelibvirt as libvirt import fakelibvirt as libvirt
@@ -252,7 +252,7 @@ class FakeLibvirtTests(test.TestCase):
conn.defineXML(get_vm_xml()) conn.defineXML(get_vm_xml())
dom = conn.lookupByName('testname') dom = conn.lookupByName('testname')
xml = dom.XMLDesc(0) xml = dom.XMLDesc(0)
xml_to_tree(xml) ElementTree.fromstring(xml)
def _test_accepts_source_type(self, source_type): def _test_accepts_source_type(self, source_type):
conn = self.get_openAuth_curry_func()('qemu:///system') conn = self.get_openAuth_curry_func()('qemu:///system')
@@ -260,7 +260,7 @@ class FakeLibvirtTests(test.TestCase):
conn.defineXML(get_vm_xml(source_type=source_type)) conn.defineXML(get_vm_xml(source_type=source_type))
dom = conn.lookupByName('testname') dom = conn.lookupByName('testname')
xml = dom.XMLDesc(0) xml = dom.XMLDesc(0)
tree = xml_to_tree(xml) tree = ElementTree.fromstring(xml)
elem = tree.find('./devices/disk/source') elem = tree.find('./devices/disk/source')
self.assertEquals(elem.get('file'), '/somefile') self.assertEquals(elem.get('file'), '/somefile')
@@ -282,7 +282,7 @@ class FakeLibvirtTests(test.TestCase):
conn.defineXML(get_vm_xml(interface_type=network_type)) conn.defineXML(get_vm_xml(interface_type=network_type))
dom = conn.lookupByName('testname') dom = conn.lookupByName('testname')
xml = dom.XMLDesc(0) xml = dom.XMLDesc(0)
tree = xml_to_tree(xml) tree = ElementTree.fromstring(xml)
elem = tree.find('./devices/interface') elem = tree.find('./devices/interface')
self.assertEquals(elem.get('type'), network_type) self.assertEquals(elem.get('type'), network_type)
elem = elem.find('./source') elem = elem.find('./source')
@@ -298,7 +298,7 @@ class FakeLibvirtTests(test.TestCase):
def test_getCapabilities(self): def test_getCapabilities(self):
conn = self.get_openAuth_curry_func()('qemu:///system') conn = self.get_openAuth_curry_func()('qemu:///system')
xml_to_tree(conn.getCapabilities()) ElementTree.fromstring(conn.getCapabilities())
def test_nwfilter_define_undefine(self): def test_nwfilter_define_undefine(self):
conn = self.get_openAuth_curry_func()('qemu:///system') conn = self.get_openAuth_curry_func()('qemu:///system')

View File

@@ -24,8 +24,8 @@ from nova import flags
from nova import log as logging from nova import log as logging
from nova import test from nova import test
from nova.compute import instance_types from nova.compute import instance_types
from nova.db.sqlalchemy.session import get_session
from nova.db.sqlalchemy import models from nova.db.sqlalchemy import models
from nova.db.sqlalchemy import session as sql_session
FLAGS = flags.FLAGS FLAGS = flags.FLAGS
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@@ -90,7 +90,7 @@ class InstanceTypeTestCase(test.TestCase):
def test_get_all_instance_types(self): def test_get_all_instance_types(self):
"""Ensures that all instance types can be retrieved""" """Ensures that all instance types can be retrieved"""
session = get_session() session = sql_session.get_session()
total_instance_types = session.query(models.InstanceTypes).count() total_instance_types = session.query(models.InstanceTypes).count()
inst_types = instance_types.get_all_types() inst_types = instance_types.get_all_types()
self.assertEqual(total_instance_types, len(inst_types)) self.assertEqual(total_instance_types, len(inst_types))

View File

@@ -23,8 +23,8 @@ import shutil
import sys import sys
import tempfile import tempfile
from xml.etree.ElementTree import fromstring as xml_to_tree from xml.etree import ElementTree
from xml.dom.minidom import parseString as xml_to_dom from xml.dom import minidom
from nova import context from nova import context
from nova import db from nova import db
@@ -149,7 +149,7 @@ class LibvirtVolumeTestCase(test.TestCase):
connection_info = vol_driver.initialize_connection(vol, self.connr) connection_info = vol_driver.initialize_connection(vol, self.connr)
mount_device = "vde" mount_device = "vde"
xml = libvirt_driver.connect_volume(connection_info, mount_device) xml = libvirt_driver.connect_volume(connection_info, mount_device)
tree = xml_to_tree(xml) tree = ElementTree.fromstring(xml)
dev_str = '/dev/disk/by-path/ip-%s-iscsi-%s-lun-0' % (location, iqn) dev_str = '/dev/disk/by-path/ip-%s-iscsi-%s-lun-0' % (location, iqn)
self.assertEqual(tree.get('type'), 'block') self.assertEqual(tree.get('type'), 'block')
self.assertEqual(tree.find('./source').get('dev'), dev_str) self.assertEqual(tree.find('./source').get('dev'), dev_str)
@@ -188,7 +188,7 @@ class LibvirtVolumeTestCase(test.TestCase):
connection_info = vol_driver.initialize_connection(vol, self.connr) connection_info = vol_driver.initialize_connection(vol, self.connr)
mount_device = "vde" mount_device = "vde"
xml = libvirt_driver.connect_volume(connection_info, mount_device) xml = libvirt_driver.connect_volume(connection_info, mount_device)
tree = xml_to_tree(xml) tree = ElementTree.fromstring(xml)
dev_str = '/dev/disk/by-path/ip-%s-iscsi-%s-lun-0' % (location, iqn) dev_str = '/dev/disk/by-path/ip-%s-iscsi-%s-lun-0' % (location, iqn)
self.assertEqual(tree.get('type'), 'block') self.assertEqual(tree.get('type'), 'block')
self.assertEqual(tree.find('./source').get('dev'), dev_str) self.assertEqual(tree.find('./source').get('dev'), dev_str)
@@ -211,7 +211,7 @@ class LibvirtVolumeTestCase(test.TestCase):
connection_info = vol_driver.initialize_connection(vol, self.connr) connection_info = vol_driver.initialize_connection(vol, self.connr)
mount_device = "vde" mount_device = "vde"
xml = libvirt_driver.connect_volume(connection_info, mount_device) xml = libvirt_driver.connect_volume(connection_info, mount_device)
tree = xml_to_tree(xml) tree = ElementTree.fromstring(xml)
self.assertEqual(tree.get('type'), 'network') self.assertEqual(tree.get('type'), 'network')
self.assertEqual(tree.find('./source').get('protocol'), 'sheepdog') self.assertEqual(tree.find('./source').get('protocol'), 'sheepdog')
self.assertEqual(tree.find('./source').get('name'), name) self.assertEqual(tree.find('./source').get('name'), name)
@@ -226,7 +226,7 @@ class LibvirtVolumeTestCase(test.TestCase):
connection_info = vol_driver.initialize_connection(vol, self.connr) connection_info = vol_driver.initialize_connection(vol, self.connr)
mount_device = "vde" mount_device = "vde"
xml = libvirt_driver.connect_volume(connection_info, mount_device) xml = libvirt_driver.connect_volume(connection_info, mount_device)
tree = xml_to_tree(xml) tree = ElementTree.fromstring(xml)
self.assertEqual(tree.get('type'), 'network') self.assertEqual(tree.get('type'), 'network')
self.assertEqual(tree.find('./source').get('protocol'), 'rbd') self.assertEqual(tree.find('./source').get('protocol'), 'rbd')
rbd_name = '%s/%s' % (FLAGS.rbd_pool, name) rbd_name = '%s/%s' % (FLAGS.rbd_pool, name)
@@ -248,7 +248,7 @@ class LibvirtVolumeTestCase(test.TestCase):
connection_info = vol_driver.initialize_connection(vol, self.connr) connection_info = vol_driver.initialize_connection(vol, self.connr)
mount_device = "vde" mount_device = "vde"
xml = libvirt_driver.connect_volume(connection_info, mount_device) xml = libvirt_driver.connect_volume(connection_info, mount_device)
tree = xml_to_tree(xml) tree = ElementTree.fromstring(xml)
dev_str = '/dev/disk/by-path/ip-%s-iscsi-%s-lun-0' % (location, iqn) dev_str = '/dev/disk/by-path/ip-%s-iscsi-%s-lun-0' % (location, iqn)
self.assertEqual(tree.get('type'), 'block') self.assertEqual(tree.get('type'), 'block')
self.assertEqual(tree.find('./source').get('dev'), dev_str) self.assertEqual(tree.find('./source').get('dev'), dev_str)
@@ -716,7 +716,7 @@ class LibvirtConnTestCase(test.TestCase):
conn = connection.LibvirtConnection(True) conn = connection.LibvirtConnection(True)
instance_ref = db.instance_create(self.context, instance_data) instance_ref = db.instance_create(self.context, instance_data)
xml = conn.to_xml(instance_ref, network_info, None, False) xml = conn.to_xml(instance_ref, network_info, None, False)
tree = xml_to_tree(xml) tree = ElementTree.fromstring(xml)
interfaces = tree.findall("./devices/interface") interfaces = tree.findall("./devices/interface")
self.assertEquals(len(interfaces), 2) self.assertEquals(len(interfaces), 2)
parameters = interfaces[0].findall('./filterref/parameter') parameters = interfaces[0].findall('./filterref/parameter')
@@ -738,7 +738,7 @@ class LibvirtConnTestCase(test.TestCase):
network_info = _fake_network_info(self.stubs, 1) network_info = _fake_network_info(self.stubs, 1)
xml = conn.to_xml(instance_ref, network_info) xml = conn.to_xml(instance_ref, network_info)
tree = xml_to_tree(xml) tree = ElementTree.fromstring(xml)
check = [ check = [
(lambda t: t.find('.').get('type'), 'lxc'), (lambda t: t.find('.').get('type'), 'lxc'),
@@ -779,7 +779,7 @@ class LibvirtConnTestCase(test.TestCase):
network_info = _fake_network_info(self.stubs, 1) network_info = _fake_network_info(self.stubs, 1)
xml = conn.to_xml(instance_ref, network_info) xml = conn.to_xml(instance_ref, network_info)
tree = xml_to_tree(xml) tree = ElementTree.fromstring(xml)
for i, (check, expected_result) in enumerate(checks): for i, (check, expected_result) in enumerate(checks):
self.assertEqual(check(tree), self.assertEqual(check(tree),
@@ -795,7 +795,7 @@ class LibvirtConnTestCase(test.TestCase):
xml = connection.LibvirtConnection(True).to_xml(instance_ref, xml = connection.LibvirtConnection(True).to_xml(instance_ref,
network_info, network_info,
image_meta) image_meta)
tree = xml_to_tree(xml) tree = ElementTree.fromstring(xml)
self.assertEqual(tree.find('./devices/disk').get('device'), self.assertEqual(tree.find('./devices/disk').get('device'),
device_type) device_type)
self.assertEqual(tree.find('./devices/disk/target').get('bus'), bus) self.assertEqual(tree.find('./devices/disk/target').get('bus'), bus)
@@ -808,7 +808,7 @@ class LibvirtConnTestCase(test.TestCase):
xml = connection.LibvirtConnection(True).to_xml(instance_ref, xml = connection.LibvirtConnection(True).to_xml(instance_ref,
network_info, network_info,
image_meta) image_meta)
tree = xml_to_tree(xml) tree = ElementTree.fromstring(xml)
self.assertEqual(tree.find('./uuid').text, self.assertEqual(tree.find('./uuid').text,
instance_ref['uuid']) instance_ref['uuid'])
@@ -894,7 +894,7 @@ class LibvirtConnTestCase(test.TestCase):
network_info = _fake_network_info(self.stubs, 1) network_info = _fake_network_info(self.stubs, 1)
xml = conn.to_xml(instance_ref, network_info, None, rescue) xml = conn.to_xml(instance_ref, network_info, None, rescue)
tree = xml_to_tree(xml) tree = ElementTree.fromstring(xml)
for i, (check, expected_result) in enumerate(checks): for i, (check, expected_result) in enumerate(checks):
self.assertEqual(check(tree), self.assertEqual(check(tree),
expected_result, expected_result,
@@ -1352,7 +1352,7 @@ class NWFilterFakes:
def undefine(self): def undefine(self):
del self.parent.filters[self.name] del self.parent.filters[self.name]
pass pass
tree = xml_to_tree(xml) tree = ElementTree.fromstring(xml)
name = tree.get('name') name = tree.get('name')
if name not in self.filters: if name not in self.filters:
self.filters[name] = FakeNWFilterInternal(self, name) self.filters[name] = FakeNWFilterInternal(self, name)
@@ -1772,7 +1772,7 @@ class NWFilterTestCase(test.TestCase):
self.recursive_depends[f] = [] self.recursive_depends[f] = []
def _filterDefineXMLMock(xml): def _filterDefineXMLMock(xml):
dom = xml_to_dom(xml) dom = minidom.parseString(xml)
name = dom.firstChild.getAttribute('name') name = dom.firstChild.getAttribute('name')
self.recursive_depends[name] = [] self.recursive_depends[name] = []
for f in dom.getElementsByTagName('filterref'): for f in dom.getElementsByTagName('filterref'):

View File

@@ -20,12 +20,8 @@ from nova import flags
from nova import test from nova import test
from nova import utils from nova import utils
from nova.virt import firewall from nova.virt import firewall
from nova.virt import vif from nova.virt.libvirt import vif
from nova.virt.libvirt import connection from nova.virt.libvirt import connection
from nova.virt.libvirt.vif import LibvirtBridgeDriver, \
LibvirtOpenVswitchDriver, \
LibvirtOpenVswitchVirtualPortDriver, \
QuantumLinuxBridgeVIFDriver
FLAGS = flags.FLAGS FLAGS = flags.FLAGS
@@ -101,7 +97,7 @@ class LibvirtVifTestCase(test.TestCase):
return xml return xml
def test_bridge_driver(self): def test_bridge_driver(self):
d = LibvirtBridgeDriver() d = vif.LibvirtBridgeDriver()
xml = self._get_instance_xml(d, 'bridge') xml = self._get_instance_xml(d, 'bridge')
doc = ElementTree.fromstring(xml) doc = ElementTree.fromstring(xml)
@@ -117,7 +113,7 @@ class LibvirtVifTestCase(test.TestCase):
d.unplug(None, self.net, self.mapping) d.unplug(None, self.net, self.mapping)
def test_ovs_ethernet_driver(self): def test_ovs_ethernet_driver(self):
d = LibvirtOpenVswitchDriver() d = vif.LibvirtOpenVswitchDriver()
xml = self._get_instance_xml(d, 'ethernet') xml = self._get_instance_xml(d, 'ethernet')
doc = ElementTree.fromstring(xml) doc = ElementTree.fromstring(xml)
@@ -135,7 +131,7 @@ class LibvirtVifTestCase(test.TestCase):
d.unplug(None, self.net, self.mapping) d.unplug(None, self.net, self.mapping)
def test_ovs_virtualport_driver(self): def test_ovs_virtualport_driver(self):
d = LibvirtOpenVswitchVirtualPortDriver() d = vif.LibvirtOpenVswitchVirtualPortDriver()
xml = self._get_instance_xml(d, 'ovs_virtualport') xml = self._get_instance_xml(d, 'ovs_virtualport')
doc = ElementTree.fromstring(xml) doc = ElementTree.fromstring(xml)
@@ -161,7 +157,7 @@ class LibvirtVifTestCase(test.TestCase):
d.unplug(None, self.net, self.mapping) d.unplug(None, self.net, self.mapping)
def test_quantum_bridge_ethernet_driver(self): def test_quantum_bridge_ethernet_driver(self):
d = QuantumLinuxBridgeVIFDriver() d = vif.QuantumLinuxBridgeVIFDriver()
xml = self._get_instance_xml(d, 'ethernet') xml = self._get_instance_xml(d, 'ethernet')
doc = ElementTree.fromstring(xml) doc = ElementTree.fromstring(xml)

View File

@@ -33,7 +33,7 @@ import urlparse
import migrate import migrate
from migrate.versioning import util as migrate_util from migrate.versioning import util as migrate_util
from sqlalchemy import create_engine import sqlalchemy
import nova.db.sqlalchemy.migrate_repo import nova.db.sqlalchemy.migrate_repo
from nova import log as logging from nova import log as logging
@@ -68,7 +68,7 @@ if USE_MIGRATE_PATCH:
# NOTE(jkoelker) Delay importing migrate until we are patched # NOTE(jkoelker) Delay importing migrate until we are patched
from migrate.versioning import api as migration_api from migrate.versioning import api as migration_api
from migrate.versioning.repository import Repository from migrate.versioning import repository
class TestMigrations(unittest.TestCase): class TestMigrations(unittest.TestCase):
@@ -82,7 +82,8 @@ class TestMigrations(unittest.TestCase):
CONFIG_FILE_PATH = os.environ.get('NOVA_TEST_MIGRATIONS_CONF', CONFIG_FILE_PATH = os.environ.get('NOVA_TEST_MIGRATIONS_CONF',
DEFAULT_CONFIG_FILE) DEFAULT_CONFIG_FILE)
MIGRATE_FILE = nova.db.sqlalchemy.migrate_repo.__file__ MIGRATE_FILE = nova.db.sqlalchemy.migrate_repo.__file__
REPOSITORY = Repository(os.path.abspath(os.path.dirname(MIGRATE_FILE))) REPOSITORY = repository.Repository(
os.path.abspath(os.path.dirname(MIGRATE_FILE)))
def setUp(self): def setUp(self):
super(TestMigrations, self).setUp() super(TestMigrations, self).setUp()
@@ -108,7 +109,7 @@ class TestMigrations(unittest.TestCase):
self.engines = {} self.engines = {}
for key, value in TestMigrations.TEST_DATABASES.items(): for key, value in TestMigrations.TEST_DATABASES.items():
self.engines[key] = create_engine(value) self.engines[key] = sqlalchemy.create_engine(value)
# We start each test case with a completely blank slate. # We start each test case with a completely blank slate.
self._reset_databases() self._reset_databases()

View File

@@ -27,7 +27,7 @@ from lxml import etree
from nova import log as logging from nova import log as logging
from nova import test from nova import test
from nova.volume.netapp import NetAppISCSIDriver from nova.volume import netapp
LOG = logging.getLogger("nova.volume.driver") LOG = logging.getLogger("nova.volume.driver")
@@ -898,7 +898,7 @@ class NetAppDriverTestCase(test.TestCase):
def setUp(self): def setUp(self):
super(NetAppDriverTestCase, self).setUp() super(NetAppDriverTestCase, self).setUp()
driver = NetAppISCSIDriver() driver = netapp.NetAppISCSIDriver()
self.stubs.Set(httplib, 'HTTPConnection', FakeHTTPConnection) self.stubs.Set(httplib, 'HTTPConnection', FakeHTTPConnection)
driver._create_client('http://localhost:8088/dfm.wsdl', driver._create_client('http://localhost:8088/dfm.wsdl',
'root', 'password', 'localhost', 8088) 'root', 'password', 'localhost', 8088)

View File

@@ -14,10 +14,9 @@
# under the License. # under the License.
import nova import nova
import nova.notifier.no_op_notifier
from nova import log from nova import log
import nova.notifier.api import nova.notifier.no_op_notifier
from nova.notifier.api import notify from nova.notifier import api as notifier_api
from nova import test from nova import test
@@ -36,7 +35,7 @@ class NotifierTestCase(test.TestCase):
self.stubs.Set(nova.notifier.no_op_notifier, 'notify', self.stubs.Set(nova.notifier.no_op_notifier, 'notify',
mock_notify) mock_notify)
notify('publisher_id', 'event_type', notifier_api.notify('publisher_id', 'event_type',
nova.notifier.api.WARN, dict(a=3)) nova.notifier.api.WARN, dict(a=3))
self.assertEqual(self.notify_called, True) self.assertEqual(self.notify_called, True)
@@ -56,7 +55,7 @@ class NotifierTestCase(test.TestCase):
self.stubs.Set(nova.notifier.no_op_notifier, 'notify', self.stubs.Set(nova.notifier.no_op_notifier, 'notify',
message_assert) message_assert)
notify('publisher_id', 'event_type', notifier_api.notify('publisher_id', 'event_type',
nova.notifier.api.WARN, dict(a=3)) nova.notifier.api.WARN, dict(a=3))
def test_send_rabbit_notification(self): def test_send_rabbit_notification(self):
@@ -68,14 +67,14 @@ class NotifierTestCase(test.TestCase):
self.mock_notify = True self.mock_notify = True
self.stubs.Set(nova.rpc, 'notify', mock_notify) self.stubs.Set(nova.rpc, 'notify', mock_notify)
notify('publisher_id', 'event_type', notifier_api.notify('publisher_id', 'event_type',
nova.notifier.api.WARN, dict(a=3)) nova.notifier.api.WARN, dict(a=3))
self.assertEqual(self.mock_notify, True) self.assertEqual(self.mock_notify, True)
def test_invalid_priority(self): def test_invalid_priority(self):
self.assertRaises(nova.notifier.api.BadPriorityException, self.assertRaises(nova.notifier.api.BadPriorityException,
notify, 'publisher_id', notifier_api.notify, 'publisher_id',
'event_type', 'not a priority', dict(a=3)) 'event_type', 'not a priority', dict(a=3))
def test_rabbit_priority_queue(self): def test_rabbit_priority_queue(self):
@@ -90,7 +89,7 @@ class NotifierTestCase(test.TestCase):
self.test_topic = topic self.test_topic = topic
self.stubs.Set(nova.rpc, 'notify', mock_notify) self.stubs.Set(nova.rpc, 'notify', mock_notify)
notify('publisher_id', 'event_type', 'DEBUG', dict(a=3)) notifier_api.notify('publisher_id', 'event_type', 'DEBUG', dict(a=3))
self.assertEqual(self.test_topic, 'testnotify.debug') self.assertEqual(self.test_topic, 'testnotify.debug')
def test_error_notification(self): def test_error_notification(self):

View File

@@ -20,7 +20,7 @@ import mox
from nova import context from nova import context
from nova import db from nova import db
from nova.db.sqlalchemy import models from nova.db.sqlalchemy import models
from nova.db.sqlalchemy.session import get_session from nova.db.sqlalchemy import session as sql_session
from nova import exception from nova import exception
from nova import flags from nova import flags
from nova import log as logging from nova import log as logging
@@ -198,7 +198,7 @@ class QuantumNovaTestCase(test.TestCase):
# habit of of creating fixed IPs and not cleaning up, which # habit of of creating fixed IPs and not cleaning up, which
# can confuse these tests, so we remove all existing fixed # can confuse these tests, so we remove all existing fixed
# ips before starting. # ips before starting.
session = get_session() session = sql_session.get_session()
result = session.query(models.FixedIp).all() result = session.query(models.FixedIp).all()
with session.begin(): with session.begin():
for fip_ref in result: for fip_ref in result:

View File

@@ -24,7 +24,7 @@ from nova import flags
from nova import log as logging from nova import log as logging
from nova import test from nova import test
from nova.volume import volume_types from nova.volume import volume_types
from nova.db.sqlalchemy.session import get_session from nova.db.sqlalchemy import session as sql_session
from nova.db.sqlalchemy import models from nova.db.sqlalchemy import models
FLAGS = flags.FLAGS FLAGS = flags.FLAGS
@@ -75,7 +75,7 @@ class VolumeTypeTestCase(test.TestCase):
def test_get_all_volume_types(self): def test_get_all_volume_types(self):
"""Ensures that all volume types can be retrieved""" """Ensures that all volume types can be retrieved"""
session = get_session() session = sql_session.get_session()
total_volume_types = session.query(models.VolumeTypes).count() total_volume_types = session.query(models.VolumeTypes).count()
vol_types = volume_types.get_all_types(self.ctxt) vol_types = volume_types.get_all_types(self.ctxt)
self.assertEqual(total_volume_types, len(vol_types)) self.assertEqual(total_volume_types, len(vol_types))

View File

@@ -36,7 +36,7 @@ class VsaTestCase(test.TestCase):
def setUp(self): def setUp(self):
super(VsaTestCase, self).setUp() super(VsaTestCase, self).setUp()
self.vsa_api = vsa.API() self.vsa_api = vsa.api.API()
self.flags(quota_volumes=100, quota_gigabytes=10000) self.flags(quota_volumes=100, quota_gigabytes=10000)

View File

@@ -15,7 +15,7 @@
from nova import exception from nova import exception
from nova import flags from nova import flags
from nova import vsa from nova.vsa import api as vsa_api
from nova import volume from nova import volume
from nova import context from nova import context
from nova import test from nova import test
@@ -30,7 +30,7 @@ class VsaVolumesTestCase(test.TestCase):
def setUp(self): def setUp(self):
super(VsaVolumesTestCase, self).setUp() super(VsaVolumesTestCase, self).setUp()
self.vsa_api = vsa.API() self.vsa_api = vsa_api.API()
self.volume_api = volume.API() self.volume_api = volume.API()
self.context = context.get_admin_context() self.context = context.get_admin_context()

View File

@@ -14,5 +14,3 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from nova.vsa.api import API

View File

@@ -29,11 +29,10 @@ from nova import log as logging
from nova import manager from nova import manager
from nova.openstack.common import cfg from nova.openstack.common import cfg
from nova import volume from nova import volume
from nova import vsa
from nova import utils from nova import utils
from nova.compute import instance_types from nova.compute import instance_types
from nova.vsa import utils as vsa_utils from nova.vsa import utils as vsa_utils
from nova.vsa.api import VsaState from nova.vsa import api as vsa_api
vsa_driver_opt = cfg.StrOpt('vsa_driver', vsa_driver_opt = cfg.StrOpt('vsa_driver',
default='nova.vsa.connection.get_connection', default='nova.vsa.connection.get_connection',
@@ -56,7 +55,7 @@ class VsaManager(manager.SchedulerDependentManager):
self.compute_api = compute.API() self.compute_api = compute.API()
self.volume_api = volume.API() self.volume_api = volume.API()
self.vsa_api = vsa.API() self.vsa_api = vsa_api.API()
if FLAGS.vsa_ec2_user_id is None or FLAGS.vsa_ec2_access_key is None: if FLAGS.vsa_ec2_user_id is None or FLAGS.vsa_ec2_access_key is None:
raise exception.VSANovaAccessParamNotFound() raise exception.VSANovaAccessParamNotFound()
@@ -122,9 +121,9 @@ class VsaManager(manager.SchedulerDependentManager):
"""Start VCs for VSA """ """Start VCs for VSA """
vsa_id = vsa['id'] vsa_id = vsa['id']
if vsa['status'] == VsaState.CREATING: if vsa['status'] == vsa_api.VsaState.CREATING:
self.vsa_api.update_vsa_status(context, vsa_id, self.vsa_api.update_vsa_status(context, vsa_id,
VsaState.LAUNCHING) vsa_api.VsaState.LAUNCHING)
else: else:
return return
@@ -153,7 +152,7 @@ class VsaManager(manager.SchedulerDependentManager):
LOG.info(_("VSA ID %(vsa_id)d: Delete all BE volumes"), locals()) LOG.info(_("VSA ID %(vsa_id)d: Delete all BE volumes"), locals())
self.vsa_api.delete_vsa_volumes(context, vsa_id, "BE", True) self.vsa_api.delete_vsa_volumes(context, vsa_id, "BE", True)
self.vsa_api.update_vsa_status(context, vsa_id, self.vsa_api.update_vsa_status(context, vsa_id,
VsaState.FAILED) vsa_api.VsaState.FAILED)
return return
# create user-data record for VC # create user-data record for VC
@@ -179,4 +178,4 @@ class VsaManager(manager.SchedulerDependentManager):
metadata=dict(vsa_id=str(vsa_id))) metadata=dict(vsa_id=str(vsa_id)))
self.vsa_api.update_vsa_status(context, vsa_id, self.vsa_api.update_vsa_status(context, vsa_id,
VsaState.CREATED) vsa_api.VsaState.CREATED)