Shim compute driver in nova.virt namespace

Recent nova commit 8eb03de1eb83a6cd2d4d41804e1b8253f94e5400 removed the
mechanism by which nova-powervm was loading its ComputeDriver from out
of tree.

With Change-Id: I78c0ca85cb6ee2e370214a89a203f6f099748930 we can now add
to the nova.virt namespace from the nova-powervm package.

This change set restores the ability to load the driver by creating a
thin shim into nova.virt.powervm.driver, passing through all public
symbols from nova_powervm.virt.powervm.driver.

Change-Id: I8ff5154edfcef6fa83686b2ae046512ce7d6d628
Partial-Bug: 1575335
This commit is contained in:
Eric Fried 2016-04-26 16:11:53 -05:00
parent e223f2a0fe
commit fe9bec248e
8 changed files with 72 additions and 17 deletions

View File

@ -10,7 +10,7 @@ INSTALL_PYPOWERVM=$(trueorfalse False INSTALL_PYPOWERVM)
PVM_ADMIN_GROUP=${PVM_ADMIN_GROUP:-pvm_admin}
# Nova settings
PVM_DRIVER=nova_powervm.virt.powervm.driver.PowerVMDriver
PVM_DRIVER=powervm.driver.PowerVMDriver
INSTANCE_NAME_TEMPLATE=${INSTANCE_NAME_TEMPLATE:-"%(display_name).13s-%(uuid).8s-pvm"}
COMPUTE_MONITORS=${COMPUTE_MONITORS:-nova.compute.monitors.all_monitors}
FORCE_CONFIG_DRIVE=${FORCE_CONFIG_DRIVE:-True}

0
nova/__init__.py Normal file
View File

18
nova/virt/__init__.py Normal file
View File

@ -0,0 +1,18 @@
# Copyright 2016 IBM Corp.
#
# All Rights Reserved.
#
# 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.
# Required to play nicely with namespace composition (PEP420).
__import__('pkg_resources').declare_namespace(__name__)

View File

View File

@ -0,0 +1,35 @@
# Copyright 2016 IBM Corp.
#
# All Rights Reserved.
#
# 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.
"""Shim layer for nova_powervm.virt.powervm.driver.PowerVMDriver.
Duplicate all public symbols. This is necessary for the constants as well as
the classes - because instances of the classes need to be able to resolve
references to the constants.
"""
import nova_powervm.virt.powervm.driver as real_drv
LOG = real_drv.LOG
CONF = real_drv.CONF
VOLUME_DRIVER_MAPPINGS = real_drv.VOLUME_DRIVER_MAPPINGS
DISK_ADPT_NS = real_drv.DISK_ADPT_NS
DISK_ADPT_MAPPINGS = real_drv.DISK_ADPT_MAPPINGS
NVRAM_NS = real_drv.NVRAM_NS
NVRAM_APIS = real_drv.NVRAM_APIS
KEEP_NVRAM_STATES = real_drv.KEEP_NVRAM_STATES
FETCH_NVRAM_STATES = real_drv.FETCH_NVRAM_STATES
PowerVMDriver = real_drv.PowerVMDriver
NovaEventHandler = real_drv.NovaEventHandler

View File

@ -20,7 +20,7 @@ from __future__ import absolute_import
import fixtures
import mock
from nova_powervm.virt.powervm import driver
from nova.virt.powervm import driver
from nova.virt import fake
from pypowervm.tests import test_fixtures as pvm_fx

View File

