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:
parent
d8324bb3d0
commit
01a938f7fe
2
Authors
2
Authors
@ -5,6 +5,7 @@ Adrian Smith <adrian_f_smith@dell.com>
|
||||
Ahmad Hassan <ahmad.hassan@hp.com>
|
||||
Alex Meade <alex.meade@rackspace.com>
|
||||
Alexander Sakhnov <asakhnov@mirantis.com>
|
||||
Alexander Kovalev <akovalev@mirantis.com>
|
||||
Alvaro Lopez Garcia <aloga@ifca.unican.es>
|
||||
Andrew Bogott <abogott@wikimedia.org>
|
||||
Andrew Clay Shafer <acs@parvuscaptus.com>
|
||||
@ -49,6 +50,7 @@ Derek Higgins <derekh@redhat.com>
|
||||
Devdeep Singh <devdeep.singh@citrix.com>
|
||||
Devendra Modium <dmodium@isi.edu>
|
||||
Devin Carlen <devin.carlen@gmail.com>
|
||||
Dina Belova <dbelova@mirantis.com>
|
||||
Donal Lafferty <donal.lafferty@citrix.com>
|
||||
Dong-In David Kang <dkang@isi.edu>
|
||||
Doug Hellmann <doug.hellmann@dreamhost.com>
|
||||
|
@ -28,10 +28,11 @@ import time
|
||||
import urllib
|
||||
|
||||
from nova.api.ec2 import ec2utils
|
||||
from nova.compute import instance_types
|
||||
from nova.api.ec2 import inst_state
|
||||
from nova.api import validator
|
||||
from nova import block_device
|
||||
from nova import compute
|
||||
from nova.compute import instance_types
|
||||
from nova.compute import vm_states
|
||||
from nova import crypto
|
||||
from nova import db
|
||||
@ -40,10 +41,9 @@ from nova import flags
|
||||
from nova.image import s3
|
||||
from nova import log as logging
|
||||
from nova import network
|
||||
from nova import rpc
|
||||
from nova.rpc import common as rpc_common
|
||||
from nova import utils
|
||||
from nova import volume
|
||||
from nova.api import validator
|
||||
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
@ -1215,7 +1215,7 @@ class CloudController(object):
|
||||
try:
|
||||
public_ip = self.network_api.allocate_floating_ip(context)
|
||||
return {'publicIp': public_ip}
|
||||
except rpc.RemoteError as ex:
|
||||
except rpc_common.RemoteError as ex:
|
||||
# NOTE(tr3buchet) - why does this block exist?
|
||||
if ex.exc_type == 'NoMoreFloatingIps':
|
||||
raise exception.NoMoreFloatingIps()
|
||||
|
@ -20,7 +20,7 @@ from webob import exc
|
||||
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api.openstack import xmlutil
|
||||
from nova import console
|
||||
from nova.console import api as console_api
|
||||
from nova import exception
|
||||
|
||||
|
||||
@ -83,7 +83,7 @@ class Controller(object):
|
||||
"""The Consoles controller for the Openstack API"""
|
||||
|
||||
def __init__(self):
|
||||
self.console_api = console.API()
|
||||
self.console_api = console_api.API()
|
||||
|
||||
@wsgi.serializers(xml=ConsolesTemplate)
|
||||
def index(self, req, server_id):
|
||||
|
@ -18,11 +18,10 @@
|
||||
from webob import exc
|
||||
|
||||
from nova.api.openstack import extensions
|
||||
from nova import compute
|
||||
from nova.compute import api as compute_api
|
||||
from nova import exception
|
||||
from nova import log as logging
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
authorize = extensions.extension_authorizer('compute', 'aggregates')
|
||||
|
||||
@ -45,7 +44,7 @@ def get_host_from_body(fn):
|
||||
class AggregateController(object):
|
||||
"""The Host Aggregates API controller for the OpenStack API."""
|
||||
def __init__(self):
|
||||
self.api = compute.AggregateAPI()
|
||||
self.api = compute_api.AggregateAPI()
|
||||
|
||||
def index(self, req):
|
||||
"""Returns a list a host aggregate's id, name, availability_zone."""
|
||||
|
@ -26,7 +26,7 @@ from nova import compute
|
||||
from nova import exception
|
||||
from nova import log as logging
|
||||
from nova import network
|
||||
from nova import rpc
|
||||
from nova.rpc import common as rpc_common
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -152,7 +152,7 @@ class FloatingIPController(object):
|
||||
try:
|
||||
address = self.network_api.allocate_floating_ip(context, pool)
|
||||
ip = self.network_api.get_floating_ip_by_address(context, address)
|
||||
except rpc.RemoteError as ex:
|
||||
except rpc_common.RemoteError as ex:
|
||||
# NOTE(tr3buchet) - why does this block exist?
|
||||
if ex.exc_type == 'NoMoreFloatingIps':
|
||||
if pool:
|
||||
@ -212,7 +212,7 @@ class FloatingIPActionController(wsgi.Controller):
|
||||
except exception.FixedIpNotFoundForInstance:
|
||||
msg = _("No fixed ips associated to instance")
|
||||
raise webob.exc.HTTPBadRequest(explanation=msg)
|
||||
except rpc.RemoteError:
|
||||
except rpc_common.RemoteError:
|
||||
msg = _("Associate floating ip failed")
|
||||
raise webob.exc.HTTPInternalServerError(explanation=msg)
|
||||
|
||||
|
@ -22,7 +22,7 @@ from xml.parsers import expat
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api.openstack import xmlutil
|
||||
from nova.api.openstack import extensions
|
||||
from nova import compute
|
||||
from nova.compute import api as compute_api
|
||||
from nova import db
|
||||
from nova import exception
|
||||
from nova import flags
|
||||
@ -120,7 +120,7 @@ def check_host(fn):
|
||||
class HostController(object):
|
||||
"""The Hosts API controller for the OpenStack API."""
|
||||
def __init__(self):
|
||||
self.api = compute.HostAPI()
|
||||
self.api = compute_api.HostAPI()
|
||||
super(HostController, self).__init__()
|
||||
|
||||
@wsgi.serializers(xml=HostIndexTemplate)
|
||||
|
@ -72,12 +72,12 @@ class SimpleTenantUsageController(object):
|
||||
terminated_at = instance['terminated_at']
|
||||
if terminated_at is not None:
|
||||
if not isinstance(terminated_at, datetime.datetime):
|
||||
terminated_at = datetime.strptime(terminated_at,
|
||||
terminated_at = datetime.datetime.strptime(terminated_at,
|
||||
"%Y-%m-%d %H:%M:%S.%f")
|
||||
|
||||
if launched_at is not None:
|
||||
if not isinstance(launched_at, datetime.datetime):
|
||||
launched_at = datetime.strptime(launched_at,
|
||||
launched_at = datetime.datetime.strptime(launched_at,
|
||||
"%Y-%m-%d %H:%M:%S.%f")
|
||||
|
||||
if terminated_at and terminated_at < period_start:
|
||||
|
@ -33,7 +33,7 @@ from nova import network
|
||||
from nova import exception
|
||||
from nova import flags
|
||||
from nova import log as logging
|
||||
from nova import vsa
|
||||
from nova.vsa import api as vsa_api
|
||||
from nova import volume
|
||||
|
||||
|
||||
@ -114,7 +114,7 @@ class VsaController(object):
|
||||
"""The Virtual Storage Array API controller for the OpenStack API."""
|
||||
|
||||
def __init__(self):
|
||||
self.vsa_api = vsa.API()
|
||||
self.vsa_api = vsa_api.API()
|
||||
self.compute_api = compute.API()
|
||||
self.network_api = network.API()
|
||||
super(VsaController, self).__init__()
|
||||
@ -271,7 +271,7 @@ class VsaVolumeDriveController(volumes.VolumeController):
|
||||
|
||||
def __init__(self):
|
||||
self.volume_api = volume.API()
|
||||
self.vsa_api = vsa.API()
|
||||
self.vsa_api = vsa_api.API()
|
||||
super(VsaVolumeDriveController, self).__init__()
|
||||
|
||||
def _translation(self, context, vol, vsa_id, details):
|
||||
@ -565,7 +565,7 @@ class VsaVPoolController(object):
|
||||
"""The vPool VSA API controller for the OpenStack API."""
|
||||
|
||||
def __init__(self):
|
||||
self.vsa_api = vsa.API()
|
||||
self.vsa_api = vsa_api.API()
|
||||
super(VsaVPoolController, self).__init__()
|
||||
|
||||
@wsgi.serializers(xml=VsaVPoolsTemplate)
|
||||
@ -594,7 +594,7 @@ class VsaVCController(servers.Controller):
|
||||
"""The VSA Virtual Controller API controller for the OpenStack API."""
|
||||
|
||||
def __init__(self):
|
||||
self.vsa_api = vsa.API()
|
||||
self.vsa_api = vsa_api.API()
|
||||
self.compute_api = compute.API()
|
||||
self.vsa_id = None # VP-TODO: temporary ugly hack
|
||||
super(VsaVCController, self).__init__()
|
||||
|
@ -16,8 +16,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from nova.compute.api import AggregateAPI
|
||||
from nova.compute.api import HostAPI
|
||||
# Importing full names to not pollute the namespace and cause possible
|
||||
# collisions with use of 'from nova.compute import <foo>' elsewhere.
|
||||
import nova.flags
|
||||
|
@ -10,4 +10,3 @@
|
||||
multitenant VM console access
|
||||
.. moduleauthor:: Monsyne Dragon <mdragon@rackspace.com>
|
||||
"""
|
||||
from nova.console.api import API
|
||||
|
@ -13,7 +13,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import nova.exception
|
||||
from nova import exception
|
||||
from nova import flags
|
||||
from nova import log as logging
|
||||
from nova.openstack.common import cfg
|
||||
@ -50,7 +50,7 @@ def _get_drivers():
|
||||
for notification_driver in FLAGS.list_notifier_drivers:
|
||||
try:
|
||||
drivers.append(utils.import_object(notification_driver))
|
||||
except nova.exception.ClassNotFound as e:
|
||||
except exception.ClassNotFound as e:
|
||||
drivers.append(ImportFailureNotifier(e))
|
||||
return drivers
|
||||
|
||||
|
@ -17,9 +17,11 @@
|
||||
import nova.context
|
||||
|
||||
from nova import flags
|
||||
from nova import log as logging
|
||||
from nova.openstack.common import cfg
|
||||
from nova import rpc
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
notification_topic_opt = cfg.ListOpt('notification_topics',
|
||||
default=['notifications', ],
|
||||
|
@ -19,8 +19,7 @@
|
||||
|
||||
from nova import flags
|
||||
from nova.openstack.common import cfg
|
||||
from nova.rpc.common import RemoteError, LOG
|
||||
from nova.utils import import_object
|
||||
from nova import utils
|
||||
|
||||
|
||||
rpc_backend_opt = cfg.StrOpt('rpc_backend',
|
||||
@ -199,5 +198,5 @@ def _get_impl():
|
||||
"""Delay import of rpc_backend until FLAGS are loaded."""
|
||||
global _RPCIMPL
|
||||
if _RPCIMPL is None:
|
||||
_RPCIMPL = import_object(FLAGS.rpc_backend)
|
||||
_RPCIMPL = utils.import_object(FLAGS.rpc_backend)
|
||||
return _RPCIMPL
|
||||
|
@ -37,8 +37,10 @@ from nova import context
|
||||
from nova import exception
|
||||
from nova import flags
|
||||
from nova import local
|
||||
from nova import log as logging
|
||||
import nova.rpc.common as rpc_common
|
||||
from nova.rpc.common import LOG
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
|
@ -43,11 +43,12 @@ from nova import context
|
||||
from nova import exception
|
||||
from nova import flags
|
||||
from nova import local
|
||||
from nova import log as logging
|
||||
from nova.rpc import common as rpc_common
|
||||
from nova.rpc.common import RemoteError, LOG
|
||||
from nova.testing import fake
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Connection(carrot_connection.BrokerConnection, rpc_common.Connection):
|
||||
@ -558,7 +559,7 @@ class MulticallWaiter(object):
|
||||
"""Acks message and sets result."""
|
||||
message.ack()
|
||||
if data['failure']:
|
||||
self._results.put(RemoteError(*data['failure']))
|
||||
self._results.put(rpc_common.RemoteError(*data['failure']))
|
||||
elif data.get('ending', False):
|
||||
self._got_ending = True
|
||||
else:
|
||||
|
@ -26,11 +26,12 @@ import qpid.messaging
|
||||
import qpid.messaging.exceptions
|
||||
|
||||
from nova import flags
|
||||
from nova import log as logging
|
||||
from nova.openstack.common import cfg
|
||||
from nova.rpc import amqp as rpc_amqp
|
||||
from nova.rpc import common as rpc_common
|
||||
from nova.rpc.common import LOG
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
qpid_opts = [
|
||||
cfg.StrOpt('qpid_hostname',
|
||||
|
@ -31,6 +31,7 @@ from nova import flags
|
||||
from nova import log as logging
|
||||
from nova.openstack.common import cfg
|
||||
from nova import rpc
|
||||
from nova.rpc import common as rpc_common
|
||||
from nova import utils
|
||||
|
||||
|
||||
@ -366,7 +367,7 @@ class Scheduler(object):
|
||||
{"method": 'compare_cpu',
|
||||
"args": {'cpu_info': oservice_ref['cpu_info']}})
|
||||
|
||||
except rpc.RemoteError:
|
||||
except rpc_common.RemoteError:
|
||||
src = instance_ref['host']
|
||||
LOG.exception(_("host %(dest)s is not compatible with "
|
||||
"original host %(src)s.") % locals())
|
||||
@ -457,7 +458,7 @@ class Scheduler(object):
|
||||
{"method": 'get_instance_disk_info',
|
||||
"args": {'instance_name': instance_ref['name']}})
|
||||
disk_infos = utils.loads(ret)
|
||||
except rpc.RemoteError:
|
||||
except rpc_common.RemoteError:
|
||||
LOG.exception(_("host %(dest)s is not compatible with "
|
||||
"original host %(src)s.") % locals())
|
||||
raise
|
||||
|
@ -29,8 +29,8 @@ from nova import rpc
|
||||
from nova import utils
|
||||
from nova.scheduler import driver
|
||||
from nova.scheduler import simple
|
||||
from nova.vsa.api import VsaState
|
||||
from nova.volume import volume_types
|
||||
from nova.vsa import api as vsa_api
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -297,7 +297,8 @@ class VsaScheduler(simple.SimpleScheduler):
|
||||
except Exception:
|
||||
LOG.exception(_("Error creating volumes"))
|
||||
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:
|
||||
if 'capabilities' in vol:
|
||||
@ -351,7 +352,7 @@ class VsaScheduler(simple.SimpleScheduler):
|
||||
LOG.exception(_("Error creating volume"))
|
||||
if 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
|
||||
|
||||
if host:
|
||||
|
@ -132,13 +132,11 @@ class _Win32Colorizer(object):
|
||||
See _AnsiColorizer docstring.
|
||||
"""
|
||||
def __init__(self, stream):
|
||||
from win32console import (GetStdHandle, STD_OUT_HANDLE,
|
||||
FOREGROUND_RED, FOREGROUND_BLUE,
|
||||
FOREGROUND_GREEN, FOREGROUND_INTENSITY)
|
||||
red, green, blue, bold = (FOREGROUND_RED, FOREGROUND_GREEN,
|
||||
FOREGROUND_BLUE, FOREGROUND_INTENSITY)
|
||||
import win32console as win
|
||||
red, green, blue, bold = (win.FOREGROUND_RED, win.FOREGROUND_GREEN,
|
||||
win.FOREGROUND_BLUE, win.FOREGROUND_INTENSITY)
|
||||
self.stream = stream
|
||||
self.screenBuffer = GetStdHandle(STD_OUT_HANDLE)
|
||||
self.screenBuffer = win.GetStdHandle(win.STD_OUT_HANDLE)
|
||||
self._colors = {
|
||||
'normal': red | green | blue,
|
||||
'red': red | bold,
|
||||
|
@ -27,7 +27,7 @@ from nova import flags
|
||||
from nova import test
|
||||
from nova import utils
|
||||
|
||||
from xml.etree.ElementTree import fromstring as xml_to_tree
|
||||
from xml.etree import ElementTree
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
|
||||
@ -108,7 +108,7 @@ class ExecutorTestCase(test.TestCase):
|
||||
return self.executor(fake_wsgi_request)
|
||||
|
||||
def _extract_message(self, result):
|
||||
tree = xml_to_tree(result.body)
|
||||
tree = ElementTree.fromstring(result.body)
|
||||
return tree.findall('./Errors')[0].find('Error/Message').text
|
||||
|
||||
def test_instance_not_found(self):
|
||||
|
@ -21,7 +21,7 @@ import webob
|
||||
|
||||
from nova import test
|
||||
from nova.api.openstack.compute.contrib import accounts
|
||||
from nova.auth.manager import User
|
||||
from nova.auth import manager as auth_manager
|
||||
from nova.tests.api.openstack import fakes
|
||||
|
||||
|
||||
@ -42,8 +42,8 @@ class AccountsTest(test.TestCase):
|
||||
fakes.stub_out_auth(self.stubs)
|
||||
|
||||
fakemgr = fakes.FakeAuthManager()
|
||||
joeuser = User('id1', 'guy1', 'acc1', 'secret1', False)
|
||||
superuser = User('id2', 'guy2', 'acc2', 'secret2', True)
|
||||
joeuser = auth_manager.User('id1', 'guy1', 'acc1', 'secret1', False)
|
||||
superuser = auth_manager.User('id2', 'guy2', 'acc2', 'secret2', True)
|
||||
fakemgr.add_user(joeuser)
|
||||
fakemgr.add_user(superuser)
|
||||
fakemgr.create_project('test1', joeuser)
|
||||
|
@ -23,6 +23,7 @@ from nova import db
|
||||
from nova import network
|
||||
from nova import compute
|
||||
from nova import rpc
|
||||
from nova.rpc import common as rpc_common
|
||||
from nova import test
|
||||
from nova.tests import fake_network
|
||||
from nova.tests.api.openstack import fakes
|
||||
@ -204,7 +205,7 @@ class FloatingIpTest(test.TestCase):
|
||||
# test floating ip allocate/release(deallocate)
|
||||
def test_floating_ip_allocate_no_free_ips(self):
|
||||
def fake_call(*args, **kwargs):
|
||||
raise(rpc.RemoteError('NoMoreFloatingIps', '', ''))
|
||||
raise(rpc_common.RemoteError('NoMoreFloatingIps', '', ''))
|
||||
|
||||
self.stubs.Set(rpc, "call", fake_call)
|
||||
|
||||
|
@ -19,16 +19,16 @@ import json
|
||||
from lxml import etree
|
||||
import webob
|
||||
|
||||
from nova.api.openstack.compute.contrib import (virtual_storage_arrays as
|
||||
vsa_ext)
|
||||
from nova.api.openstack.compute.contrib import virtual_storage_arrays as \
|
||||
vsa_ext
|
||||
import nova.db
|
||||
from nova import exception
|
||||
from nova import flags
|
||||
from nova import log as logging
|
||||
from nova import test
|
||||
from nova.tests.api.openstack import fakes
|
||||
from nova import volume
|
||||
from nova import vsa
|
||||
from nova.volume import api as volume_api
|
||||
from nova.vsa import api as vsa_api
|
||||
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
@ -99,10 +99,10 @@ class VSAApiTest(test.TestCase):
|
||||
fakes.stub_out_networking(self.stubs)
|
||||
fakes.stub_out_rate_limiting(self.stubs)
|
||||
fakes.stub_out_auth(self.stubs)
|
||||
self.stubs.Set(vsa.api.API, "create", stub_vsa_create)
|
||||
self.stubs.Set(vsa.api.API, "delete", stub_vsa_delete)
|
||||
self.stubs.Set(vsa.api.API, "get", stub_vsa_get)
|
||||
self.stubs.Set(vsa.api.API, "get_all", stub_vsa_get_all)
|
||||
self.stubs.Set(vsa_api.API, "create", stub_vsa_create)
|
||||
self.stubs.Set(vsa_api.API, "delete", stub_vsa_delete)
|
||||
self.stubs.Set(vsa_api.API, "get", stub_vsa_get)
|
||||
self.stubs.Set(vsa_api.API, "get_all", stub_vsa_get_all)
|
||||
|
||||
def test_vsa_create(self):
|
||||
global last_param
|
||||
@ -239,19 +239,19 @@ class VSAVolumeApiTest(test.TestCase):
|
||||
fakes.stub_out_rate_limiting(self.stubs)
|
||||
fakes.stub_out_auth(self.stubs)
|
||||
self.stubs.Set(nova.db, 'vsa_get', return_vsa)
|
||||
self.stubs.Set(vsa.api.API, "get_vsa_volume_type",
|
||||
self.stubs.Set(vsa_api.API, "get_vsa_volume_type",
|
||||
stub_get_vsa_volume_type)
|
||||
|
||||
self.stubs.Set(volume.api.API, "update", fakes.stub_volume_update)
|
||||
self.stubs.Set(volume.api.API, "delete", fakes.stub_volume_delete)
|
||||
self.stubs.Set(volume.api.API, "get", fakes.stub_volume_get)
|
||||
self.stubs.Set(volume.api.API, "get_all", fakes.stub_volume_get_all)
|
||||
self.stubs.Set(volume_api.API, "update", fakes.stub_volume_update)
|
||||
self.stubs.Set(volume_api.API, "delete", fakes.stub_volume_delete)
|
||||
self.stubs.Set(volume_api.API, "get", fakes.stub_volume_get)
|
||||
self.stubs.Set(volume_api.API, "get_all", fakes.stub_volume_get_all)
|
||||
|
||||
self.test_obj = test_obj if test_obj else "volume"
|
||||
self.test_objs = test_objs if test_objs else "volumes"
|
||||
|
||||
def test_vsa_volume_create(self):
|
||||
self.stubs.Set(volume.api.API, "create", fakes.stub_volume_create)
|
||||
self.stubs.Set(volume_api.API, "create", fakes.stub_volume_create)
|
||||
|
||||
vol = {"size": 100,
|
||||
"displayName": "VSA Volume Test Name",
|
||||
@ -314,7 +314,7 @@ class VSAVolumeApiTest(test.TestCase):
|
||||
self.assertEqual(resp.status_int, 400)
|
||||
|
||||
def test_vsa_volume_show_no_volume(self):
|
||||
self.stubs.Set(volume.api.API, "get", fakes.stub_volume_get_notfound)
|
||||
self.stubs.Set(volume_api.API, "get", fakes.stub_volume_get_notfound)
|
||||
|
||||
req = webob.Request.blank('/v2/fake/zadr-vsa/123/%s/333' %
|
||||
self.test_objs)
|
||||
@ -357,7 +357,7 @@ class VSAVolumeApiTest(test.TestCase):
|
||||
self.assertEqual(resp.status_int, 400)
|
||||
|
||||
def test_vsa_volume_delete_no_volume(self):
|
||||
self.stubs.Set(volume.api.API, "get", fakes.stub_volume_get_notfound)
|
||||
self.stubs.Set(volume_api.API, "get", fakes.stub_volume_get_notfound)
|
||||
|
||||
req = webob.Request.blank('/v2/fake/zadr-vsa/123/%s/333' %
|
||||
self.test_objs)
|
||||
|
@ -18,9 +18,9 @@
|
||||
import json
|
||||
|
||||
from lxml import etree
|
||||
import webob
|
||||
import webob.exc
|
||||
import webob.dec
|
||||
from webob import Request
|
||||
|
||||
import nova.context
|
||||
from nova import test
|
||||
@ -84,7 +84,7 @@ class APITest(test.TestCase):
|
||||
|
||||
#api.application = raise_webob_exc
|
||||
api = self._wsgi_app(raise_webob_exc)
|
||||
resp = Request.blank('/').get_response(api)
|
||||
resp = webob.Request.blank('/').get_response(api)
|
||||
self.assertEqual(resp.status_int, 404, resp.body)
|
||||
|
||||
def test_exceptions_are_converted_to_faults_api_fault(self):
|
||||
@ -95,7 +95,7 @@ class APITest(test.TestCase):
|
||||
|
||||
#api.application = raise_api_fault
|
||||
api = self._wsgi_app(raise_api_fault)
|
||||
resp = Request.blank('/').get_response(api)
|
||||
resp = webob.Request.blank('/').get_response(api)
|
||||
self.assertTrue('itemNotFound' in resp.body, resp.body)
|
||||
self.assertEqual(resp.status_int, 404, resp.body)
|
||||
|
||||
@ -106,7 +106,7 @@ class APITest(test.TestCase):
|
||||
|
||||
#api.application = fail
|
||||
api = self._wsgi_app(fail)
|
||||
resp = Request.blank('/').get_response(api)
|
||||
resp = webob.Request.blank('/').get_response(api)
|
||||
self.assertTrue('{"computeFault' in resp.body, resp.body)
|
||||
self.assertEqual(resp.status_int, 500, resp.body)
|
||||
|
||||
@ -117,7 +117,7 @@ class APITest(test.TestCase):
|
||||
|
||||
#api.application = fail
|
||||
api = self._wsgi_app(fail)
|
||||
resp = Request.blank('/.xml').get_response(api)
|
||||
resp = webob.Request.blank('/.xml').get_response(api)
|
||||
self.assertTrue('<computeFault' in resp.body, resp.body)
|
||||
self.assertEqual(resp.status_int, 500, resp.body)
|
||||
|
||||
|
@ -141,7 +141,7 @@ class ConsolesControllerTest(test.TestCase):
|
||||
def fake_create_console(cons_self, context, instance_id):
|
||||
self.assertEqual(instance_id, self.uuid)
|
||||
return {}
|
||||
self.stubs.Set(console.API, 'create_console', fake_create_console)
|
||||
self.stubs.Set(console.api.API, 'create_console', fake_create_console)
|
||||
|
||||
req = fakes.HTTPRequest.blank(self.url)
|
||||
self.controller.create(req, self.uuid)
|
||||
@ -162,7 +162,7 @@ class ConsolesControllerTest(test.TestCase):
|
||||
'instance_name': 'inst-0001',
|
||||
'console_type': 'fake_type'}}
|
||||
|
||||
self.stubs.Set(console.API, 'get_console', fake_get_console)
|
||||
self.stubs.Set(console.api.API, 'get_console', fake_get_console)
|
||||
|
||||
req = fakes.HTTPRequest.blank(self.url + '/20')
|
||||
res_dict = self.controller.show(req, self.uuid, '20')
|
||||
@ -172,7 +172,7 @@ class ConsolesControllerTest(test.TestCase):
|
||||
def fake_get_console(cons_self, context, instance_id, console_id):
|
||||
raise exception.ConsoleNotFound(console_id=console_id)
|
||||
|
||||
self.stubs.Set(console.API, 'get_console', fake_get_console)
|
||||
self.stubs.Set(console.api.API, 'get_console', fake_get_console)
|
||||
|
||||
req = fakes.HTTPRequest.blank(self.url + '/20')
|
||||
self.assertRaises(webob.exc.HTTPNotFound, self.controller.show,
|
||||
@ -182,7 +182,7 @@ class ConsolesControllerTest(test.TestCase):
|
||||
def fake_get_console(cons_self, context, instance_id, console_id):
|
||||
raise exception.InstanceNotFound(instance_id=instance_id)
|
||||
|
||||
self.stubs.Set(console.API, 'get_console', fake_get_console)
|
||||
self.stubs.Set(console.api.API, 'get_console', fake_get_console)
|
||||
|
||||
req = fakes.HTTPRequest.blank(self.url + '/20')
|
||||
self.assertRaises(webob.exc.HTTPNotFound, self.controller.show,
|
||||
@ -206,7 +206,7 @@ class ConsolesControllerTest(test.TestCase):
|
||||
[{'console': {'id': 10, 'console_type': 'fake_type'}},
|
||||
{'console': {'id': 11, 'console_type': 'fake_type2'}}]}
|
||||
|
||||
self.stubs.Set(console.API, 'get_consoles', fake_get_consoles)
|
||||
self.stubs.Set(console.api.API, 'get_consoles', fake_get_consoles)
|
||||
|
||||
req = fakes.HTTPRequest.blank(self.url)
|
||||
res_dict = self.controller.index(req, self.uuid)
|
||||
@ -225,8 +225,8 @@ class ConsolesControllerTest(test.TestCase):
|
||||
self.assertEqual(instance_id, self.uuid)
|
||||
self.assertEqual(console_id, 20)
|
||||
|
||||
self.stubs.Set(console.API, 'get_console', fake_get_console)
|
||||
self.stubs.Set(console.API, 'delete_console', fake_delete_console)
|
||||
self.stubs.Set(console.api.API, 'get_console', fake_get_console)
|
||||
self.stubs.Set(console.api.API, 'delete_console', fake_delete_console)
|
||||
|
||||
req = fakes.HTTPRequest.blank(self.url + '/20')
|
||||
self.controller.delete(req, self.uuid, '20')
|
||||
@ -235,7 +235,7 @@ class ConsolesControllerTest(test.TestCase):
|
||||
def fake_delete_console(cons_self, context, instance_id, console_id):
|
||||
raise exception.ConsoleNotFound(console_id=console_id)
|
||||
|
||||
self.stubs.Set(console.API, 'delete_console', fake_delete_console)
|
||||
self.stubs.Set(console.api.API, 'delete_console', fake_delete_console)
|
||||
|
||||
req = fakes.HTTPRequest.blank(self.url + '/20')
|
||||
self.assertRaises(webob.exc.HTTPNotFound, self.controller.delete,
|
||||
@ -245,7 +245,7 @@ class ConsolesControllerTest(test.TestCase):
|
||||
def fake_delete_console(cons_self, context, instance_id, console_id):
|
||||
raise exception.InstanceNotFound(instance_id=instance_id)
|
||||
|
||||
self.stubs.Set(console.API, 'delete_console', fake_delete_console)
|
||||
self.stubs.Set(console.api.API, 'delete_console', fake_delete_console)
|
||||
|
||||
req = fakes.HTTPRequest.blank(self.url + '/20')
|
||||
self.assertRaises(webob.exc.HTTPNotFound, self.controller.delete,
|
||||
|
@ -34,7 +34,7 @@ from nova.compute import instance_types
|
||||
from nova.compute import task_states
|
||||
from nova.compute import vm_states
|
||||
import nova.db
|
||||
from nova.db.sqlalchemy.models import InstanceMetadata
|
||||
from nova.db.sqlalchemy import models
|
||||
from nova import flags
|
||||
import nova.image.fake
|
||||
import nova.rpc
|
||||
@ -3008,7 +3008,7 @@ class ServersViewBuilderTest(test.TestCase):
|
||||
def test_build_server_detail_with_metadata(self):
|
||||
|
||||
metadata = []
|
||||
metadata.append(InstanceMetadata(key="Open", value="Stack"))
|
||||
metadata.append(models.InstanceMetadata(key="Open", value="Stack"))
|
||||
self.instance['metadata'] = metadata
|
||||
|
||||
image_bookmark = "http://localhost/fake/images/5"
|
||||
|
@ -20,13 +20,11 @@ Test suites for 'common' code used throughout the OpenStack HTTP API.
|
||||
"""
|
||||
|
||||
from lxml import etree
|
||||
import webob
|
||||
import webob.exc
|
||||
# FIXME(comstud): Don't import classes (HACKING)
|
||||
from webob import Request
|
||||
import xml.dom.minidom as minidom
|
||||
|
||||
from nova import exception
|
||||
from nova import network
|
||||
from nova import test
|
||||
from nova.api.openstack import common
|
||||
from nova.api.openstack import xmlutil
|
||||
@ -53,7 +51,7 @@ class LimiterTest(test.TestCase):
|
||||
|
||||
def test_limiter_offset_zero(self):
|
||||
""" Test offset key works with 0. """
|
||||
req = Request.blank('/?offset=0')
|
||||
req = webob.Request.blank('/?offset=0')
|
||||
self.assertEqual(common.limited(self.tiny, req), self.tiny)
|
||||
self.assertEqual(common.limited(self.small, req), self.small)
|
||||
self.assertEqual(common.limited(self.medium, req), self.medium)
|
||||
@ -61,7 +59,7 @@ class LimiterTest(test.TestCase):
|
||||
|
||||
def test_limiter_offset_medium(self):
|
||||
""" Test offset key works with a medium sized number. """
|
||||
req = Request.blank('/?offset=10')
|
||||
req = webob.Request.blank('/?offset=10')
|
||||
self.assertEqual(common.limited(self.tiny, req), [])
|
||||
self.assertEqual(common.limited(self.small, req), self.small[10:])
|
||||
self.assertEqual(common.limited(self.medium, req), self.medium[10:])
|
||||
@ -69,7 +67,7 @@ class LimiterTest(test.TestCase):
|
||||
|
||||
def test_limiter_offset_over_max(self):
|
||||
""" Test offset key works with a number over 1000 (max_limit). """
|
||||
req = Request.blank('/?offset=1001')
|
||||
req = webob.Request.blank('/?offset=1001')
|
||||
self.assertEqual(common.limited(self.tiny, req), [])
|
||||
self.assertEqual(common.limited(self.small, req), [])
|
||||
self.assertEqual(common.limited(self.medium, req), [])
|
||||
@ -78,19 +76,19 @@ class LimiterTest(test.TestCase):
|
||||
|
||||
def test_limiter_offset_blank(self):
|
||||
""" Test offset key works with a blank offset. """
|
||||
req = Request.blank('/?offset=')
|
||||
req = webob.Request.blank('/?offset=')
|
||||
self.assertRaises(
|
||||
webob.exc.HTTPBadRequest, common.limited, self.tiny, req)
|
||||
|
||||
def test_limiter_offset_bad(self):
|
||||
""" Test offset key works with a BAD offset. """
|
||||
req = Request.blank(u'/?offset=\u0020aa')
|
||||
req = webob.Request.blank(u'/?offset=\u0020aa')
|
||||
self.assertRaises(
|
||||
webob.exc.HTTPBadRequest, common.limited, self.tiny, req)
|
||||
|
||||
def test_limiter_nothing(self):
|
||||
""" Test request with no offset or limit """
|
||||
req = Request.blank('/')
|
||||
req = webob.Request.blank('/')
|
||||
self.assertEqual(common.limited(self.tiny, req), self.tiny)
|
||||
self.assertEqual(common.limited(self.small, req), self.small)
|
||||
self.assertEqual(common.limited(self.medium, req), self.medium)
|
||||
@ -98,7 +96,7 @@ class LimiterTest(test.TestCase):
|
||||
|
||||
def test_limiter_limit_zero(self):
|
||||
""" Test limit of zero. """
|
||||
req = Request.blank('/?limit=0')
|
||||
req = webob.Request.blank('/?limit=0')
|
||||
self.assertEqual(common.limited(self.tiny, req), self.tiny)
|
||||
self.assertEqual(common.limited(self.small, req), self.small)
|
||||
self.assertEqual(common.limited(self.medium, req), self.medium)
|
||||
@ -106,7 +104,7 @@ class LimiterTest(test.TestCase):
|
||||
|
||||
def test_limiter_limit_medium(self):
|
||||
""" Test limit of 10. """
|
||||
req = Request.blank('/?limit=10')
|
||||
req = webob.Request.blank('/?limit=10')
|
||||
self.assertEqual(common.limited(self.tiny, req), self.tiny)
|
||||
self.assertEqual(common.limited(self.small, req), self.small)
|
||||
self.assertEqual(common.limited(self.medium, req), self.medium[:10])
|
||||
@ -114,7 +112,7 @@ class LimiterTest(test.TestCase):
|
||||
|
||||
def test_limiter_limit_over_max(self):
|
||||
""" Test limit of 3000. """
|
||||
req = Request.blank('/?limit=3000')
|
||||
req = webob.Request.blank('/?limit=3000')
|
||||
self.assertEqual(common.limited(self.tiny, req), self.tiny)
|
||||
self.assertEqual(common.limited(self.small, req), self.small)
|
||||
self.assertEqual(common.limited(self.medium, req), self.medium)
|
||||
@ -123,39 +121,39 @@ class LimiterTest(test.TestCase):
|
||||
def test_limiter_limit_and_offset(self):
|
||||
""" Test request with both limit and offset. """
|
||||
items = range(2000)
|
||||
req = Request.blank('/?offset=1&limit=3')
|
||||
req = webob.Request.blank('/?offset=1&limit=3')
|
||||
self.assertEqual(common.limited(items, req), items[1:4])
|
||||
req = Request.blank('/?offset=3&limit=0')
|
||||
req = webob.Request.blank('/?offset=3&limit=0')
|
||||
self.assertEqual(common.limited(items, req), items[3:1003])
|
||||
req = Request.blank('/?offset=3&limit=1500')
|
||||
req = webob.Request.blank('/?offset=3&limit=1500')
|
||||
self.assertEqual(common.limited(items, req), items[3:1003])
|
||||
req = Request.blank('/?offset=3000&limit=10')
|
||||
req = webob.Request.blank('/?offset=3000&limit=10')
|
||||
self.assertEqual(common.limited(items, req), [])
|
||||
|
||||
def test_limiter_custom_max_limit(self):
|
||||
""" Test a max_limit other than 1000. """
|
||||
items = range(2000)
|
||||
req = Request.blank('/?offset=1&limit=3')
|
||||
req = webob.Request.blank('/?offset=1&limit=3')
|
||||
self.assertEqual(
|
||||
common.limited(items, req, max_limit=2000), items[1:4])
|
||||
req = Request.blank('/?offset=3&limit=0')
|
||||
req = webob.Request.blank('/?offset=3&limit=0')
|
||||
self.assertEqual(
|
||||
common.limited(items, req, max_limit=2000), items[3:])
|
||||
req = Request.blank('/?offset=3&limit=2500')
|
||||
req = webob.Request.blank('/?offset=3&limit=2500')
|
||||
self.assertEqual(
|
||||
common.limited(items, req, max_limit=2000), items[3:])
|
||||
req = Request.blank('/?offset=3000&limit=10')
|
||||
req = webob.Request.blank('/?offset=3000&limit=10')
|
||||
self.assertEqual(common.limited(items, req, max_limit=2000), [])
|
||||
|
||||
def test_limiter_negative_limit(self):
|
||||
""" Test a negative limit. """
|
||||
req = Request.blank('/?limit=-3000')
|
||||
req = webob.Request.blank('/?limit=-3000')
|
||||
self.assertRaises(
|
||||
webob.exc.HTTPBadRequest, common.limited, self.tiny, req)
|
||||
|
||||
def test_limiter_negative_offset(self):
|
||||
""" Test a negative offset. """
|
||||
req = Request.blank('/?offset=-30')
|
||||
req = webob.Request.blank('/?offset=-30')
|
||||
self.assertRaises(
|
||||
webob.exc.HTTPBadRequest, common.limited, self.tiny, req)
|
||||
|
||||
@ -169,30 +167,31 @@ class PaginationParamsTest(test.TestCase):
|
||||
|
||||
def test_no_params(self):
|
||||
""" Test no params. """
|
||||
req = Request.blank('/')
|
||||
req = webob.Request.blank('/')
|
||||
self.assertEqual(common.get_pagination_params(req), {})
|
||||
|
||||
def test_valid_marker(self):
|
||||
""" Test valid marker param. """
|
||||
req = Request.blank('/?marker=263abb28-1de6-412f-b00b-f0ee0c4333c2')
|
||||
req = webob.Request.blank(
|
||||
'/?marker=263abb28-1de6-412f-b00b-f0ee0c4333c2')
|
||||
self.assertEqual(common.get_pagination_params(req),
|
||||
{'marker': '263abb28-1de6-412f-b00b-f0ee0c4333c2'})
|
||||
|
||||
def test_valid_limit(self):
|
||||
""" Test valid limit param. """
|
||||
req = Request.blank('/?limit=10')
|
||||
req = webob.Request.blank('/?limit=10')
|
||||
self.assertEqual(common.get_pagination_params(req), {'limit': 10})
|
||||
|
||||
def test_invalid_limit(self):
|
||||
""" Test invalid limit param. """
|
||||
req = Request.blank('/?limit=-2')
|
||||
req = webob.Request.blank('/?limit=-2')
|
||||
self.assertRaises(
|
||||
webob.exc.HTTPBadRequest, common.get_pagination_params, req)
|
||||
|
||||
def test_valid_limit_and_marker(self):
|
||||
""" Test valid limit and marker parameters. """
|
||||
marker = '263abb28-1de6-412f-b00b-f0ee0c4333c2'
|
||||
req = Request.blank('/?limit=20&marker=%s' % marker)
|
||||
req = webob.Request.blank('/?limit=20&marker=%s' % marker)
|
||||
self.assertEqual(common.get_pagination_params(req),
|
||||
{'marker': marker, 'limit': 20})
|
||||
|
||||
|
@ -14,11 +14,12 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from xml.etree.ElementTree import fromstring as xml_to_tree
|
||||
from xml.etree import ElementTree
|
||||
try:
|
||||
from xml.etree.ElementTree import ParseError
|
||||
except ImportError:
|
||||
from xml.parsers.expat import ExpatError as ParseError
|
||||
ParseError = ElementTree.ParseError
|
||||
except AttributeError:
|
||||
from xml.parsers import expat
|
||||
ParseError = expat.ExpatError
|
||||
|
||||
import uuid
|
||||
|
||||
@ -140,7 +141,7 @@ class NWFilter(object):
|
||||
self._parse_xml(xml)
|
||||
|
||||
def _parse_xml(self, xml):
|
||||
tree = xml_to_tree(xml)
|
||||
tree = ElementTree.fromstring(xml)
|
||||
root = tree.find('.')
|
||||
self._name = root.get('name')
|
||||
|
||||
@ -162,7 +163,7 @@ class Domain(object):
|
||||
|
||||
def _parse_definition(self, xml):
|
||||
try:
|
||||
tree = xml_to_tree(xml)
|
||||
tree = ElementTree.fromstring(xml)
|
||||
except ParseError:
|
||||
raise libvirtError(VIR_ERR_XML_DETAIL, VIR_FROM_DOMAIN,
|
||||
"Invalid XML.")
|
||||
@ -300,13 +301,13 @@ class Domain(object):
|
||||
123456789L]
|
||||
|
||||
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
|
||||
self._def['devices']['disks'] += [disk_info]
|
||||
return True
|
||||
|
||||
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
|
||||
return disk_info in self._def['devices']['disks']
|
||||
|
||||
@ -398,7 +399,7 @@ class Domain(object):
|
||||
self._state = VIR_DOMAIN_RUNNING
|
||||
|
||||
def snapshotCreateXML(self, xml, flags):
|
||||
tree = xml_to_tree(xml)
|
||||
tree = ElementTree.fromstring(xml)
|
||||
name = tree.find('./name').text
|
||||
snapshot = DomainSnapshot(name, self)
|
||||
self._snapshots[name] = snapshot
|
||||
@ -735,7 +736,7 @@ class Connection(object):
|
||||
</capabilities>'''
|
||||
|
||||
def compareCPU(self, xml, flags):
|
||||
tree = xml_to_tree(xml)
|
||||
tree = ElementTree.fromstring(xml)
|
||||
|
||||
arch_node = tree.find('./arch')
|
||||
if arch_node is not None:
|
||||
|
@ -16,7 +16,6 @@
|
||||
import nova
|
||||
from nova import log as logging
|
||||
import nova.notifier.api
|
||||
from nova.notifier.api import notify
|
||||
import nova.notifier.log_notifier
|
||||
import nova.notifier.no_op_notifier
|
||||
from nova.notifier import list_notifier
|
||||
@ -59,7 +58,7 @@ class NotifierListTestCase(test.TestCase):
|
||||
self.flags(notification_driver='nova.notifier.list_notifier',
|
||||
list_notifier_drivers=['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))
|
||||
self.assertEqual(self.notify_count, 2)
|
||||
self.assertEqual(self.exception_count, 0)
|
||||
@ -69,7 +68,8 @@ class NotifierListTestCase(test.TestCase):
|
||||
self.flags(notification_driver='nova.notifier.list_notifier',
|
||||
list_notifier_drivers=['nova.notifier.no_op_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.exception_count, 1)
|
||||
|
||||
@ -78,6 +78,7 @@ class NotifierListTestCase(test.TestCase):
|
||||
list_notifier_drivers=['nova.notifier.no_op_notifier',
|
||||
'nova.notifier.logo_notifier',
|
||||
'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.notify_count, 1)
|
||||
|
@ -25,7 +25,7 @@ import nose
|
||||
|
||||
from nova import context
|
||||
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
|
||||
|
||||
|
||||
@ -107,7 +107,7 @@ class _BaseRpcTestCase(test.TestCase):
|
||||
|
||||
"""
|
||||
value = 42
|
||||
self.assertRaises(RemoteError,
|
||||
self.assertRaises(rpc_common.RemoteError,
|
||||
self.rpc.call,
|
||||
self.context,
|
||||
'test',
|
||||
@ -119,7 +119,7 @@ class _BaseRpcTestCase(test.TestCase):
|
||||
{"method": "fail",
|
||||
"args": {"value": value}})
|
||||
self.fail("should have thrown RemoteError")
|
||||
except RemoteError as exc:
|
||||
except rpc_common.RemoteError as exc:
|
||||
self.assertEqual(int(exc.value), value)
|
||||
|
||||
def test_nested_calls(self):
|
||||
@ -157,7 +157,7 @@ class _BaseRpcTestCase(test.TestCase):
|
||||
raise nose.SkipTest(_("RPC backend does not support timeouts"))
|
||||
|
||||
value = 42
|
||||
self.assertRaises(Timeout,
|
||||
self.assertRaises(rpc_common.Timeout,
|
||||
self.rpc.call,
|
||||
self.context,
|
||||
'test',
|
||||
@ -170,7 +170,7 @@ class _BaseRpcTestCase(test.TestCase):
|
||||
"args": {"value": value}},
|
||||
timeout=1)
|
||||
self.fail("should have thrown Timeout")
|
||||
except Timeout as exc:
|
||||
except rpc_common.Timeout as exc:
|
||||
pass
|
||||
|
||||
|
||||
|
@ -996,7 +996,7 @@ class SchedulerTestCase(test.TestCase):
|
||||
rpc.call(self.context, 'dest_queue',
|
||||
{'method': 'compare_cpu',
|
||||
'args': {'cpu_info': 'fake_cpu_info'}}).AndRaise(
|
||||
rpc.RemoteError())
|
||||
rpc_common.RemoteError())
|
||||
|
||||
self.mox.ReplayAll()
|
||||
self.assertRaises(rpc_common.RemoteError,
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
from nova import exception
|
||||
from nova import log as logging
|
||||
from nova.volume.san import SolidFireSanISCSIDriver as SFID
|
||||
from nova.volume import san
|
||||
from nova import test
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -90,19 +90,21 @@ class SolidFireVolumeTestCase(test.TestCase):
|
||||
'id': 1}
|
||||
|
||||
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',
|
||||
'name': 'testvol',
|
||||
'size': 1}
|
||||
sfv = SFID()
|
||||
sfv = san.SolidFireSanISCSIDriver()
|
||||
model_update = sfv.create_volume(testvol)
|
||||
|
||||
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',
|
||||
'name': 'testvol',
|
||||
'size': 1}
|
||||
sfv = SFID()
|
||||
sfv = san.SolidFireSanISCSIDriver()
|
||||
try:
|
||||
sfv.create_volume(testvol)
|
||||
self.fail("Should have thrown Error")
|
||||
@ -110,43 +112,49 @@ class SolidFireVolumeTestCase(test.TestCase):
|
||||
pass
|
||||
|
||||
def test_create_sfaccount(self):
|
||||
sfv = SFID()
|
||||
SFID._issue_api_request = self.fake_issue_api_request
|
||||
sfv = san.SolidFireSanISCSIDriver()
|
||||
self.stubs.Set(san.SolidFireSanISCSIDriver, '_issue_api_request',
|
||||
self.fake_issue_api_request)
|
||||
account = sfv._create_sfaccount('project-id')
|
||||
self.assertNotEqual(account, None)
|
||||
|
||||
def test_create_sfaccount_fails(self):
|
||||
sfv = SFID()
|
||||
SFID._issue_api_request = self.fake_issue_api_request_fails
|
||||
sfv = san.SolidFireSanISCSIDriver()
|
||||
self.stubs.Set(san.SolidFireSanISCSIDriver, '_issue_api_request',
|
||||
self.fake_issue_api_request_fails)
|
||||
account = sfv._create_sfaccount('project-id')
|
||||
self.assertEqual(account, None)
|
||||
|
||||
def test_get_sfaccount_by_name(self):
|
||||
sfv = SFID()
|
||||
SFID._issue_api_request = self.fake_issue_api_request
|
||||
sfv = san.SolidFireSanISCSIDriver()
|
||||
self.stubs.Set(san.SolidFireSanISCSIDriver, '_issue_api_request',
|
||||
self.fake_issue_api_request)
|
||||
account = sfv._get_sfaccount_by_name('some-name')
|
||||
self.assertNotEqual(account, None)
|
||||
|
||||
def test_get_sfaccount_by_name_fails(self):
|
||||
sfv = SFID()
|
||||
SFID._issue_api_request = self.fake_issue_api_request_fails
|
||||
sfv = san.SolidFireSanISCSIDriver()
|
||||
self.stubs.Set(san.SolidFireSanISCSIDriver, '_issue_api_request',
|
||||
self.fake_issue_api_request_fails)
|
||||
account = sfv._get_sfaccount_by_name('some-name')
|
||||
self.assertEqual(account, None)
|
||||
|
||||
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',
|
||||
'name': 'test_volume',
|
||||
'size': 1}
|
||||
sfv = SFID()
|
||||
sfv = san.SolidFireSanISCSIDriver()
|
||||
model_update = sfv.delete_volume(testvol)
|
||||
|
||||
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',
|
||||
'name': 'no-name',
|
||||
'size': 1}
|
||||
sfv = SFID()
|
||||
sfv = san.SolidFireSanISCSIDriver()
|
||||
try:
|
||||
model_update = sfv.delete_volume(testvol)
|
||||
self.fail("Should have thrown Error")
|
||||
@ -154,22 +162,25 @@ class SolidFireVolumeTestCase(test.TestCase):
|
||||
pass
|
||||
|
||||
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',
|
||||
'name': 'no-name',
|
||||
'size': 1}
|
||||
sfv = SFID()
|
||||
sfv = san.SolidFireSanISCSIDriver()
|
||||
self.assertRaises(exception.DuplicateSfVolumeNames,
|
||||
sfv.delete_volume,
|
||||
testvol)
|
||||
|
||||
def test_get_cluster_info(self):
|
||||
SFID._issue_api_request = self.fake_issue_api_request
|
||||
sfv = SFID()
|
||||
self.stubs.Set(san.SolidFireSanISCSIDriver, '_issue_api_request',
|
||||
self.fake_issue_api_request)
|
||||
sfv = san.SolidFireSanISCSIDriver()
|
||||
sfv._get_cluster_info()
|
||||
|
||||
def test_get_cluster_info_fail(self):
|
||||
SFID._issue_api_request = self.fake_issue_api_request_fails
|
||||
sfv = SFID()
|
||||
self.stubs.Set(san.SolidFireSanISCSIDriver, '_issue_api_request',
|
||||
self.fake_issue_api_request_fails)
|
||||
sfv = san.SolidFireSanISCSIDriver()
|
||||
self.assertRaises(exception.SolidFireAPIException,
|
||||
sfv._get_cluster_info)
|
||||
|
@ -18,13 +18,14 @@
|
||||
|
||||
"""Unit tests for the API endpoint"""
|
||||
|
||||
import boto
|
||||
from boto.ec2 import regioninfo
|
||||
from boto.exception import EC2ResponseError
|
||||
import datetime
|
||||
import httplib
|
||||
import random
|
||||
import StringIO
|
||||
|
||||
import boto
|
||||
from boto.ec2 import regioninfo
|
||||
from boto import exception as boto_exc
|
||||
import webob
|
||||
|
||||
from nova import block_device
|
||||
@ -271,8 +272,8 @@ class ApiEc2TestCase(test.TestCase):
|
||||
"""Attempt to terminate an invalid instance"""
|
||||
self.expect_http()
|
||||
self.mox.ReplayAll()
|
||||
self.assertRaises(EC2ResponseError, self.ec2.terminate_instances,
|
||||
"i-00000005")
|
||||
self.assertRaises(boto_exc.EC2ResponseError,
|
||||
self.ec2.terminate_instances, "i-00000005")
|
||||
|
||||
def test_get_all_key_pairs(self):
|
||||
"""Test that, after creating a user and project and generating
|
||||
@ -300,7 +301,7 @@ class ApiEc2TestCase(test.TestCase):
|
||||
|
||||
try:
|
||||
self.ec2.create_key_pair('test')
|
||||
except EC2ResponseError, e:
|
||||
except boto_exc.EC2ResponseError, e:
|
||||
if e.code == 'KeyPairExists':
|
||||
pass
|
||||
else:
|
||||
@ -352,8 +353,10 @@ class ApiEc2TestCase(test.TestCase):
|
||||
# dashes, and underscores.
|
||||
security_group_name = "aa #^% -=99"
|
||||
|
||||
self.assertRaises(EC2ResponseError, self.ec2.create_security_group,
|
||||
security_group_name, 'test group')
|
||||
self.assertRaises(boto_exc.EC2ResponseError,
|
||||
self.ec2.create_security_group,
|
||||
security_group_name,
|
||||
'test group')
|
||||
|
||||
def test_group_name_valid_length_security_group(self):
|
||||
"""Test that we sanely handle invalid security group names.
|
||||
@ -365,8 +368,10 @@ class ApiEc2TestCase(test.TestCase):
|
||||
security_group_name = "".join(random.choice("poiuytrewqasdfghjklmnbvc")
|
||||
for x in range(random.randint(256, 266)))
|
||||
|
||||
self.assertRaises(EC2ResponseError, self.ec2.create_security_group,
|
||||
security_group_name, 'test group')
|
||||
self.assertRaises(boto_exc.EC2ResponseError,
|
||||
self.ec2.create_security_group,
|
||||
security_group_name,
|
||||
'test group')
|
||||
|
||||
def test_authorize_revoke_security_group_cidr(self):
|
||||
"""
|
||||
@ -393,7 +398,7 @@ class ApiEc2TestCase(test.TestCase):
|
||||
def _assert(message, *args):
|
||||
try:
|
||||
group.authorize(*args)
|
||||
except EC2ResponseError as e:
|
||||
except boto_exc.EC2ResponseError as e:
|
||||
self.assertEqual(e.status, 400, 'Expected status to be 400')
|
||||
self.assertIn(message, e.error_message, e.error_message)
|
||||
else:
|
||||
@ -569,7 +574,7 @@ class ApiEc2TestCase(test.TestCase):
|
||||
|
||||
# Can not delete the group while it is still used by
|
||||
# another group.
|
||||
self.assertRaises(EC2ResponseError,
|
||||
self.assertRaises(boto_exc.EC2ResponseError,
|
||||
self.ec2.delete_security_group,
|
||||
other_security_group_name)
|
||||
|
||||
|
@ -29,7 +29,7 @@ import webob.exc
|
||||
import nova
|
||||
import nova.common.policy
|
||||
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 instance_types
|
||||
from nova.compute import manager as compute_manager
|
||||
@ -1419,7 +1419,7 @@ class ComputeTestCase(BaseTestCase):
|
||||
|
||||
# start test
|
||||
self.mox.ReplayAll()
|
||||
self.assertRaises(rpc.RemoteError,
|
||||
self.assertRaises(rpc_common.RemoteError,
|
||||
self.compute.live_migration,
|
||||
c, instance_id, inst_ref['host'], True)
|
||||
|
||||
@ -3316,7 +3316,7 @@ class ComputeAPIAggrTestCase(test.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(ComputeAPIAggrTestCase, self).setUp()
|
||||
self.api = compute.AggregateAPI()
|
||||
self.api = compute_api.AggregateAPI()
|
||||
self.context = context.get_admin_context()
|
||||
self.stubs.Set(rpc, 'call', fake_rpc_method)
|
||||
self.stubs.Set(rpc, 'cast', fake_rpc_method)
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
from nova import test
|
||||
|
||||
from xml.etree.ElementTree import fromstring as xml_to_tree
|
||||
from xml.etree import ElementTree
|
||||
|
||||
import fakelibvirt as libvirt
|
||||
|
||||
@ -252,7 +252,7 @@ class FakeLibvirtTests(test.TestCase):
|
||||
conn.defineXML(get_vm_xml())
|
||||
dom = conn.lookupByName('testname')
|
||||
xml = dom.XMLDesc(0)
|
||||
xml_to_tree(xml)
|
||||
ElementTree.fromstring(xml)
|
||||
|
||||
def _test_accepts_source_type(self, source_type):
|
||||
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))
|
||||
dom = conn.lookupByName('testname')
|
||||
xml = dom.XMLDesc(0)
|
||||
tree = xml_to_tree(xml)
|
||||
tree = ElementTree.fromstring(xml)
|
||||
elem = tree.find('./devices/disk/source')
|
||||
self.assertEquals(elem.get('file'), '/somefile')
|
||||
|
||||
@ -282,7 +282,7 @@ class FakeLibvirtTests(test.TestCase):
|
||||
conn.defineXML(get_vm_xml(interface_type=network_type))
|
||||
dom = conn.lookupByName('testname')
|
||||
xml = dom.XMLDesc(0)
|
||||
tree = xml_to_tree(xml)
|
||||
tree = ElementTree.fromstring(xml)
|
||||
elem = tree.find('./devices/interface')
|
||||
self.assertEquals(elem.get('type'), network_type)
|
||||
elem = elem.find('./source')
|
||||
@ -298,7 +298,7 @@ class FakeLibvirtTests(test.TestCase):
|
||||
|
||||
def test_getCapabilities(self):
|
||||
conn = self.get_openAuth_curry_func()('qemu:///system')
|
||||
xml_to_tree(conn.getCapabilities())
|
||||
ElementTree.fromstring(conn.getCapabilities())
|
||||
|
||||
def test_nwfilter_define_undefine(self):
|
||||
conn = self.get_openAuth_curry_func()('qemu:///system')
|
||||
|
@ -24,8 +24,8 @@ from nova import flags
|
||||
from nova import log as logging
|
||||
from nova import test
|
||||
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 session as sql_session
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -90,7 +90,7 @@ class InstanceTypeTestCase(test.TestCase):
|
||||
|
||||
def test_get_all_instance_types(self):
|
||||
"""Ensures that all instance types can be retrieved"""
|
||||
session = get_session()
|
||||
session = sql_session.get_session()
|
||||
total_instance_types = session.query(models.InstanceTypes).count()
|
||||
inst_types = instance_types.get_all_types()
|
||||
self.assertEqual(total_instance_types, len(inst_types))
|
||||
|
@ -23,8 +23,8 @@ import shutil
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
from xml.etree.ElementTree import fromstring as xml_to_tree
|
||||
from xml.dom.minidom import parseString as xml_to_dom
|
||||
from xml.etree import ElementTree
|
||||
from xml.dom import minidom
|
||||
|
||||
from nova import context
|
||||
from nova import db
|
||||
@ -149,7 +149,7 @@ class LibvirtVolumeTestCase(test.TestCase):
|
||||
connection_info = vol_driver.initialize_connection(vol, self.connr)
|
||||
mount_device = "vde"
|
||||
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)
|
||||
self.assertEqual(tree.get('type'), 'block')
|
||||
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)
|
||||
mount_device = "vde"
|
||||
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)
|
||||
self.assertEqual(tree.get('type'), 'block')
|
||||
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)
|
||||
mount_device = "vde"
|
||||
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.find('./source').get('protocol'), 'sheepdog')
|
||||
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)
|
||||
mount_device = "vde"
|
||||
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.find('./source').get('protocol'), 'rbd')
|
||||
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)
|
||||
mount_device = "vde"
|
||||
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)
|
||||
self.assertEqual(tree.get('type'), 'block')
|
||||
self.assertEqual(tree.find('./source').get('dev'), dev_str)
|
||||
@ -716,7 +716,7 @@ class LibvirtConnTestCase(test.TestCase):
|
||||
conn = connection.LibvirtConnection(True)
|
||||
instance_ref = db.instance_create(self.context, instance_data)
|
||||
xml = conn.to_xml(instance_ref, network_info, None, False)
|
||||
tree = xml_to_tree(xml)
|
||||
tree = ElementTree.fromstring(xml)
|
||||
interfaces = tree.findall("./devices/interface")
|
||||
self.assertEquals(len(interfaces), 2)
|
||||
parameters = interfaces[0].findall('./filterref/parameter')
|
||||
@ -738,7 +738,7 @@ class LibvirtConnTestCase(test.TestCase):
|
||||
|
||||
network_info = _fake_network_info(self.stubs, 1)
|
||||
xml = conn.to_xml(instance_ref, network_info)
|
||||
tree = xml_to_tree(xml)
|
||||
tree = ElementTree.fromstring(xml)
|
||||
|
||||
check = [
|
||||
(lambda t: t.find('.').get('type'), 'lxc'),
|
||||
@ -779,7 +779,7 @@ class LibvirtConnTestCase(test.TestCase):
|
||||
|
||||
network_info = _fake_network_info(self.stubs, 1)
|
||||
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):
|
||||
self.assertEqual(check(tree),
|
||||
@ -795,7 +795,7 @@ class LibvirtConnTestCase(test.TestCase):
|
||||
xml = connection.LibvirtConnection(True).to_xml(instance_ref,
|
||||
network_info,
|
||||
image_meta)
|
||||
tree = xml_to_tree(xml)
|
||||
tree = ElementTree.fromstring(xml)
|
||||
self.assertEqual(tree.find('./devices/disk').get('device'),
|
||||
device_type)
|
||||
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,
|
||||
network_info,
|
||||
image_meta)
|
||||
tree = xml_to_tree(xml)
|
||||
tree = ElementTree.fromstring(xml)
|
||||
self.assertEqual(tree.find('./uuid').text,
|
||||
instance_ref['uuid'])
|
||||
|
||||
@ -894,7 +894,7 @@ class LibvirtConnTestCase(test.TestCase):
|
||||
|
||||
network_info = _fake_network_info(self.stubs, 1)
|
||||
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):
|
||||
self.assertEqual(check(tree),
|
||||
expected_result,
|
||||
@ -1352,7 +1352,7 @@ class NWFilterFakes:
|
||||
def undefine(self):
|
||||
del self.parent.filters[self.name]
|
||||
pass
|
||||
tree = xml_to_tree(xml)
|
||||
tree = ElementTree.fromstring(xml)
|
||||
name = tree.get('name')
|
||||
if name not in self.filters:
|
||||
self.filters[name] = FakeNWFilterInternal(self, name)
|
||||
@ -1772,7 +1772,7 @@ class NWFilterTestCase(test.TestCase):
|
||||
self.recursive_depends[f] = []
|
||||
|
||||
def _filterDefineXMLMock(xml):
|
||||
dom = xml_to_dom(xml)
|
||||
dom = minidom.parseString(xml)
|
||||
name = dom.firstChild.getAttribute('name')
|
||||
self.recursive_depends[name] = []
|
||||
for f in dom.getElementsByTagName('filterref'):
|
||||
|
@ -20,12 +20,8 @@ from nova import flags
|
||||
from nova import test
|
||||
from nova import utils
|
||||
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.vif import LibvirtBridgeDriver, \
|
||||
LibvirtOpenVswitchDriver, \
|
||||
LibvirtOpenVswitchVirtualPortDriver, \
|
||||
QuantumLinuxBridgeVIFDriver
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
|
||||
@ -101,7 +97,7 @@ class LibvirtVifTestCase(test.TestCase):
|
||||
return xml
|
||||
|
||||
def test_bridge_driver(self):
|
||||
d = LibvirtBridgeDriver()
|
||||
d = vif.LibvirtBridgeDriver()
|
||||
xml = self._get_instance_xml(d, 'bridge')
|
||||
|
||||
doc = ElementTree.fromstring(xml)
|
||||
@ -117,7 +113,7 @@ class LibvirtVifTestCase(test.TestCase):
|
||||
d.unplug(None, self.net, self.mapping)
|
||||
|
||||
def test_ovs_ethernet_driver(self):
|
||||
d = LibvirtOpenVswitchDriver()
|
||||
d = vif.LibvirtOpenVswitchDriver()
|
||||
xml = self._get_instance_xml(d, 'ethernet')
|
||||
|
||||
doc = ElementTree.fromstring(xml)
|
||||
@ -135,7 +131,7 @@ class LibvirtVifTestCase(test.TestCase):
|
||||
d.unplug(None, self.net, self.mapping)
|
||||
|
||||
def test_ovs_virtualport_driver(self):
|
||||
d = LibvirtOpenVswitchVirtualPortDriver()
|
||||
d = vif.LibvirtOpenVswitchVirtualPortDriver()
|
||||
xml = self._get_instance_xml(d, 'ovs_virtualport')
|
||||
|
||||
doc = ElementTree.fromstring(xml)
|
||||
@ -161,7 +157,7 @@ class LibvirtVifTestCase(test.TestCase):
|
||||
d.unplug(None, self.net, self.mapping)
|
||||
|
||||
def test_quantum_bridge_ethernet_driver(self):
|
||||
d = QuantumLinuxBridgeVIFDriver()
|
||||
d = vif.QuantumLinuxBridgeVIFDriver()
|
||||
xml = self._get_instance_xml(d, 'ethernet')
|
||||
|
||||
doc = ElementTree.fromstring(xml)
|
||||
|
@ -33,7 +33,7 @@ import urlparse
|
||||
|
||||
import migrate
|
||||
from migrate.versioning import util as migrate_util
|
||||
from sqlalchemy import create_engine
|
||||
import sqlalchemy
|
||||
|
||||
import nova.db.sqlalchemy.migrate_repo
|
||||
from nova import log as logging
|
||||
@ -68,7 +68,7 @@ if USE_MIGRATE_PATCH:
|
||||
|
||||
# NOTE(jkoelker) Delay importing migrate until we are patched
|
||||
from migrate.versioning import api as migration_api
|
||||
from migrate.versioning.repository import Repository
|
||||
from migrate.versioning import repository
|
||||
|
||||
|
||||
class TestMigrations(unittest.TestCase):
|
||||
@ -82,7 +82,8 @@ class TestMigrations(unittest.TestCase):
|
||||
CONFIG_FILE_PATH = os.environ.get('NOVA_TEST_MIGRATIONS_CONF',
|
||||
DEFAULT_CONFIG_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):
|
||||
super(TestMigrations, self).setUp()
|
||||
@ -108,7 +109,7 @@ class TestMigrations(unittest.TestCase):
|
||||
|
||||
self.engines = {}
|
||||
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.
|
||||
self._reset_databases()
|
||||
|
@ -27,7 +27,7 @@ from lxml import etree
|
||||
|
||||
from nova import log as logging
|
||||
from nova import test
|
||||
from nova.volume.netapp import NetAppISCSIDriver
|
||||
from nova.volume import netapp
|
||||
|
||||
LOG = logging.getLogger("nova.volume.driver")
|
||||
|
||||
@ -898,7 +898,7 @@ class NetAppDriverTestCase(test.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(NetAppDriverTestCase, self).setUp()
|
||||
driver = NetAppISCSIDriver()
|
||||
driver = netapp.NetAppISCSIDriver()
|
||||
self.stubs.Set(httplib, 'HTTPConnection', FakeHTTPConnection)
|
||||
driver._create_client('http://localhost:8088/dfm.wsdl',
|
||||
'root', 'password', 'localhost', 8088)
|
||||
|
@ -14,10 +14,9 @@
|
||||
# under the License.
|
||||
|
||||
import nova
|
||||
import nova.notifier.no_op_notifier
|
||||
from nova import log
|
||||
import nova.notifier.api
|
||||
from nova.notifier.api import notify
|
||||
import nova.notifier.no_op_notifier
|
||||
from nova.notifier import api as notifier_api
|
||||
from nova import test
|
||||
|
||||
|
||||
@ -36,7 +35,7 @@ class NotifierTestCase(test.TestCase):
|
||||
self.stubs.Set(nova.notifier.no_op_notifier, 'notify',
|
||||
mock_notify)
|
||||
|
||||
notify('publisher_id', 'event_type',
|
||||
notifier_api.notify('publisher_id', 'event_type',
|
||||
nova.notifier.api.WARN, dict(a=3))
|
||||
self.assertEqual(self.notify_called, True)
|
||||
|
||||
@ -56,7 +55,7 @@ class NotifierTestCase(test.TestCase):
|
||||
|
||||
self.stubs.Set(nova.notifier.no_op_notifier, 'notify',
|
||||
message_assert)
|
||||
notify('publisher_id', 'event_type',
|
||||
notifier_api.notify('publisher_id', 'event_type',
|
||||
nova.notifier.api.WARN, dict(a=3))
|
||||
|
||||
def test_send_rabbit_notification(self):
|
||||
@ -68,14 +67,14 @@ class NotifierTestCase(test.TestCase):
|
||||
self.mock_notify = True
|
||||
|
||||
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))
|
||||
|
||||
self.assertEqual(self.mock_notify, True)
|
||||
|
||||
def test_invalid_priority(self):
|
||||
self.assertRaises(nova.notifier.api.BadPriorityException,
|
||||
notify, 'publisher_id',
|
||||
notifier_api.notify, 'publisher_id',
|
||||
'event_type', 'not a priority', dict(a=3))
|
||||
|
||||
def test_rabbit_priority_queue(self):
|
||||
@ -90,7 +89,7 @@ class NotifierTestCase(test.TestCase):
|
||||
self.test_topic = topic
|
||||
|
||||
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')
|
||||
|
||||
def test_error_notification(self):
|
||||
|
@ -20,7 +20,7 @@ import mox
|
||||
from nova import context
|
||||
from nova import db
|
||||
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 flags
|
||||
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
|
||||
# can confuse these tests, so we remove all existing fixed
|
||||
# ips before starting.
|
||||
session = get_session()
|
||||
session = sql_session.get_session()
|
||||
result = session.query(models.FixedIp).all()
|
||||
with session.begin():
|
||||
for fip_ref in result:
|
||||
|
@ -24,7 +24,7 @@ from nova import flags
|
||||
from nova import log as logging
|
||||
from nova import test
|
||||
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
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
@ -75,7 +75,7 @@ class VolumeTypeTestCase(test.TestCase):
|
||||
|
||||
def test_get_all_volume_types(self):
|
||||
"""Ensures that all volume types can be retrieved"""
|
||||
session = get_session()
|
||||
session = sql_session.get_session()
|
||||
total_volume_types = session.query(models.VolumeTypes).count()
|
||||
vol_types = volume_types.get_all_types(self.ctxt)
|
||||
self.assertEqual(total_volume_types, len(vol_types))
|
||||
|
@ -36,7 +36,7 @@ class VsaTestCase(test.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(VsaTestCase, self).setUp()
|
||||
self.vsa_api = vsa.API()
|
||||
self.vsa_api = vsa.api.API()
|
||||
|
||||
self.flags(quota_volumes=100, quota_gigabytes=10000)
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
from nova import exception
|
||||
from nova import flags
|
||||
from nova import vsa
|
||||
from nova.vsa import api as vsa_api
|
||||
from nova import volume
|
||||
from nova import context
|
||||
from nova import test
|
||||
@ -30,7 +30,7 @@ class VsaVolumesTestCase(test.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(VsaVolumesTestCase, self).setUp()
|
||||
self.vsa_api = vsa.API()
|
||||
self.vsa_api = vsa_api.API()
|
||||
self.volume_api = volume.API()
|
||||
self.context = context.get_admin_context()
|
||||
|
||||
|
@ -26,7 +26,7 @@ from nova.network import linux_net
|
||||
from nova.openstack.common import cfg
|
||||
from nova import utils
|
||||
from nova.virt import netutils
|
||||
from nova.virt.vif import VIFDriver
|
||||
from nova.virt import vif
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -39,7 +39,7 @@ FLAGS = flags.FLAGS
|
||||
FLAGS.register_opt(libvirt_ovs_bridge_opt)
|
||||
|
||||
|
||||
class LibvirtBridgeDriver(VIFDriver):
|
||||
class LibvirtBridgeDriver(vif.VIFDriver):
|
||||
"""VIF driver for Linux bridge."""
|
||||
|
||||
def _get_configurations(self, network, mapping):
|
||||
@ -103,7 +103,7 @@ class LibvirtBridgeDriver(VIFDriver):
|
||||
pass
|
||||
|
||||
|
||||
class LibvirtOpenVswitchDriver(VIFDriver):
|
||||
class LibvirtOpenVswitchDriver(vif.VIFDriver):
|
||||
"""VIF driver for Open vSwitch that uses type='ethernet'
|
||||
libvirt XML. Used for libvirt versions that do not support
|
||||
OVS virtual port XML (0.9.10 or earlier)."""
|
||||
@ -158,7 +158,7 @@ class LibvirtOpenVswitchDriver(VIFDriver):
|
||||
instance['name'])
|
||||
|
||||
|
||||
class LibvirtOpenVswitchVirtualPortDriver(VIFDriver):
|
||||
class LibvirtOpenVswitchVirtualPortDriver(vif.VIFDriver):
|
||||
"""VIF driver for Open vSwitch that uses integrated libvirt
|
||||
OVS virtual port XML (introduced in libvirt 0.9.11)."""
|
||||
|
||||
@ -174,7 +174,7 @@ class LibvirtOpenVswitchVirtualPortDriver(VIFDriver):
|
||||
pass
|
||||
|
||||
|
||||
class QuantumLinuxBridgeVIFDriver(VIFDriver):
|
||||
class QuantumLinuxBridgeVIFDriver(vif.VIFDriver):
|
||||
"""VIF driver for Linux Bridge when running Quantum."""
|
||||
|
||||
def get_dev_name(self, iface_id):
|
||||
|
@ -19,7 +19,7 @@
|
||||
A fake VMWare VI API implementation.
|
||||
"""
|
||||
|
||||
from pprint import pformat
|
||||
import pprint
|
||||
import uuid
|
||||
|
||||
from nova import exception
|
||||
@ -40,7 +40,7 @@ LOG = logging.getLogger(__name__)
|
||||
def log_db_contents(msg=None):
|
||||
"""Log DB Contents."""
|
||||
text = msg or ""
|
||||
content = pformat(_db_content)
|
||||
content = pprint.pformat(_db_content)
|
||||
LOG.debug(_("%(text)s: _db_content => %(content)s") % locals())
|
||||
|
||||
|
||||
|
@ -22,7 +22,7 @@ to the write using a LightQueue as a Pipe between the reader and the writer.
|
||||
|
||||
from eventlet import event
|
||||
from eventlet import greenthread
|
||||
from eventlet.queue import LightQueue
|
||||
from eventlet import queue
|
||||
|
||||
from nova import exception
|
||||
from nova import log as logging
|
||||
@ -33,12 +33,12 @@ IO_THREAD_SLEEP_TIME = .01
|
||||
GLANCE_POLL_INTERVAL = 5
|
||||
|
||||
|
||||
class ThreadSafePipe(LightQueue):
|
||||
class ThreadSafePipe(queue.LightQueue):
|
||||
"""The pipe to hold the data which the reader writes to and the writer
|
||||
reads from."""
|
||||
|
||||
def __init__(self, maxsize, transfer_size):
|
||||
LightQueue.__init__(self, maxsize)
|
||||
queue.LightQueue.__init__(self, maxsize)
|
||||
self.transfer_size = transfer_size
|
||||
self.transferred = 0
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
from nova import exception
|
||||
from nova import flags
|
||||
from nova import log as logging
|
||||
from nova.virt.vif import VIFDriver
|
||||
from nova.virt import vif
|
||||
from nova.virt.vmwareapi import network_utils
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ FLAGS = flags.FLAGS
|
||||
FLAGS.set_default('vmwareapi_vlan_interface', 'vmnic0')
|
||||
|
||||
|
||||
class VMWareVlanBridgeDriver(VIFDriver):
|
||||
class VMWareVlanBridgeDriver(vif.VIFDriver):
|
||||
"""VIF Driver to setup bridge/VLAN networking using VMWare API."""
|
||||
|
||||
def plug(self, instance, network, mapping):
|
||||
|
@ -47,7 +47,7 @@ from nova.virt import driver
|
||||
from nova.virt.vmwareapi import error_util
|
||||
from nova.virt.vmwareapi import vim
|
||||
from nova.virt.vmwareapi import vim_util
|
||||
from nova.virt.vmwareapi.vmops import VMWareVMOps
|
||||
from nova.virt.vmwareapi import vmops
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -118,7 +118,7 @@ class VMWareESXConnection(driver.ComputeDriver):
|
||||
super(VMWareESXConnection, self).__init__()
|
||||
session = VMWareAPISession(host_ip, host_username, host_password,
|
||||
api_retry_count, scheme=scheme)
|
||||
self._vmops = VMWareVMOps(session)
|
||||
self._vmops = vmops.VMWareVMOps(session)
|
||||
|
||||
def init_host(self, host):
|
||||
"""Do the initialization that needs to be done."""
|
||||
|
@ -54,9 +54,9 @@ A fake XenAPI SDK.
|
||||
import json
|
||||
import random
|
||||
import uuid
|
||||
from xml.sax.saxutils import escape
|
||||
from xml.sax import saxutils
|
||||
|
||||
from pprint import pformat
|
||||
import pprint
|
||||
|
||||
from nova import exception
|
||||
from nova import log as logging
|
||||
@ -73,7 +73,7 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
def log_db_contents(msg=None):
|
||||
text = msg or ""
|
||||
content = pformat(_db_content)
|
||||
content = pprint.pformat(_db_content)
|
||||
LOG.debug(_("%(text)s: _db_content => %(content)s") % locals())
|
||||
|
||||
|
||||
@ -326,7 +326,7 @@ def check_for_session_leaks():
|
||||
def as_value(s):
|
||||
"""Helper function for simulating XenAPI plugin responses. It
|
||||
escapes and wraps the given argument."""
|
||||
return '<value>%s</value>' % escape(s)
|
||||
return '<value>%s</value>' % saxutils.escape(s)
|
||||
|
||||
|
||||
def as_json(*args, **kwargs):
|
||||
|
@ -25,7 +25,7 @@ from nova import flags
|
||||
from nova import log as logging
|
||||
from nova.db import api as db
|
||||
from nova.virt import netutils
|
||||
from nova.virt.firewall import IptablesFirewallDriver
|
||||
from nova.virt import firewall
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -37,7 +37,7 @@ drivers = ['nova.virt.firewall.IptablesFirewallDriver',
|
||||
'nova.virt.xenapi.firewall.Dom0IptablesFirewallDriver', ]
|
||||
|
||||
|
||||
class Dom0IptablesFirewallDriver(IptablesFirewallDriver):
|
||||
class Dom0IptablesFirewallDriver(firewall.IptablesFirewallDriver):
|
||||
""" Dom0IptablesFirewallDriver class
|
||||
|
||||
This class provides an implementation for nova.virt.Firewall
|
||||
|
@ -21,10 +21,10 @@ their lookup functions.
|
||||
"""
|
||||
|
||||
|
||||
from nova.virt.xenapi import HelperBase
|
||||
from nova.virt import xenapi
|
||||
|
||||
|
||||
class NetworkHelper(HelperBase):
|
||||
class NetworkHelper(xenapi.HelperBase):
|
||||
"""
|
||||
The class that wraps the helper methods together.
|
||||
"""
|
||||
|
@ -22,9 +22,9 @@
|
||||
from nova import flags
|
||||
from nova import log as logging
|
||||
from nova.openstack.common import cfg
|
||||
from nova.virt.vif import VIFDriver
|
||||
from nova.virt.xenapi.network_utils import NetworkHelper
|
||||
from nova.virt.xenapi.vm_utils import VMHelper
|
||||
from nova.virt import vif
|
||||
from nova.virt.xenapi import network_utils
|
||||
from nova.virt.xenapi import vm_utils
|
||||
|
||||
|
||||
xenapi_ovs_integration_bridge_opt = cfg.StrOpt('xenapi_ovs_integration_bridge',
|
||||
@ -36,7 +36,7 @@ FLAGS.register_opt(xenapi_ovs_integration_bridge_opt)
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class XenVIFDriver(VIFDriver):
|
||||
class XenVIFDriver(vif.VIFDriver):
|
||||
def __init__(self, xenapi_session):
|
||||
self._session = xenapi_session
|
||||
|
||||
@ -46,14 +46,14 @@ class XenAPIBridgeDriver(XenVIFDriver):
|
||||
|
||||
def plug(self, instance, network, mapping, vm_ref=None, device=None):
|
||||
if not vm_ref:
|
||||
vm_ref = VMHelper.lookup(self._session, instance.name)
|
||||
vm_ref = vm_utils.VMHelper.lookup(self._session, instance.name)
|
||||
if not device:
|
||||
device = 0
|
||||
|
||||
if mapping.get('should_create_vlan'):
|
||||
network_ref = self._ensure_vlan_bridge(network)
|
||||
else:
|
||||
network_ref = NetworkHelper.find_network_with_bridge(
|
||||
network_ref = network_utils.NetworkHelper.find_network_with_bridge(
|
||||
self._session, network['bridge'])
|
||||
vif_rec = {}
|
||||
vif_rec['device'] = str(device)
|
||||
@ -79,7 +79,7 @@ class XenAPIBridgeDriver(XenVIFDriver):
|
||||
bridge_interface = FLAGS.vlan_interface or network['bridge_interface']
|
||||
# Check whether bridge already exists
|
||||
# Retrieve network whose name_label is "bridge"
|
||||
network_ref = NetworkHelper.find_network_with_name_label(
|
||||
network_ref = network_utils.NetworkHelper.find_network_with_name_label(
|
||||
self._session, bridge)
|
||||
if network_ref is None:
|
||||
# If bridge does not exists
|
||||
@ -135,15 +135,15 @@ class XenAPIOpenVswitchDriver(XenVIFDriver):
|
||||
|
||||
def plug(self, instance, network, mapping, vm_ref=None, device=None):
|
||||
if not vm_ref:
|
||||
vm_ref = VMHelper.lookup(self._session, instance.name)
|
||||
vm_ref = vm_utils.VMHelper.lookup(self._session, instance.name)
|
||||
|
||||
if not device:
|
||||
device = 0
|
||||
|
||||
# with OVS model, always plug into an OVS integration bridge
|
||||
# that is already created
|
||||
network_ref = NetworkHelper.find_network_with_bridge(self._session,
|
||||
FLAGS.xenapi_ovs_integration_bridge)
|
||||
network_ref = network_utils.NetworkHelper.find_network_with_bridge(
|
||||
self._session, FLAGS.xenapi_ovs_integration_bridge)
|
||||
vif_rec = {}
|
||||
vif_rec['device'] = str(device)
|
||||
vif_rec['network'] = network_ref
|
||||
|
@ -21,7 +21,7 @@ their attributes like VDIs, VIFs, as well as their lookup functions.
|
||||
"""
|
||||
|
||||
import contextlib
|
||||
from decimal import Decimal, InvalidOperation
|
||||
import decimal
|
||||
import json
|
||||
import os
|
||||
import pickle
|
||||
@ -44,7 +44,7 @@ from nova import utils
|
||||
from nova.compute import instance_types
|
||||
from nova.compute import power_state
|
||||
from nova.virt.disk import api as disk
|
||||
from nova.virt.xenapi import HelperBase
|
||||
from nova.virt import xenapi
|
||||
from nova.virt.xenapi import volume_utils
|
||||
|
||||
|
||||
@ -132,7 +132,7 @@ class ImageType:
|
||||
return dict(zip(ImageType._strs, ImageType._ids)).get(image_type_str)
|
||||
|
||||
|
||||
class VMHelper(HelperBase):
|
||||
class VMHelper(xenapi.HelperBase):
|
||||
"""
|
||||
The class that wraps the helper methods together.
|
||||
"""
|
||||
@ -1251,7 +1251,7 @@ def parse_rrd_data(doc):
|
||||
dnode = doc.getElementsByTagName('data')[0]
|
||||
return [dict(
|
||||
time=int(child.getElementsByTagName('t')[0].firstChild.data),
|
||||
values=[Decimal(valnode.firstChild.data)
|
||||
values=[decimal.Decimal(valnode.firstChild.data)
|
||||
for valnode in child.getElementsByTagName('v')])
|
||||
for child in dnode.childNodes]
|
||||
|
||||
@ -1277,8 +1277,8 @@ def average_series(data, col, until=None):
|
||||
row['values'][col].is_finite()]
|
||||
if vals:
|
||||
try:
|
||||
return (sum(vals) / len(vals)).quantize(Decimal('1.0000'))
|
||||
except InvalidOperation:
|
||||
return (sum(vals) / len(vals)).quantize(decimal.Decimal('1.0000'))
|
||||
except decimal.InvalidOperation:
|
||||
# (mdragon) Xenserver occasionally returns odd values in
|
||||
# data that will throw an error on averaging (see bug 918490)
|
||||
# These are hard to find, since, whatever those values are,
|
||||
@ -1288,13 +1288,13 @@ def average_series(data, col, until=None):
|
||||
# other statistics.
|
||||
LOG.error(_("Invalid statistics data from Xenserver: %s")
|
||||
% str(vals))
|
||||
return Decimal('NaN')
|
||||
return decimal.Decimal('NaN')
|
||||
else:
|
||||
return Decimal('0.0000')
|
||||
return decimal.Decimal('0.0000')
|
||||
|
||||
|
||||
def integrate_series(data, col, start, until=None):
|
||||
total = Decimal('0.0000')
|
||||
total = decimal.Decimal('0.0000')
|
||||
prev_time = int(start)
|
||||
prev_val = None
|
||||
for row in reversed(data):
|
||||
@ -1302,20 +1302,20 @@ def integrate_series(data, col, start, until=None):
|
||||
time = row['time']
|
||||
val = row['values'][col]
|
||||
if val.is_nan():
|
||||
val = Decimal('0.0000')
|
||||
val = decimal.Decimal('0.0000')
|
||||
if prev_val is None:
|
||||
prev_val = val
|
||||
if prev_val >= val:
|
||||
total += ((val * (time - prev_time)) +
|
||||
(Decimal('0.5000') * (prev_val - val) *
|
||||
(decimal.Decimal('0.5000') * (prev_val - val) *
|
||||
(time - prev_time)))
|
||||
else:
|
||||
total += ((prev_val * (time - prev_time)) +
|
||||
(Decimal('0.5000') * (val - prev_val) *
|
||||
(decimal.Decimal('0.5000') * (val - prev_val) *
|
||||
(time - prev_time)))
|
||||
prev_time = time
|
||||
prev_val = val
|
||||
return total.quantize(Decimal('1.0000'))
|
||||
return total.quantize(decimal.Decimal('1.0000'))
|
||||
|
||||
|
||||
def _get_all_vdis_in_sr(session, sr_ref):
|
||||
|
@ -28,7 +28,7 @@ from nova import exception
|
||||
from nova import flags
|
||||
from nova import log as logging
|
||||
from nova import utils
|
||||
from nova.virt.xenapi import HelperBase
|
||||
from nova.virt import xenapi
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -41,7 +41,7 @@ class StorageError(Exception):
|
||||
super(StorageError, self).__init__(message)
|
||||
|
||||
|
||||
class VolumeHelper(HelperBase):
|
||||
class VolumeHelper(xenapi.HelperBase):
|
||||
"""
|
||||
The class that wraps the helper methods together.
|
||||
"""
|
||||
|
@ -20,9 +20,8 @@ Management class for Storage-related functions (attach, detach, etc).
|
||||
|
||||
from nova import exception
|
||||
from nova import log as logging
|
||||
from nova.virt.xenapi.vm_utils import VMHelper
|
||||
from nova.virt.xenapi.volume_utils import VolumeHelper
|
||||
from nova.virt.xenapi.volume_utils import StorageError
|
||||
from nova.virt.xenapi import vm_utils
|
||||
from nova.virt.xenapi import volume_utils
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -37,8 +36,8 @@ class VolumeOps(object):
|
||||
self.XenAPI = session.get_imported_xenapi()
|
||||
self._session = session
|
||||
# Load XenAPI module in the helper classes respectively
|
||||
VolumeHelper.XenAPI = self.XenAPI
|
||||
VMHelper.XenAPI = self.XenAPI
|
||||
volume_utils.VolumeHelper.XenAPI = self.XenAPI
|
||||
vm_utils.VMHelper.XenAPI = self.XenAPI
|
||||
|
||||
def create_volume_for_sm(self, volume, sr_uuid):
|
||||
LOG.debug("Creating volume for Storage Manager")
|
||||
@ -48,13 +47,13 @@ class VolumeOps(object):
|
||||
sr_ref = self._session.call_xenapi("SR.get_by_uuid", sr_uuid)
|
||||
except self.XenAPI.Failure, exc:
|
||||
LOG.exception(exc)
|
||||
raise StorageError(_('Unable to get SR using uuid'))
|
||||
raise volume_utils.StorageError(_('Unable to get SR using uuid'))
|
||||
#Create VDI
|
||||
label = 'vol-' + hex(volume['id'])[:-1]
|
||||
# size presented to xenapi is in bytes, while euca api is in GB
|
||||
vdi_size = volume['size'] * 1024 * 1024 * 1024
|
||||
vdi_ref = VMHelper.create_vdi(self._session, sr_ref, label, vdi_size,
|
||||
False)
|
||||
vdi_ref = vm_utils.VMHelper.create_vdi(self._session,
|
||||
sr_ref, label, vdi_size, False)
|
||||
vdi_rec = self._session.call_xenapi("VDI.get_record", vdi_ref)
|
||||
sm_vol_rec['vdi_uuid'] = vdi_rec['uuid']
|
||||
return sm_vol_rec
|
||||
@ -68,11 +67,12 @@ class VolumeOps(object):
|
||||
self._session.call_xenapi("VDI.destroy", vdi_ref)
|
||||
except self.XenAPI.Failure, exc:
|
||||
LOG.exception(exc)
|
||||
raise StorageError(_('Error destroying VDI'))
|
||||
raise volume_utils.StorageError(_('Error destroying VDI'))
|
||||
|
||||
def create_sr(self, label, params):
|
||||
LOG.debug(_("Creating SR %s") % label)
|
||||
sr_ref = VolumeHelper.create_sr(self._session, label, params)
|
||||
sr_ref = volume_utils.VolumeHelper.create_sr(self._session,
|
||||
label, params)
|
||||
if sr_ref is None:
|
||||
raise exception.Error(_('Could not create SR'))
|
||||
sr_rec = self._session.call_xenapi("SR.get_record", sr_ref)
|
||||
@ -83,39 +83,42 @@ class VolumeOps(object):
|
||||
# Checks if sr has already been introduced to this host
|
||||
def introduce_sr(self, sr_uuid, label, params):
|
||||
LOG.debug(_("Introducing SR %s") % label)
|
||||
sr_ref = VolumeHelper.find_sr_by_uuid(self._session, sr_uuid)
|
||||
sr_ref = volume_utils.VolumeHelper.find_sr_by_uuid(self._session,
|
||||
sr_uuid)
|
||||
if sr_ref:
|
||||
LOG.debug(_('SR found in xapi database. No need to introduce'))
|
||||
return sr_ref
|
||||
sr_ref = VolumeHelper.introduce_sr(self._session, sr_uuid, label,
|
||||
params)
|
||||
sr_ref = volume_utils.VolumeHelper.introduce_sr(self._session,
|
||||
sr_uuid, label, params)
|
||||
if sr_ref is None:
|
||||
raise exception.Error(_('Could not introduce SR'))
|
||||
return sr_ref
|
||||
|
||||
def is_sr_on_host(self, sr_uuid):
|
||||
LOG.debug(_('Checking for SR %s') % sr_uuid)
|
||||
sr_ref = VolumeHelper.find_sr_by_uuid(self._session, sr_uuid)
|
||||
sr_ref = volume_utils.VolumeHelper.find_sr_by_uuid(self._session,
|
||||
sr_uuid)
|
||||
if sr_ref:
|
||||
return True
|
||||
return False
|
||||
|
||||
# Checks if sr has been introduced
|
||||
def forget_sr(self, sr_uuid):
|
||||
sr_ref = VolumeHelper.find_sr_by_uuid(self._session, sr_uuid)
|
||||
sr_ref = volume_utils.VolumeHelper.find_sr_by_uuid(self._session,
|
||||
sr_uuid)
|
||||
if sr_ref is None:
|
||||
LOG.INFO(_('SR %s not found in the xapi database') % sr_uuid)
|
||||
return
|
||||
try:
|
||||
VolumeHelper.forget_sr(self._session, sr_uuid)
|
||||
except StorageError, exc:
|
||||
volume_utils.VolumeHelper.forget_sr(self._session, sr_uuid)
|
||||
except volume_utils.StorageError, exc:
|
||||
LOG.exception(exc)
|
||||
raise exception.Error(_('Could not forget SR'))
|
||||
|
||||
def attach_volume(self, connection_info, instance_name, mountpoint):
|
||||
"""Attach volume storage to VM instance"""
|
||||
# Before we start, check that the VM exists
|
||||
vm_ref = VMHelper.lookup(self._session, instance_name)
|
||||
vm_ref = vm_utils.VMHelper.lookup(self._session, instance_name)
|
||||
if vm_ref is None:
|
||||
raise exception.InstanceNotFound(instance_id=instance_name)
|
||||
# NOTE: No Resource Pool concept so far
|
||||
@ -140,8 +143,8 @@ class VolumeOps(object):
|
||||
LOG.debug(connection_info)
|
||||
sr_params = {}
|
||||
if u'sr_uuid' not in data:
|
||||
sr_params = VolumeHelper.parse_volume_info(connection_info,
|
||||
mountpoint)
|
||||
sr_params = volume_utils.VolumeHelper.parse_volume_info(
|
||||
connection_info, mountpoint)
|
||||
uuid = "FA15E-D15C-" + str(sr_params['id'])
|
||||
sr_params['sr_type'] = 'iscsi'
|
||||
else:
|
||||
@ -157,7 +160,8 @@ class VolumeOps(object):
|
||||
LOG.debug(_('Introduced %(label)s as %(sr_ref)s.') % locals())
|
||||
except self.XenAPI.Failure, exc:
|
||||
LOG.exception(exc)
|
||||
raise StorageError(_('Unable to introduce Storage Repository'))
|
||||
raise volume_utils.StorageError(
|
||||
_('Unable to introduce Storage Repository'))
|
||||
|
||||
vdi_uuid = None
|
||||
target_lun = None
|
||||
@ -170,22 +174,21 @@ class VolumeOps(object):
|
||||
|
||||
# Introduce VDI and attach VBD to VM
|
||||
try:
|
||||
vdi_ref = VolumeHelper.introduce_vdi(self._session, sr_ref,
|
||||
vdi_uuid,
|
||||
target_lun)
|
||||
except StorageError, exc:
|
||||
vdi_ref = volume_utils.VolumeHelper.introduce_vdi(self._session,
|
||||
sr_ref, vdi_uuid, target_lun)
|
||||
except volume_utils.StorageError, exc:
|
||||
LOG.exception(exc)
|
||||
self.forget_sr(uuid)
|
||||
raise Exception(_('Unable to create VDI on SR %(sr_ref)s for'
|
||||
' instance %(instance_name)s') % locals())
|
||||
|
||||
dev_number = VolumeHelper.mountpoint_to_number(mountpoint)
|
||||
dev_number = volume_utils.VolumeHelper.mountpoint_to_number(mountpoint)
|
||||
try:
|
||||
vbd_ref = VolumeHelper.create_vbd(self._session,
|
||||
vm_ref,
|
||||
vdi_ref,
|
||||
dev_number,
|
||||
False)
|
||||
vbd_ref = volume_utils.VolumeHelper.create_vbd(self._session,
|
||||
vm_ref,
|
||||
vdi_ref,
|
||||
dev_number,
|
||||
False)
|
||||
except self.XenAPI.Failure, exc:
|
||||
LOG.exception(exc)
|
||||
self.forget_sr(uuid)
|
||||
@ -206,37 +209,38 @@ class VolumeOps(object):
|
||||
def detach_volume(self, connection_info, instance_name, mountpoint):
|
||||
"""Detach volume storage to VM instance"""
|
||||
# Before we start, check that the VM exists
|
||||
vm_ref = VMHelper.lookup(self._session, instance_name)
|
||||
vm_ref = vm_utils.VMHelper.lookup(self._session, instance_name)
|
||||
if vm_ref is None:
|
||||
raise exception.InstanceNotFound(instance_id=instance_name)
|
||||
# Detach VBD from VM
|
||||
LOG.debug(_("Detach_volume: %(instance_name)s, %(mountpoint)s")
|
||||
% locals())
|
||||
device_number = VolumeHelper.mountpoint_to_number(mountpoint)
|
||||
device_number = volume_utils.VolumeHelper.mountpoint_to_number(
|
||||
mountpoint)
|
||||
try:
|
||||
vbd_ref = VMHelper.find_vbd_by_number(self._session,
|
||||
vbd_ref = vm_utils.VMHelper.find_vbd_by_number(self._session,
|
||||
vm_ref, device_number)
|
||||
except StorageError, exc:
|
||||
except volume_utils.StorageError, exc:
|
||||
LOG.exception(exc)
|
||||
raise Exception(_('Unable to locate volume %s') % mountpoint)
|
||||
|
||||
try:
|
||||
sr_ref = VolumeHelper.find_sr_from_vbd(self._session,
|
||||
vbd_ref)
|
||||
VMHelper.unplug_vbd(self._session, vbd_ref)
|
||||
except StorageError, exc:
|
||||
sr_ref = volume_utils.VolumeHelper.find_sr_from_vbd(self._session,
|
||||
vbd_ref)
|
||||
vm_utils.VMHelper.unplug_vbd(self._session, vbd_ref)
|
||||
except volume_utils.StorageError, exc:
|
||||
LOG.exception(exc)
|
||||
raise Exception(_('Unable to detach volume %s') % mountpoint)
|
||||
try:
|
||||
VMHelper.destroy_vbd(self._session, vbd_ref)
|
||||
except StorageError, exc:
|
||||
vm_utils.VMHelper.destroy_vbd(self._session, vbd_ref)
|
||||
except volume_utils.StorageError, exc:
|
||||
LOG.exception(exc)
|
||||
raise Exception(_('Unable to destroy vbd %s') % mountpoint)
|
||||
|
||||
# Forget SR only if no other volumes on this host are using it
|
||||
try:
|
||||
VolumeHelper.purge_sr(self._session, sr_ref)
|
||||
except StorageError, exc:
|
||||
volume_utils.VolumeHelper.purge_sr(self._session, sr_ref)
|
||||
except volume_utils.StorageError, exc:
|
||||
LOG.exception(exc)
|
||||
raise Exception(_('Error purging SR %s') % sr_ref)
|
||||
|
||||
|
@ -77,8 +77,8 @@ from nova.virt import driver
|
||||
from nova.virt.xenapi import host
|
||||
from nova.virt.xenapi import pool
|
||||
from nova.virt.xenapi import vm_utils
|
||||
from nova.virt.xenapi.vmops import VMOps
|
||||
from nova.virt.xenapi.volumeops import VolumeOps
|
||||
from nova.virt.xenapi import vmops
|
||||
from nova.virt.xenapi import volumeops
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -173,11 +173,11 @@ class XenAPIConnection(driver.ComputeDriver):
|
||||
def __init__(self, url, user, pw):
|
||||
super(XenAPIConnection, self).__init__()
|
||||
self._session = XenAPISession(url, user, pw)
|
||||
self._volumeops = VolumeOps(self._session)
|
||||
self._volumeops = volumeops.VolumeOps(self._session)
|
||||
self._host_state = None
|
||||
self._host = host.Host(self._session)
|
||||
self._product_version = self._session.get_product_version()
|
||||
self._vmops = VMOps(self._session, self._product_version)
|
||||
self._vmops = vmops.VMOps(self._session, self._product_version)
|
||||
self._initiator = None
|
||||
self._pool = pool.ResourcePool(self._session)
|
||||
|
||||
|
@ -37,8 +37,7 @@ from nova import flags
|
||||
from nova import log as logging
|
||||
from nova.openstack.common import cfg
|
||||
from nova import utils
|
||||
from nova.utils import ssh_execute
|
||||
from nova.volume.driver import ISCSIDriver
|
||||
import nova.volume.driver
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -78,7 +77,7 @@ FLAGS = flags.FLAGS
|
||||
FLAGS.register_opts(san_opts)
|
||||
|
||||
|
||||
class SanISCSIDriver(ISCSIDriver):
|
||||
class SanISCSIDriver(nova.volume.driver.ISCSIDriver):
|
||||
"""Base class for SAN-style storage volumes
|
||||
|
||||
A SAN-style storage value is 'different' because the volume controller
|
||||
@ -127,7 +126,7 @@ class SanISCSIDriver(ISCSIDriver):
|
||||
ssh = self._connect_to_ssh()
|
||||
|
||||
#TODO(justinsb): Reintroduce the retry hack
|
||||
ret = ssh_execute(ssh, command, check_exit_code=check_exit_code)
|
||||
ret = utils.ssh_execute(ssh, command, check_exit_code=check_exit_code)
|
||||
|
||||
ssh.close()
|
||||
|
||||
|
@ -16,15 +16,15 @@ from nova import exception
|
||||
from nova import flags
|
||||
from nova import log as logging
|
||||
from nova import utils
|
||||
from nova.volume.driver import VolumeDriver
|
||||
from nova.virt.xenapi_conn import XenAPISession
|
||||
from nova.virt.xenapi.volumeops import VolumeOps
|
||||
from nova.virt import xenapi_conn
|
||||
from nova.virt.xenapi import volumeops
|
||||
import nova.volume.driver
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
FLAGS = flags.FLAGS
|
||||
|
||||
|
||||
class XenSMDriver(VolumeDriver):
|
||||
class XenSMDriver(nova.volume.driver.VolumeDriver):
|
||||
|
||||
def _convert_config_params(self, conf_str):
|
||||
params = dict([item.split("=") for item in conf_str.split()])
|
||||
@ -103,8 +103,8 @@ class XenSMDriver(VolumeDriver):
|
||||
username = FLAGS.xenapi_connection_username
|
||||
password = FLAGS.xenapi_connection_password
|
||||
try:
|
||||
session = XenAPISession(url, username, password)
|
||||
self._volumeops = VolumeOps(session)
|
||||
session = xenapi_conn.XenAPISession(url, username, password)
|
||||
self._volumeops = volumeops.VolumeOps(session)
|
||||
except Exception as ex:
|
||||
LOG.exception(ex)
|
||||
raise exception.Error(_("Failed to initiate session"))
|
||||
|
@ -14,5 +14,3 @@
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from nova.vsa.api import API
|
||||
|
@ -29,11 +29,10 @@ from nova import log as logging
|
||||
from nova import manager
|
||||
from nova.openstack.common import cfg
|
||||
from nova import volume
|
||||
from nova import vsa
|
||||
from nova import utils
|
||||
from nova.compute import instance_types
|
||||
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',
|
||||
default='nova.vsa.connection.get_connection',
|
||||
@ -56,7 +55,7 @@ class VsaManager(manager.SchedulerDependentManager):
|
||||
|
||||
self.compute_api = compute.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:
|
||||
raise exception.VSANovaAccessParamNotFound()
|
||||
@ -122,9 +121,9 @@ class VsaManager(manager.SchedulerDependentManager):
|
||||
"""Start VCs for VSA """
|
||||
|
||||
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,
|
||||
VsaState.LAUNCHING)
|
||||
vsa_api.VsaState.LAUNCHING)
|
||||
else:
|
||||
return
|
||||
|
||||
@ -153,7 +152,7 @@ class VsaManager(manager.SchedulerDependentManager):
|
||||
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.update_vsa_status(context, vsa_id,
|
||||
VsaState.FAILED)
|
||||
vsa_api.VsaState.FAILED)
|
||||
return
|
||||
|
||||
# create user-data record for VC
|
||||
@ -179,4 +178,4 @@ class VsaManager(manager.SchedulerDependentManager):
|
||||
metadata=dict(vsa_id=str(vsa_id)))
|
||||
|
||||
self.vsa_api.update_vsa_status(context, vsa_id,
|
||||
VsaState.CREATED)
|
||||
vsa_api.VsaState.CREATED)
|
||||
|
@ -24,21 +24,21 @@ This script is used to configure base openvswitch flows for XenServer hosts.
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
from novalib import execute, execute_get_output
|
||||
import novalib
|
||||
|
||||
|
||||
def main(command, phys_dev_name):
|
||||
ovs_ofctl = lambda *rule: execute('/usr/bin/ovs-ofctl', *rule)
|
||||
ovs_ofctl = lambda *rule: novalib.execute('/usr/bin/ovs-ofctl', *rule)
|
||||
|
||||
bridge_name = \
|
||||
execute_get_output('/usr/bin/ovs-vsctl', 'iface-to-br', phys_dev_name)
|
||||
novalib.execute_get_output('/usr/bin/ovs-vsctl',
|
||||
'iface-to-br', phys_dev_name)
|
||||
|
||||
# always clear all flows first
|
||||
ovs_ofctl('del-flows', bridge_name)
|
||||
|
||||
if command in ('online', 'reset'):
|
||||
pnic_ofport = execute_get_output('/usr/bin/ovs-vsctl', 'get',
|
||||
pnic_ofport = novalib.execute_get_output('/usr/bin/ovs-vsctl', 'get',
|
||||
'Interface', phys_dev_name, 'ofport')
|
||||
|
||||
# these flows are lower priority than all VM-specific flows.
|
||||
@ -51,8 +51,8 @@ def main(command, phys_dev_name):
|
||||
# Allow traffic from dom0 if there is a management interface
|
||||
# present (its IP address is on the bridge itself)
|
||||
bridge_addr = \
|
||||
execute_get_output('/sbin/ip', '-o', '-f', 'inet', 'addr', 'show',
|
||||
bridge_name)
|
||||
novalib.execute_get_output('/sbin/ip', '-o', '-f', 'inet', 'addr',
|
||||
'show', bridge_name)
|
||||
if bridge_addr != '':
|
||||
ovs_ofctl('add-flow', bridge_name,
|
||||
"priority=2,in_port=LOCAL,actions=normal")
|
||||
|
@ -21,13 +21,12 @@ This script is used to configure openvswitch flows on XenServer hosts.
|
||||
"""
|
||||
|
||||
import os
|
||||
import simplejson as json
|
||||
import sys
|
||||
|
||||
# This is written to Python 2.4, since that is what is available on XenServer
|
||||
import netaddr
|
||||
import simplejson as json
|
||||
|
||||
from novalib import execute, execute_get_output
|
||||
import novalib
|
||||
|
||||
|
||||
OVS_OFCTL = '/usr/bin/ovs-ofctl'
|
||||
@ -39,10 +38,11 @@ class OvsFlow(object):
|
||||
self.params = params
|
||||
|
||||
def add(self, rule):
|
||||
execute(OVS_OFCTL, 'add-flow', self.bridge, rule % self.params)
|
||||
novalib.execute(OVS_OFCTL, 'add-flow', self.bridge, rule % self.params)
|
||||
|
||||
def clear_flows(self, ofport):
|
||||
execute(OVS_OFCTL, 'del-flows', self.bridge, "in_port=%s" % ofport)
|
||||
novalib.execute(OVS_OFCTL, 'del-flows',
|
||||
self.bridge, "in_port=%s" % ofport)
|
||||
|
||||
|
||||
def main(command, vif_raw, net_type):
|
||||
@ -52,14 +52,15 @@ def main(command, vif_raw, net_type):
|
||||
vif_name, dom_id, vif_index = vif_raw.split('-')
|
||||
vif = "%s%s.%s" % (vif_name, dom_id, vif_index)
|
||||
|
||||
bridge = execute_get_output('/usr/bin/ovs-vsctl', 'iface-to-br', vif)
|
||||
bridge = novalib.execute_get_output('/usr/bin/ovs-vsctl',
|
||||
'iface-to-br', vif)
|
||||
|
||||
xsls = execute_get_output('/usr/bin/xenstore-ls',
|
||||
xsls = novalib.execute_get_output('/usr/bin/xenstore-ls',
|
||||
'/local/domain/%s/vm-data/networking' % dom_id)
|
||||
macs = [line.split("=")[0].strip() for line in xsls.splitlines()]
|
||||
|
||||
for mac in macs:
|
||||
xsread = execute_get_output('/usr/bin/xenstore-read',
|
||||
xsread = novalib.execute_get_output('/usr/bin/xenstore-read',
|
||||
'/local/domain/%s/vm-data/networking/%s' %
|
||||
(dom_id, mac))
|
||||
data = json.loads(xsread)
|
||||
@ -71,10 +72,10 @@ def main(command, vif_raw, net_type):
|
||||
phys_dev = "eth1"
|
||||
|
||||
if vif == this_vif:
|
||||
vif_ofport = execute_get_output('/usr/bin/ovs-vsctl', 'get',
|
||||
'Interface', vif, 'ofport')
|
||||
phys_ofport = execute_get_output('/usr/bin/ovs-vsctl', 'get',
|
||||
'Interface', phys_dev, 'ofport')
|
||||
vif_ofport = novalib.execute_get_output('/usr/bin/ovs-vsctl',
|
||||
'get', 'Interface', vif, 'ofport')
|
||||
phys_ofport = novalib.execute_get_output('/usr/bin/ovs-vsctl',
|
||||
'get', 'Interface', phys_dev, 'ofport')
|
||||
|
||||
params = dict(VIF_NAME=vif,
|
||||
MAC=data['mac'],
|
||||
|
@ -24,20 +24,19 @@ XenServer hosts.
|
||||
import os
|
||||
import sys
|
||||
|
||||
import novalib
|
||||
|
||||
# This is written to Python 2.4, since that is what is available on XenServer
|
||||
import simplejson as json
|
||||
|
||||
|
||||
from novalib import execute, execute_get_output
|
||||
|
||||
|
||||
def main(dom_id, command, only_this_vif=None):
|
||||
xsls = execute_get_output('/usr/bin/xenstore-ls',
|
||||
xsls = novalib.execute_get_output('/usr/bin/xenstore-ls',
|
||||
'/local/domain/%s/vm-data/networking' % dom_id)
|
||||
macs = [line.split("=")[0].strip() for line in xsls.splitlines()]
|
||||
|
||||
for mac in macs:
|
||||
xsread = execute_get_output('/usr/bin/xenstore-read',
|
||||
xsread = novalib.execute_get_output('/usr/bin/xenstore-read',
|
||||
'/local/domain/%s/vm-data/networking/%s' %
|
||||
(dom_id, mac))
|
||||
data = json.loads(xsread)
|
||||
@ -60,7 +59,7 @@ def main(dom_id, command, only_this_vif=None):
|
||||
|
||||
|
||||
def apply_iptables_rules(command, params):
|
||||
iptables = lambda *rule: execute('/sbin/iptables', *rule)
|
||||
iptables = lambda *rule: novalib.execute('/sbin/iptables', *rule)
|
||||
|
||||
iptables('-D', 'FORWARD', '-m', 'physdev',
|
||||
'--physdev-in', params['VIF'],
|
||||
@ -74,7 +73,7 @@ def apply_iptables_rules(command, params):
|
||||
|
||||
|
||||
def apply_arptables_rules(command, params):
|
||||
arptables = lambda *rule: execute('/sbin/arptables', *rule)
|
||||
arptables = lambda *rule: novalib.execute('/sbin/arptables', *rule)
|
||||
|
||||
arptables('-D', 'FORWARD', '--opcode', 'Request',
|
||||
'--in-interface', params['VIF'],
|
||||
@ -99,7 +98,7 @@ def apply_arptables_rules(command, params):
|
||||
|
||||
|
||||
def apply_ebtables_rules(command, params):
|
||||
ebtables = lambda *rule: execute("/sbin/ebtables", *rule)
|
||||
ebtables = lambda *rule: novalib.execute("/sbin/ebtables", *rule)
|
||||
|
||||
ebtables('-D', 'FORWARD', '-p', '0806', '-o', params['VIF'],
|
||||
'--arp-ip-dst', params['IP'],
|
||||
|
12
setup.py
12
setup.py
@ -19,18 +19,16 @@
|
||||
import glob
|
||||
import os
|
||||
|
||||
from setuptools import find_packages
|
||||
|
||||
from setuptools import setup
|
||||
import setuptools
|
||||
|
||||
from nova import version
|
||||
|
||||
nova_cmdclass = {}
|
||||
|
||||
try:
|
||||
from sphinx.setup_command import BuildDoc
|
||||
from sphinx import setup_command
|
||||
|
||||
class local_BuildDoc(BuildDoc):
|
||||
class local_BuildDoc(setup_command.BuildDoc):
|
||||
def run(self):
|
||||
for builder in ['html', 'man']:
|
||||
self.builder = builder
|
||||
@ -55,14 +53,14 @@ def find_data_files(destdir, srcdir):
|
||||
return package_data
|
||||
|
||||
|
||||
setup(name='nova',
|
||||
setuptools.setup(name='nova',
|
||||
version=version.canonical_version_string(),
|
||||
description='cloud computing fabric controller',
|
||||
author='OpenStack',
|
||||
author_email='nova@lists.launchpad.net',
|
||||
url='http://www.openstack.org/',
|
||||
cmdclass=nova_cmdclass,
|
||||
packages=find_packages(exclude=['bin', 'smoketests']),
|
||||
packages=setuptools.find_packages(exclude=['bin', 'smoketests']),
|
||||
include_package_data=True,
|
||||
test_suite='nose.collector',
|
||||
scripts=['bin/clear_rabbit_queues',
|
||||
|
@ -1,3 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
# Copyright (c) 2012, Cloudscaling
|
||||
@ -24,10 +25,10 @@ import inspect
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
import pep8
|
||||
|
||||
|
||||
#N1xx comments
|
||||
#N2xx except
|
||||
#N3xx imports
|
||||
@ -118,14 +119,14 @@ def nova_import_module_only(logical_line):
|
||||
return logical_line.find(mod), ("NOVA N302: import only "
|
||||
"modules. '%s' does not import a module" % logical_line)
|
||||
|
||||
except (ImportError, NameError):
|
||||
except (ImportError, NameError) as exc:
|
||||
if not added:
|
||||
added = True
|
||||
sys.path.append(current_path)
|
||||
return importModuleCheck(mod, parent, added)
|
||||
else:
|
||||
print >> sys.stderr, ("ERROR: import '%s' failed, couldn't "
|
||||
"find module" % logical_line)
|
||||
print >> sys.stderr, ("ERROR: import '%s' failed: %s" %
|
||||
(logical_line, exc))
|
||||
added = False
|
||||
sys.path.pop()
|
||||
return
|
||||
@ -149,6 +150,7 @@ def nova_import_module_only(logical_line):
|
||||
# handle "from x import y as z"
|
||||
elif (logical_line.startswith("from ") and "," not in logical_line and
|
||||
split_line[2] == "import" and split_line[3] != "*" and
|
||||
split_line[1] != "__future__" and
|
||||
(len(split_line) == 4 or
|
||||
(len(split_line) == 6 and split_line[4] == "as"))):
|
||||
mod = split_line[3]
|
||||
|
Loading…
x
Reference in New Issue
Block a user