From: Marc Koderer Date: Wed, 10 Dec 2014 06:29:25 +0000 (+0100) Subject: Create proxy volume driver X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=6049ffa244875b90f25e2db1404bea2b6f7d5976;p=openstack-build%2Fcinder-build.git Create proxy volume driver Drivers that need a special proxy logic can't inherit from BaseVD directly. This is problematic for the ABCmeta feature since the class model can't be accessed easily with isinstance(). Change-Id: I553a72991bb450e8581a757fb98a264ed1ba8fb2 Partly-Implements: blueprint abc-volume-drivers --- diff --git a/cinder/volume/driver.py b/cinder/volume/driver.py index 0c949a053..826dcc44c 100644 --- a/cinder/volume/driver.py +++ b/cinder/volume/driver.py @@ -869,6 +869,19 @@ class VolumeDriver(object): return None +class ProxyVD(object): + """Proxy Volume Driver to mark proxy drivers + + If a driver uses a proxy class (e.g. by using __setattr__ and + __getattr__) without directly inheriting from base volume driver this + class can help marking them and retrieve the actual used driver object. + """ + def _get_driver(self): + """Returns the actual driver object. Can be overloaded by the proxy. + """ + return getattr(self, "driver", None) + + class ISCSIDriver(VolumeDriver): """Executes commands relating to ISCSI volumes. diff --git a/cinder/volume/drivers/netapp/common.py b/cinder/volume/drivers/netapp/common.py index 5fa387c77..8efa8f2e4 100644 --- a/cinder/volume/drivers/netapp/common.py +++ b/cinder/volume/drivers/netapp/common.py @@ -23,6 +23,7 @@ from oslo.utils import importutils from cinder import exception from cinder.i18n import _, _LI from cinder.openstack.common import log as logging +from cinder.volume import driver from cinder.volume.drivers.netapp.options import netapp_proxy_opts from cinder.volume.drivers.netapp import utils as na_utils @@ -52,7 +53,7 @@ NETAPP_UNIFIED_DRIVER_REGISTRY = { }} -class NetAppDriver(object): +class NetAppDriver(driver.ProxyVD): """"NetApp unified block storage driver. Acts as a factory to create NetApp storage drivers based on the