diff --git a/etc/nova/nova.conf.sample b/etc/nova/nova.conf.sample index 13cc5289d694..2580fafc9067 100644 --- a/etc/nova/nova.conf.sample +++ b/etc/nova/nova.conf.sample @@ -73,10 +73,6 @@ ######## defined in nova.flags ######## -# connection_type= -#### (StrOpt) Deprecated (use compute_driver instead): Virtualization api -#### connection type : libvirt, xenapi, or fake - # sql_connection=sqlite:///$state_path/$sqlite_db #### (StrOpt) The SQLAlchemy connection string used to connect to the #### database diff --git a/nova/compute/manager.py b/nova/compute/manager.py index f9c7390013eb..9f311e881f50 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -85,7 +85,6 @@ compute_opts = [ "This is NOT the full path - just a folder name." "For per-compute-host cached images, set to _base_$my_ip"), cfg.StrOpt('compute_driver', - default='nova.virt.connection.get_connection', help='Driver to use for controlling virtualization. Options ' 'include: libvirt.LibvirtDriver, xenapi.XenAPIDriver, ' 'fake.FakeDriver, baremetal.BareMetalDriver, ' diff --git a/nova/compute/utils.py b/nova/compute/utils.py index a8a0a654480e..17416f991922 100644 --- a/nova/compute/utils.py +++ b/nova/compute/utils.py @@ -81,8 +81,7 @@ def get_device_name_for_instance(context, instance, device): except (TypeError, AttributeError, ValueError): raise exception.InvalidDevicePath(path=mappings['root']) # NOTE(vish): remove this when xenapi is setting default_root_device - if (FLAGS.connection_type == 'xenapi' or - FLAGS.compute_driver.endswith('xenapi.XenAPIDriver')): + if FLAGS.compute_driver.endswith('xenapi.XenAPIDriver'): prefix = '/dev/xvd' if req_prefix != prefix: LOG.debug(_("Using %(prefix)s instead of %(req_prefix)s") % locals()) @@ -97,8 +96,7 @@ def get_device_name_for_instance(context, instance, device): # NOTE(vish): remove this when xenapi is properly setting # default_ephemeral_device and default_swap_device - if (FLAGS.connection_type == 'xenapi' or - FLAGS.compute_driver.endswith('xenapi.XenAPIDriver')): + if FLAGS.compute_driver.endswith('xenapi.XenAPIDriver'): instance_type_id = instance['instance_type_id'] instance_type = instance_types.get_instance_type(instance_type_id) if instance_type['ephemeral_gb']: diff --git a/nova/db/sqlalchemy/migrate_repo/versions/082_essex.py b/nova/db/sqlalchemy/migrate_repo/versions/082_essex.py index 13dc02e9c221..971fa3626197 100644 --- a/nova/db/sqlalchemy/migrate_repo/versions/082_essex.py +++ b/nova/db/sqlalchemy/migrate_repo/versions/082_essex.py @@ -30,16 +30,7 @@ LOG = logging.getLogger(__name__) # of integral type, so is no longer set explicitly in such cases. def _populate_instance_types(instance_types_table): - if FLAGS.connection_type == "libvirt": - default_inst_types = { - 'm1.tiny': dict(mem=512, vcpus=1, root_gb=0, eph_gb=0, flavid=1), - 'm1.small': dict(mem=2048, vcpus=1, root_gb=10, eph_gb=20, flavid=2), - 'm1.medium': dict(mem=4096, vcpus=2, root_gb=10, eph_gb=40, flavid=3), - 'm1.large': dict(mem=8192, vcpus=4, root_gb=10, eph_gb=80, flavid=4), - 'm1.xlarge': dict(mem=16384, vcpus=8, root_gb=10, eph_gb=160, flavid=5) - } - else: - default_inst_types = { + default_inst_types = { 'm1.tiny': dict(mem=512, vcpus=1, root_gb=0, eph_gb=0, flavid=1), 'm1.small': dict(mem=2048, vcpus=1, root_gb=20, eph_gb=0, flavid=2), 'm1.medium': dict(mem=4096, vcpus=2, root_gb=40, eph_gb=0, flavid=3), diff --git a/nova/exception.py b/nova/exception.py index 9c11dd8220d9..b8df7ddcc619 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -434,7 +434,7 @@ class NotFound(NovaException): class VirtDriverNotFound(NotFound): - message = _("Could not find driver for connection_type %(name)s") + message = _("Could not find driver for compute_driver %(name)s") class PersistentVolumeFileNotFound(NotFound): diff --git a/nova/flags.py b/nova/flags.py index e39f944574c7..34dbc72efb63 100644 --- a/nova/flags.py +++ b/nova/flags.py @@ -74,10 +74,6 @@ def _get_my_ip(): core_opts = [ - cfg.StrOpt('connection_type', - default=None, - help='Deprecated (use compute_driver instead): Virtualization ' - 'api connection type : libvirt, xenapi, or fake'), cfg.StrOpt('sql_connection', default='sqlite:///$state_path/$sqlite_db', help='The SQLAlchemy connection string used to connect to the ' diff --git a/nova/tests/fake_flags.py b/nova/tests/fake_flags.py index f0fde3588b0f..32f34b3e762b 100644 --- a/nova/tests/fake_flags.py +++ b/nova/tests/fake_flags.py @@ -32,7 +32,6 @@ flags.DECLARE('volume_driver', 'nova.volume.manager') def set_defaults(conf): conf.set_default('api_paste_config', '$state_path/etc/nova/api-paste.ini') conf.set_default('compute_driver', 'nova.virt.fake.FakeDriver') - conf.set_default('connection_type', 'fake') conf.set_default('fake_network', True) conf.set_default('fake_rabbit', True) conf.set_default('flat_network_bridge', 'br100') diff --git a/nova/tests/test_virt_drivers.py b/nova/tests/test_virt_drivers.py index d24ad615a2f1..05fe140d143d 100644 --- a/nova/tests/test_virt_drivers.py +++ b/nova/tests/test_virt_drivers.py @@ -144,13 +144,6 @@ class VirtDriverLoaderTestCase(_FakeDriverBackendTestCase): 'libvirt.LibvirtDriver': 'LibvirtDriver' } - # NOTE(sdague): remove after Folsom release when connection_type - # is removed - old_drivers = { - 'libvirt': 'LibvirtDriver', - 'fake': 'FakeDriver' - } - def test_load_new_drivers(self): for cls, driver in self.new_drivers.iteritems(): self.flags(compute_driver=cls) @@ -164,28 +157,6 @@ class VirtDriverLoaderTestCase(_FakeDriverBackendTestCase): self.assertEqual(cm.driver.__class__.__name__, driver, "Could't load driver %s" % cls) - # NOTE(sdague): remove after Folsom release when connection_type - # is removed - def test_load_old_drivers(self): - # we explicitly use the old default - self.flags(compute_driver='nova.virt.connection.get_connection') - for cls, driver in self.old_drivers.iteritems(): - self.flags(connection_type=cls) - # NOTE(sdague) the try block is to make it easier to debug a - # failure by knowing which driver broke - try: - cm = ComputeManager() - except Exception as e: - self.fail("Couldn't load connection %s - %s" % (cls, e)) - - self.assertEqual(cm.driver.__class__.__name__, driver, - "Could't load connection %s" % cls) - - def test_fail_to_load_old_drivers(self): - self.flags(compute_driver='nova.virt.connection.get_connection') - self.flags(connection_type='56kmodem') - self.assertRaises(exception.VirtDriverNotFound, ComputeManager) - def test_fail_to_load_new_drivers(self): self.flags(compute_driver='nova.virt.amiga') diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py index f8bf253cb99c..5c11872678a9 100644 --- a/nova/tests/test_xenapi.py +++ b/nova/tests/test_xenapi.py @@ -1957,8 +1957,7 @@ class XenAPIAggregateTestCase(stubs.XenAPITestBase): firewall_driver='nova.virt.xenapi.firewall.' 'Dom0IptablesFirewallDriver', host='host', - connection_type='xenapi', - compute_driver='nova.virt.xenapi.driver.XenAPIDriver') + compute_driver='xenapi.XenAPIDriver') host_ref = xenapi_fake.get_all('host')[0] stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests) self.context = context.get_admin_context() diff --git a/nova/tests/test_xensm.py b/nova/tests/test_xensm.py index c1748567bc4b..a4c0fb07d8d4 100644 --- a/nova/tests/test_xensm.py +++ b/nova/tests/test_xensm.py @@ -49,7 +49,7 @@ class XenSMTestCase(stubs.XenAPITestBase): self.user_id = 'fake' self.project_id = 'fake' self.context = context.RequestContext(self.user_id, self.project_id) - self.flags(connection_type='xenapi', + self.flags(compute_driver='xenapi.XenAPIDriver', xenapi_connection_url='http://test_url', xenapi_connection_username='test_user', xenapi_connection_password='test_pass') diff --git a/nova/virt/connection.py b/nova/virt/connection.py deleted file mode 100644 index 884bbb974be3..000000000000 --- a/nova/virt/connection.py +++ /dev/null @@ -1,84 +0,0 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 - -# Copyright 2010 United States Government as represented by the -# Administrator of the National Aeronautics and Space Administration. -# All Rights Reserved. -# Copyright (c) 2010 Citrix Systems, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -"""Abstraction of the underlying virtualization API.""" - -import sys - -from nova.common import deprecated -from nova import exception -from nova import flags -from nova.openstack.common import importutils -from nova.openstack.common import log as logging -from nova import utils -from nova.virt import driver - -LOG = logging.getLogger(__name__) -FLAGS = flags.FLAGS - -known_drivers = { - 'baremetal': 'baremetal.BareMetalDriver', - 'fake': 'fake.FakeDriver', - 'libvirt': 'libvirt.LibvirtDriver', - 'vmwareapi': 'vmwareapi.VMWareESXDriver', - 'xenapi': 'xenapi.XenAPIDriver' - } - - -def get_connection(read_only=False): - """ - Returns an object representing the connection to a virtualization - platform, or to an on-demand bare-metal provisioning platform. - - This could be :mod:`nova.virt.fake.FakeConnection` in test mode, - a connection to KVM, QEMU, or UML via :mod:`libvirt_conn`, or a connection - to XenServer or Xen Cloud Platform via :mod:`xenapi`. Other platforms are - also supported. - - Any object returned here must conform to the interface documented by - :mod:`FakeConnection`. - - **Related flags** - - :connection_type: A string literal that falls through an if/elif structure - to determine what virtualization mechanism to use. - Values may be - - * fake - * libvirt - * xenapi - * vmwareapi - * baremetal - - """ - deprecated.warn(_('Specifying virt driver via connection_type is ' - 'deprecated. Use compute_driver=classname instead.')) - - driver_name = known_drivers.get(FLAGS.connection_type) - - if driver_name is None: - raise exception.VirtDriverNotFound(name=FLAGS.connection_type) - - conn = importutils.import_object_ns('nova.virt', driver_name, - read_only=read_only) - - if conn is None: - LOG.error(_('Failed to open connection to underlying virt platform')) - sys.exit(1) - return utils.check_isinstance(conn, driver.ComputeDriver) diff --git a/nova/volume/xensm.py b/nova/volume/xensm.py index 3deec66f0c8b..7e9a4b0ee4df 100644 --- a/nova/volume/xensm.py +++ b/nova/volume/xensm.py @@ -98,8 +98,9 @@ class XenSMDriver(nova.volume.driver.VolumeDriver): # This driver leverages Xen storage manager, and hence requires # hypervisor to be Xen - if FLAGS.connection_type != 'xenapi': - msg = _('XenSMDriver requires xenapi connection') + if not FLAGS.compute_driver.endswith('XenAPIDriver'): + msg = (_('XenSMDriver requires xenapi connection, using %s') % + FLAGS.compute_driver) raise exception.VolumeBackendAPIException(data=msg) url = FLAGS.xenapi_connection_url