remove deprecated connection_type flag

Fixes bug #1025712

connection_type was deprecated in Folsom and should now
be removed in Grizzly as early as possible to shake out
any fallout. This removes all references to it, changes
the config sample and tests appropriately.

Remove old default fixtures for flavors that specify
ephemeral disks if the connection_type flag was set to
'libvirt'

Change-Id: I8af831600a1931ae92c6d06c5105bd1bd81debe3
This commit is contained in:
Sean Dague
2012-10-01 11:44:55 -04:00
parent 878dd9c0e2
commit 625996722f
12 changed files with 9 additions and 143 deletions

View File

@@ -73,10 +73,6 @@
######## defined in nova.flags ########
# connection_type=<None>
#### (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

View File

@@ -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, '

View File

@@ -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']:

View File

@@ -30,15 +30,6 @@ 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 = {
'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),

View File

@@ -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):

View File

@@ -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 '

View File

@@ -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')

View File

@@ -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')

View File

@@ -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()

View File

@@ -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')

View File

@@ -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)

View File

@@ -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