virt: Remove 'is_xenapi' helper

This will never be true now.

Change-Id: I10c3542e06a4d8132314aaac5cf5a905e1f8a270
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane 2020-08-31 14:59:48 +01:00
parent adb28f503c
commit 7991155454
5 changed files with 5 additions and 100 deletions

View File

@ -544,12 +544,8 @@ def generate_device_name(prefix, index):
def instance_block_mapping(instance, bdms):
root_device_name = instance['root_device_name']
# NOTE(clayg): remove this when xenapi is setting default_root_device
if root_device_name is None:
if driver.is_xenapi():
root_device_name = '/dev/xvda'
else:
return _DEFAULT_MAPPINGS
return _DEFAULT_MAPPINGS
mappings = {}
mappings['ami'] = strip_dev(root_device_name)

View File

@ -53,7 +53,6 @@ from nova.objects import fields
from nova import rpc
from nova import safe_utils
from nova import utils
from nova.virt import driver
CONF = nova.conf.CONF
LOG = log.getLogger(__name__)
@ -229,10 +228,6 @@ def get_next_device_name(instance, device_name_list,
except (TypeError, AttributeError, ValueError):
raise exception.InvalidDevicePath(path=root_device_name)
# NOTE(vish): remove this when xenapi is setting default_root_device
if driver.is_xenapi():
prefix = '/dev/xvd'
if req_prefix != prefix:
LOG.debug("Using %(prefix)s instead of %(req_prefix)s",
{'prefix': prefix, 'req_prefix': req_prefix})
@ -242,16 +237,6 @@ def get_next_device_name(instance, device_name_list,
letter = block_device.get_device_letter(device_path)
used_letters.add(letter)
# NOTE(vish): remove this when xenapi is properly setting
# default_ephemeral_device and default_swap_device
if driver.is_xenapi():
flavor = instance.get_flavor()
if flavor.ephemeral_gb:
used_letters.add('b')
if flavor.swap:
used_letters.add('c')
check_max_disk_devices_to_attach(len(used_letters) + 1)
if not req_letter:

View File

@ -87,17 +87,10 @@ class ComputeValidateDeviceTestCase(test.NoDBTestCase):
def setUp(self):
super(ComputeValidateDeviceTestCase, self).setUp()
self.context = context.RequestContext('fake', 'fake')
# check if test name includes "xen"
if 'xen' in self.id():
self.flags(compute_driver='xenapi.XenAPIDriver')
self.instance = objects.Instance(
uuid=uuidutils.generate_uuid(dashed=False),
root_device_name=None, default_ephemeral_device=None)
else:
self.instance = objects.Instance(
uuid=uuidutils.generate_uuid(dashed=False),
root_device_name='/dev/vda',
default_ephemeral_device='/dev/vdb')
self.instance = objects.Instance(
uuid=uuidutils.generate_uuid(dashed=False),
root_device_name='/dev/vda',
default_ephemeral_device='/dev/vdb')
flavor = objects.Flavor(**test_flavor.fake_flavor)
self.instance.system_metadata = {}
@ -198,33 +191,6 @@ class ComputeValidateDeviceTestCase(test.NoDBTestCase):
device = self._validate_device()
self.assertEqual(device, '/dev/vdc')
def test_ephemeral_xenapi(self):
self.instance.flavor.ephemeral_gb = 10
self.instance.flavor.swap = 0
device = self._validate_device()
self.assertEqual(device, '/dev/xvdc')
def test_swap_xenapi(self):
self.instance.flavor.ephemeral_gb = 0
self.instance.flavor.swap = 10
device = self._validate_device()
self.assertEqual(device, '/dev/xvdb')
def test_swap_and_ephemeral_xenapi(self):
self.instance.flavor.ephemeral_gb = 10
self.instance.flavor.swap = 10
device = self._validate_device()
self.assertEqual(device, '/dev/xvdd')
def test_swap_and_one_attachment_xenapi(self):
self.instance.flavor.ephemeral_gb = 0
self.instance.flavor.swap = 10
device = self._validate_device()
self.assertEqual(device, '/dev/xvdb')
self.data.append(self._fake_bdm(device))
device = self._validate_device()
self.assertEqual(device, '/dev/xvdd')
def test_no_dev_root_device_name_get_next_name(self):
self.instance['root_device_name'] = 'vda'
device = self._validate_device()

View File

@ -1,38 +0,0 @@
# Copyright (c) 2013 Citrix Systems, Inc.
# Copyright 2013 OpenStack Foundation
#
# 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.
from oslo_config import fixture as fixture_config
from nova import test
from nova.virt import driver
class DriverMethodTestCase(test.NoDBTestCase):
def setUp(self):
super(DriverMethodTestCase, self).setUp()
self.CONF = self.useFixture(fixture_config.Config()).conf
def test_is_xenapi_true(self):
self.CONF.set_override('compute_driver', 'xenapi.XenAPIDriver')
self.assertTrue(driver.is_xenapi())
def test_is_xenapi_false(self):
driver_names = ('libvirt.LibvirtDriver', 'fake.FakeDriver',
'ironic.IronicDriver', 'vmwareapi.VMwareVCDriver',
'hyperv.HyperVDriver', None)
for driver_name in driver_names:
self.CONF.set_override('compute_driver', driver_name)
self.assertFalse(driver.is_xenapi())

View File

@ -1924,7 +1924,3 @@ def load_compute_driver(virtapi, compute_driver=None):
LOG.exception("Compute driver '%s' from 'nova.virt' is not of type "
"'%s'", compute_driver, str(ComputeDriver))
sys.exit(1)
def is_xenapi():
return CONF.compute_driver == 'xenapi.XenAPIDriver'