cisco: Do not change supported_extension_aliases directly
cisco network plugin extends supported_extension_aliases in __init__ but supported_exntension_aliases is a class attribute and it is not reset to the original even after each unit test finished. To avoid this this patch copies supported_extension_aliases to an instance attribute and extends it to ensure the class variable is not changed. This reduces unnecessary logs in unit tests. Change-Id: I3a7313f5ca2d10b1ae6ea961d9d05611aee055c0 Closes-Bug: #1292742
This commit is contained in:
@@ -34,7 +34,7 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
class PluginV2(db_base_plugin_v2.NeutronDbPluginV2):
|
||||
"""Meta-Plugin with v2 API support for multiple sub-plugins."""
|
||||
supported_extension_aliases = ["credential", "Cisco qos"]
|
||||
_supported_extension_aliases = ["credential", "Cisco qos"]
|
||||
_methods_to_delegate = ['create_network',
|
||||
'delete_network', 'update_network', 'get_network',
|
||||
'get_networks',
|
||||
@@ -65,6 +65,15 @@ class PluginV2(db_base_plugin_v2.NeutronDbPluginV2):
|
||||
cexc.VlanIDNotFound: wexc.HTTPNotFound,
|
||||
}
|
||||
|
||||
@property
|
||||
def supported_extension_aliases(self):
|
||||
if not hasattr(self, '_aliases'):
|
||||
aliases = self._supported_extension_aliases[:]
|
||||
if hasattr(self._model, "supported_extension_aliases"):
|
||||
aliases.extend(self._model.supported_extension_aliases)
|
||||
self._aliases = aliases
|
||||
return self._aliases
|
||||
|
||||
def __init__(self):
|
||||
"""Load the model class."""
|
||||
self._model = importutils.import_object(config.CISCO.model_class)
|
||||
@@ -73,10 +82,6 @@ class PluginV2(db_base_plugin_v2.NeutronDbPluginV2):
|
||||
self.__native_bulk_support = getattr(self._model,
|
||||
native_bulk_attr_name, False)
|
||||
|
||||
if hasattr(self._model, "supported_extension_aliases"):
|
||||
self.supported_extension_aliases.extend(
|
||||
self._model.supported_extension_aliases)
|
||||
|
||||
neutron_extensions.append_api_extensions_path(extensions.__path__)
|
||||
|
||||
# Extend the fault map
|
||||
|
||||
Reference in New Issue
Block a user