@ -43,9 +43,10 @@ from pypowervm.wrappers import base_partition as pvm_bp
from pypowervm.wrappers import logical_partition as pvm_lpar
from pypowervm.wrappers import virtual_io_server as pvm_vios
from nova.virt.powervm import driver
from nova_powervm.tests.virt import powervm
from nova_powervm.tests.virt.powervm import fixtures as fx
from nova_powervm.virt.powervm import driver
from nova_powervm.virt.powervm import exception as p_exc
from nova_powervm.virt.powervm import live_migration as lpm
from nova_powervm.virt.powervm import vm
@ -260,7 +261,7 @@ class TestPowerVMDriver(test.TestCase):
'.execute')
@mock.patch('nova_powervm.virt.powervm.tasks.storage.CreateDiskForImg'
'.execute')
@mock.patch('nova_powervm.virt.powervm.driver.PowerVMDriver.'
@mock.patch('nova.virt.powervm.driver.PowerVMDriver.'
'_is_booted_from_volume')
@mock.patch('nova_powervm.virt.powervm.tasks.network.PlugMgmtVif.execute')
@mock.patch('nova_powervm.virt.powervm.tasks.network.PlugVifs.execute')
@ -336,7 +337,7 @@ class TestPowerVMDriver(test.TestCase):
@mock.patch('nova.virt.block_device.DriverVolumeBlockDevice.save')
@mock.patch('nova_powervm.virt.powervm.tasks.storage.CreateDiskForImg'
'.execute')
@mock.patch('nova_powervm.virt.powervm.driver.PowerVMDriver.'
@mock.patch('nova.virt.powervm.driver.PowerVMDriver.'
'_is_booted_from_volume')
@mock.patch('nova_powervm.virt.powervm.tasks.network.PlugMgmtVif.execute')
@mock.patch('nova_powervm.virt.powervm.tasks.network.PlugVifs.execute')
@ -391,7 +392,7 @@ class TestPowerVMDriver(test.TestCase):
@mock.patch('nova.virt.block_device.DriverVolumeBlockDevice.save')
@mock.patch('nova_powervm.virt.powervm.tasks.storage.CreateDiskForImg'
'.execute')
@mock.patch('nova_powervm.virt.powervm.driver.PowerVMDriver.'
@mock.patch('nova.virt.powervm.driver.PowerVMDriver.'
'_is_booted_from_volume')
@mock.patch('nova_powervm.virt.powervm.tasks.network.PlugMgmtVif.execute')
@mock.patch('nova_powervm.virt.powervm.tasks.network.PlugVifs.execute')
@ -450,7 +451,7 @@ class TestPowerVMDriver(test.TestCase):
@mock.patch('nova.virt.block_device.DriverVolumeBlockDevice.save')
@mock.patch('nova_powervm.virt.powervm.tasks.storage.CreateDiskForImg'
'.execute')
@mock.patch('nova_powervm.virt.powervm.driver.PowerVMDriver.'
@mock.patch('nova.virt.powervm.driver.PowerVMDriver.'
'_is_booted_from_volume')
@mock.patch('nova_powervm.virt.powervm.tasks.network.PlugMgmtVif.execute')
@mock.patch('nova_powervm.virt.powervm.tasks.network.PlugVifs.execute')
@ -505,7 +506,7 @@ class TestPowerVMDriver(test.TestCase):
'.execute')
@mock.patch('nova_powervm.virt.powervm.tasks.storage.FindDisk'
'.execute')
@mock.patch('nova_powervm.virt.powervm.driver.PowerVMDriver.'
@mock.patch('nova.virt.powervm.driver.PowerVMDriver.'
'_is_booted_from_volume')
@mock.patch('nova_powervm.virt.powervm.tasks.network.PlugMgmtVif.execute')
@mock.patch('nova_powervm.virt.powervm.tasks.network.PlugVifs.execute')
@ -587,7 +588,7 @@ class TestPowerVMDriver(test.TestCase):
@mock.patch('nova.virt.block_device.DriverVolumeBlockDevice.save')
@mock.patch('nova_powervm.virt.powervm.tasks.storage.CreateDiskForImg'
'.execute')
@mock.patch('nova_powervm.virt.powervm.driver.PowerVMDriver.'
@mock.patch('nova.virt.powervm.driver.PowerVMDriver.'
'_is_booted_from_volume')
@mock.patch('nova_powervm.virt.powervm.tasks.network.PlugMgmtVif.execute')
@mock.patch('nova_powervm.virt.powervm.tasks.network.PlugVifs.execute')
@ -595,7 +596,7 @@ class TestPowerVMDriver(test.TestCase):
@mock.patch('nova.objects.flavor.Flavor.get_by_id')
@mock.patch('nova_powervm.virt.powervm.tasks.vm.UpdateIBMiSettings'
'.execute')
@mock.patch('nova_powervm.virt.powervm.driver.PowerVMDriver.'
@mock.patch('nova.virt.powervm.driver.PowerVMDriver.'
'_get_boot_connectivity_type')
@mock.patch('pypowervm.tasks.power.power_on')
def test_spawn_ibmi(
@ -646,7 +647,7 @@ class TestPowerVMDriver(test.TestCase):
'.execute')
@mock.patch('nova_powervm.virt.powervm.tasks.storage.CreateDiskForImg'
'.execute')
@mock.patch('nova_powervm.virt.powervm.driver.PowerVMDriver.'
@mock.patch('nova.virt.powervm.driver.PowerVMDriver.'
'_is_booted_from_volume')
@mock.patch('nova_powervm.virt.powervm.tasks.network.PlugMgmtVif.execute')
@mock.patch('nova_powervm.virt.powervm.tasks.network.PlugVifs.execute')
@ -654,7 +655,7 @@ class TestPowerVMDriver(test.TestCase):
@mock.patch('nova.objects.flavor.Flavor.get_by_id')
@mock.patch('nova_powervm.virt.powervm.tasks.vm.UpdateIBMiSettings'
'.execute')
@mock.patch('nova_powervm.virt.powervm.driver.PowerVMDriver.'
@mock.patch('nova.virt.powervm.driver.PowerVMDriver.'
'_get_boot_connectivity_type')
@mock.patch('pypowervm.tasks.power.power_on')
def test_spawn_ibmi_without_bdms(
@ -826,7 +827,7 @@ class TestPowerVMDriver(test.TestCase):
self.assertEqual(2, flow.add.call_count)
@mock.patch('nova_powervm.virt.powervm.tasks.network.UnplugVifs.execute')
@mock.patch('nova_powervm.virt.powervm.driver.PowerVMDriver.'
@mock.patch('nova.virt.powervm.driver.PowerVMDriver.'
'_is_booted_from_volume')
@mock.patch('nova_powervm.virt.powervm.vm.dlt_lpar')
@mock.patch('nova_powervm.virt.powervm.vm.power_off')
@ -1212,7 +1213,7 @@ class TestPowerVMDriver(test.TestCase):
taskflow_fix.assert_tasks_added(self, expected)
self.san_lpar_name.assert_called_with('resize_' + self.inst.name)
@mock.patch('nova_powervm.virt.powervm.driver.vm')
@mock.patch('nova_powervm.virt.powervm.vm')
@mock.patch('nova_powervm.virt.powervm.tasks.vm.vm')
@mock.patch('nova_powervm.virt.powervm.tasks.vm.power')
def test_rescue(self, mock_task_pwr, mock_task_vm, mock_dvr_vm):
@ -1228,7 +1229,7 @@ class TestPowerVMDriver(test.TestCase):
self.assertTrue(mock_task_pwr.power_on.called)
self.assertFalse(mock_task_pwr.power_on.call_args[1]['synchronous'])
@mock.patch('nova_powervm.virt.powervm.driver.vm')
@mock.patch('nova_powervm.virt.powervm.vm')
@mock.patch('nova_powervm.virt.powervm.tasks.vm.vm')
@mock.patch('nova_powervm.virt.powervm.tasks.vm.power')
def test_unrescue(self, mock_task_pwr, mock_task_vm, mock_dvr_vm):
@ -1243,7 +1244,7 @@ class TestPowerVMDriver(test.TestCase):
self.assertTrue(mock_task_pwr.power_on.called)
self.assertFalse(mock_task_pwr.power_on.call_args[1]['synchronous'])
@mock.patch.object(driver, 'LOG')
@mock.patch('nova_powervm.virt.powervm.driver.LOG')
def test_log_op(self, mock_log):
"""Validates the log_operations."""
self.drv._log_operation('fake_op', self.inst)
@ -1360,7 +1361,7 @@ class TestPowerVMDriver(test.TestCase):
def test_get_host_ip_addr(self):
self.assertEqual(self.drv.get_host_ip_addr(), '127.0.0.1')
@mock.patch('nova_powervm.virt.powervm.driver.LOG.warning')
@mock.patch('nova.virt.powervm.driver.LOG.warning')
@mock.patch('nova.compute.utils.get_machine_ips')
def test_get_host_ip_addr_failure(self, mock_ips, mock_log):
mock_ips.return_value = ['1.1.1.1']

View File

@ -20,6 +20,7 @@ classifier =
[files]
packages =
nova_powervm
nova.virt.powervm
[build_sphinx]
source-dir = doc/source