From 1f44fde35e56863e1dd71a0b454ad3ea1ce9e00e Mon Sep 17 00:00:00 2001 From: Matthew Edmonds Date: Thu, 22 Feb 2018 17:07:39 -0500 Subject: [PATCH] make PowerVM capabilities explicit Upcoming PowerVM driver changes will introduce support for some capabilities. In preparation for those changes, this makes capabilities explicit in the driver rather than inheriting defaults from the parent class. This is consistent with other drivers. Change-Id: Id42eed5e555c0dbedb220dcfcfd977b02a546156 --- nova/tests/unit/virt/powervm/test_driver.py | 22 ++++++++++++++++++++- nova/virt/powervm/driver.py | 15 +++++++++++++- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/nova/tests/unit/virt/powervm/test_driver.py b/nova/tests/unit/virt/powervm/test_driver.py index c97f6c1a9a9f..960de398d194 100644 --- a/nova/tests/unit/virt/powervm/test_driver.py +++ b/nova/tests/unit/virt/powervm/test_driver.py @@ -1,4 +1,4 @@ -# Copyright 2016, 2017 IBM Corp. +# Copyright 2016, 2018 IBM Corp. # # 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 @@ -26,6 +26,7 @@ from pypowervm.wrappers import virtual_io_server as pvm_vios from nova import exception from nova import test from nova.tests.unit.virt import powervm +from nova.virt.driver import ComputeDriver from nova.virt import hardware from nova.virt.powervm.disk import ssp from nova.virt.powervm import driver @@ -50,6 +51,25 @@ class TestPowerVMDriver(test.NoDBTestCase): # Create an instance to test with self.inst = powervm.TEST_INSTANCE + def test_driver_capabilities(self): + """Test the driver capabilities.""" + # check that the driver reports all capabilities + self.assertEqual(set(ComputeDriver.capabilities), + set(self.drv.capabilities)) + # check the values for each capability + self.assertFalse(self.drv.capabilities['has_imagecache']) + self.assertFalse(self.drv.capabilities['supports_recreate']) + self.assertFalse( + self.drv.capabilities['supports_migrate_to_same_host']) + self.assertFalse(self.drv.capabilities['supports_attach_interface']) + self.assertFalse(self.drv.capabilities['supports_device_tagging']) + self.assertFalse( + self.drv.capabilities['supports_tagged_attach_interface']) + self.assertFalse( + self.drv.capabilities['supports_tagged_attach_volume']) + self.assertFalse(self.drv.capabilities['supports_extend_volume']) + self.assertFalse(self.drv.capabilities['supports_multiattach']) + @mock.patch('nova.image.API') @mock.patch('pypowervm.tasks.storage.ComprehensiveScrub', autospec=True) @mock.patch('nova.virt.powervm.disk.ssp.SSPDiskAdapter') diff --git a/nova/virt/powervm/driver.py b/nova/virt/powervm/driver.py index b8e833a985b4..ceb0f0841cff 100644 --- a/nova/virt/powervm/driver.py +++ b/nova/virt/powervm/driver.py @@ -1,4 +1,4 @@ -# Copyright 2014, 2017 IBM Corp. +# Copyright 2014, 2018 IBM Corp. # # 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 @@ -52,6 +52,19 @@ class PowerVMDriver(driver.ComputeDriver): """ def __init__(self, virtapi): + # NOTE(edmondsw) some of these will be dynamic in future, so putting + # capabilities on the instance rather than on the class. + self.capabilities = { + 'has_imagecache': False, + 'supports_recreate': False, + 'supports_migrate_to_same_host': False, + 'supports_attach_interface': False, + 'supports_device_tagging': False, + 'supports_tagged_attach_interface': False, + 'supports_tagged_attach_volume': False, + 'supports_extend_volume': False, + 'supports_multiattach': False, + } super(PowerVMDriver, self).__init__(virtapi) def init_host(self, host):