From 7991155454c2f3093a18de6e44b701c13fbeb1ad Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Mon, 31 Aug 2020 14:59:48 +0100 Subject: [PATCH] virt: Remove 'is_xenapi' helper This will never be true now. Change-Id: I10c3542e06a4d8132314aaac5cf5a905e1f8a270 Signed-off-by: Stephen Finucane --- nova/block_device.py | 6 +-- nova/compute/utils.py | 15 ------- nova/tests/unit/compute/test_compute_utils.py | 42 ++----------------- nova/tests/unit/virt/test_driver.py | 38 ----------------- nova/virt/driver.py | 4 -- 5 files changed, 5 insertions(+), 100 deletions(-) delete mode 100644 nova/tests/unit/virt/test_driver.py diff --git a/nova/block_device.py b/nova/block_device.py index 413fef20e389..340d4b9285a5 100644 --- a/nova/block_device.py +++ b/nova/block_device.py @@ -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) diff --git a/nova/compute/utils.py b/nova/compute/utils.py index 63cd5b5ffa01..ec0591d493c7 100644 --- a/nova/compute/utils.py +++ b/nova/compute/utils.py @@ -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: diff --git a/nova/tests/unit/compute/test_compute_utils.py b/nova/tests/unit/compute/test_compute_utils.py index e6e07fba29eb..b9a8bf1d494e 100644 --- a/nova/tests/unit/compute/test_compute_utils.py +++ b/nova/tests/unit/compute/test_compute_utils.py @@ -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() diff --git a/nova/tests/unit/virt/test_driver.py b/nova/tests/unit/virt/test_driver.py deleted file mode 100644 index 716fa6e8371f..000000000000 --- a/nova/tests/unit/virt/test_driver.py +++ /dev/null @@ -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()) diff --git a/nova/virt/driver.py b/nova/virt/driver.py index b6eb3d008a06..118dc0f8e104 100644 --- a/nova/virt/driver.py +++ b/nova/virt/driver.py @@ -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'