From 7edc87ff0e92043f5a21d630bbb9b966f5e34535 Mon Sep 17 00:00:00 2001 From: Eric Harney Date: Tue, 8 Sep 2015 14:10:55 -0400 Subject: [PATCH] Add manage_existing and unmanage to BaseVD manage_existing() and unmanage() only exist in the deprecated VolumeDriver() class and not BaseVD. This means that drivers inheriting from *VD hit attribute errors when trying to call either of these methods. Related-Bug: #1478987 Related-Bug: #1493286 Related-Bug: #1471807 Closes-Bug: #1487329 Change-Id: Ie8aba971b51e1f5eaac5a4e681ea06b358ebb7b8 --- cinder/tests/unit/test_glusterfs.py | 21 +++++++++++++++++++++ cinder/volume/driver.py | 16 ++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/cinder/tests/unit/test_glusterfs.py b/cinder/tests/unit/test_glusterfs.py index 1ab471c4f60..ccc424d049d 100644 --- a/cinder/tests/unit/test_glusterfs.py +++ b/cinder/tests/unit/test_glusterfs.py @@ -1805,3 +1805,24 @@ class GlusterFsDriverTestCase(test.TestCase): mock.sentinel.host) self.assertEqual((False, None), ret) + + def test_manage_existing_is_there(self): + """Ensure that driver.manage_existing() is there.""" + + drv = self._driver + + volume = self._simple_volume(id=mock.sentinel.manage_id) + + self.assertRaises(NotImplementedError, + drv.manage_existing, + volume, mock.sentinel.existing_ref) + + def test_unmanage_is_there(self): + """Ensure that driver.unmanage() is there.""" + + drv = self._driver + + volume = self._simple_volume(id=mock.sentinel.unmanage_id) + self.assertRaises(NotImplementedError, + drv.unmanage, + volume) diff --git a/cinder/volume/driver.py b/cinder/volume/driver.py index 2b3f2a540e9..246f25a9320 100644 --- a/cinder/volume/driver.py +++ b/cinder/volume/driver.py @@ -1404,6 +1404,22 @@ class BaseVD(object): """ return (False, None) + def manage_existing(self, volume, existing_ref): + """Manage exiting stub. + + This is for drivers that don't implement manage_existing(). + """ + msg = _("Manage existing volume not implemented.") + raise NotImplementedError(msg) + + def unmanage(self, volume): + """Unmanage stub. + + This is for drivers that don't implement unmanage(). + """ + msg = _("Unmanage volume not implemented.") + raise NotImplementedError(msg) + @six.add_metaclass(abc.ABCMeta) class LocalVD(object):