[openstack-dev] [Cinder] Implementation of ABC MetaClasses
john.griffith8 at gmail.com
Fri Jun 19 22:43:02 UTC 2015
So I've talked a little in bits and pieces regarding the implementations
that are going in for the ABC metaclass work. First off, I think the use
of ABC is a good idea and has value, particularly as we approach/surpass 50
third party drivers.
The only thing that I'm wondering if we could do better is the metaclass
tagging of things. We have ended up with something that IMO is rather
confusing and I'm not sure what the value is (perhaps this is simply a
misunderstanding on my part and somebody can enlighten me).
What I'm referring to is the all of the *VD classes we've created, and the
fact that each driver now has an inheritance structure of multiple
classes. So for example, we have a VD class for what used to be "class
Driver" here: 
It seems we could've just "left" this as "Driver" and added the abc
decorators to abstract methods in the base object. Instead though we have
something I don't quite understand: we have abc decorators on the methods
AND we have these special meta-classes for a number of the methods. For
example:  and . What's the value here, I'm unclear on what the goal
There is an alternative that just uses the abc decorator, and no special
class designations. If you attach the abc decorator to any method in a
base class, it indicates that any inheriting driver MUST implement that
method. If said sub-class does NOT implement that method, the load of the
module will fail. This really requires no additional code or maintenance
other than just adding the decorator to the mandatory methods in the base
There examples of what I'm describing in the target drivers .
Anyway, maybe I'm missing a big advantage here, but without understanding
what this gains it makes the code structure a bit hard to maintain and
follow in a number of ways. For example, in order to implement this in the
existing drivers they need to be changed to have an inheritance structure
like this: . As opposed to just using the decorator which everything
would automatically propagate to any sub-class and enforce implementation
with no change or maintenance to existing drivers; but it still enforces
implementation of the required methods.
I'd love if folks could study some of this a bit and let me know what it is
that I'm missing here. Is there some value that I'm unaware of that the
muti-inheritance paradigm in the drivers provides us?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the OpenStack-dev