Make service plugins' get_plugin_type classmethods

Any service plugin that implements the get_plugin_type method should
make it a classmethod.  It should not need to be instantiated to
retrieve the simple constant it returns in every case.

Change-Id: Ia3a1237a5e07169ebc9378b1cd4188085e20d71c
Closes-Bug: #1590117
This commit is contained in:
Brandon Logan 2016-06-07 14:29:36 -05:00
parent bafc454ee3
commit c40403eee0
16 changed files with 35 additions and 18 deletions

View File

@ -137,7 +137,8 @@ class MeteringPluginBase(service_base.ServicePluginBase):
def get_plugin_description(self):
return constants.METERING
def get_plugin_type(self):
@classmethod
def get_plugin_type(cls):
return constants.METERING
@abc.abstractmethod

View File

@ -280,7 +280,8 @@ class QoSPluginBase(service_base.ServicePluginBase):
def get_plugin_description(self):
return "QoS Service Plugin for ports and networks"
def get_plugin_type(self):
@classmethod
def get_plugin_type(cls):
return constants.QOS
@abc.abstractmethod

View File

@ -214,5 +214,6 @@ class SegmentPluginBase(object):
def get_plugin_description(self):
return "Network Segments"
def get_plugin_type(self):
@classmethod
def get_plugin_type(cls):
return SEGMENTS

View File

@ -180,7 +180,8 @@ class TagPluginBase(service_base.ServicePluginBase):
def get_plugin_description(self):
return "Tag support"
def get_plugin_type(self):
@classmethod
def get_plugin_type(cls):
return TAG_PLUGIN_TYPE
@abc.abstractmethod

View File

@ -33,5 +33,6 @@ class Plugin(db.AutoAllocatedTopologyMixin):
def get_plugin_description(self):
return "Auto Allocated Topology - aka get me a network."
def get_plugin_type(self):
@classmethod
def get_plugin_type(cls):
return "auto-allocated-topology"

View File

@ -24,7 +24,8 @@ class FlavorsPlugin(service_base.ServicePluginBase,
supported_extension_aliases = ['flavors', 'service-type']
def get_plugin_type(self):
@classmethod
def get_plugin_type(cls):
return constants.FLAVORS
def get_plugin_description(self):

View File

@ -80,7 +80,8 @@ class L3RouterPlugin(service_base.ServicePluginBase,
fanout=False)
return self.conn.consume_in_threads()
def get_plugin_type(self):
@classmethod
def get_plugin_type(cls):
return constants.L3_ROUTER_NAT
def get_plugin_description(self):

View File

@ -34,7 +34,8 @@ class NetworkIPAvailabilityPlugin(ip_availability_db.IpAvailabilityMixin,
def get_plugin_description(self):
return "Provides IP availability data for each network and subnet."
def get_plugin_type(self):
@classmethod
def get_plugin_type(cls):
return "network-ip-availability"
def get_network_ip_availabilities(self, context, filters=None,

View File

@ -42,7 +42,8 @@ class TimeStampPlugin(service_base.ServicePluginBase,
None,
self._change_since_result_filter_hook)
def get_plugin_type(self):
@classmethod
def get_plugin_type(cls):
return 'timestamp_core'
def get_plugin_description(self):

View File

@ -156,8 +156,9 @@ class FakePlugin(object):
PLUGIN_TYPE = 'fake-ext-plugin'
supported_extension_aliases = ['fake-ext']
def get_plugin_type(self):
return self.PLUGIN_TYPE
@classmethod
def get_plugin_type(cls):
return cls.PLUGIN_TYPE
def get_meh_meh(self, context, id_, fields=None):
return {'fake': id_}

View File

@ -167,7 +167,8 @@ class ResourceExtensionTest(base.BaseTestCase):
return {'collection': 'value'}
class DummySvcPlugin(wsgi.Controller):
def get_plugin_type(self):
@classmethod
def get_plugin_type(cls):
return constants.DUMMY
def index(self, request, **kwargs):
@ -215,7 +216,8 @@ class ResourceExtensionTest(base.BaseTestCase):
def index(self, request):
return ""
def get_plugin_type(self):
@classmethod
def get_plugin_type(cls):
return constants.DUMMY
res_ext = extensions.ResourceExtension(

View File

@ -95,7 +95,8 @@ class DummyServicePlugin(service_base.ServicePluginBase):
self.svctype_mgr = servicetype_db.ServiceTypeManager.get_instance()
self.dummys = {}
def get_plugin_type(self):
@classmethod
def get_plugin_type(cls):
return constants.DUMMY
def get_plugin_description(self):

View File

@ -414,7 +414,8 @@ class DummyServicePlugin(object):
def driver_loaded(self, driver, service_profile):
pass
def get_plugin_type(self):
@classmethod
def get_plugin_type(cls):
return constants.DUMMY
def get_plugin_description(self):

View File

@ -301,7 +301,8 @@ class TestL3NatServicePlugin(common_db_mixin.CommonDbMixin,
supported_extension_aliases = ["router", "dns-integration"]
def get_plugin_type(self):
@classmethod
def get_plugin_type(cls):
return service_constants.L3_ROUTER_NAT
def get_plugin_description(self):

View File

@ -38,7 +38,8 @@ class AZRouterTestPlugin(common_db_mixin.CommonDbMixin,
supported_extension_aliases = ["router", "l3_agent_scheduler",
"router_availability_zone"]
def get_plugin_type(self):
@classmethod
def get_plugin_type(cls):
return service_constants.L3_ROUTER_NAT
def get_plugin_description(self):

View File

@ -111,7 +111,8 @@ class SegmentTestPlugin(db_base_plugin_v2.NeutronDbPluginV2,
def get_plugin_description(self):
return "Network Segments"
def get_plugin_type(self):
@classmethod
def get_plugin_type(cls):
return "segments"
def create_port(self, context, port):