]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Remove redunant key list generation in Cisco plugin
authorZhongyue Luo <zhongyue.nah@intel.com>
Wed, 30 Jan 2013 08:57:20 +0000 (16:57 +0800)
committerZhongyue Luo <zhongyue.nah@intel.com>
Thu, 31 Jan 2013 01:58:52 +0000 (09:58 +0800)
Evaluates existance of key directly on dictionary.

Fixes bug #1110957

Change-Id: I9b46a991ab9c764d7451cc122d208e06778c1ee1

quantum/plugins/cisco/models/network_multi_blade_v2.py
quantum/plugins/cisco/models/virt_phy_sw_v2.py
quantum/plugins/cisco/nexus/cisco_nexus_plugin_v2.py
quantum/plugins/cisco/services/services_logistics.py

index e47763291765a967e03815f69b1f252f0679bb81..84bb43b736dcc3152406739df905e647a0fb61e2 100644 (file)
@@ -1,6 +1,7 @@
 # vim: tabstop=4 shiftwidth=4 softtabstop=4
-#
-# Copyright 2012 Cisco Systems, Inc.  All rights reserved.
+
+# Copyright 2012 Cisco Systems, Inc.
+# All rights reserved.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
 #    not use this file except in compliance with the License. You may obtain
@@ -15,6 +16,7 @@
 #    under the License.
 #
 # @author: Sumit Naiksatam, Cisco Systems, Inc.
+#
 
 from copy import deepcopy
 import inspect
@@ -74,7 +76,7 @@ class NetworkMultiBladeV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
         Invokes a device plugin's relevant functions (on the it's
         inventory and plugin implementation) for completing this operation.
         """
-        if not plugin_key in self._plugins.keys():
+        if plugin_key not in self._plugins:
             LOG.info(_("No %s Plugin loaded"), plugin_key)
             LOG.info(_("%(plugin_key)s: %(function_name)s with args %(args)s "
                        "ignored"), locals())
@@ -99,7 +101,7 @@ class NetworkMultiBladeV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
         Invokes the relevant function on a device plugin's
         inventory for completing this operation.
         """
-        if not plugin_key in self._inventory.keys():
+        if plugin_key not in self._inventory:
             LOG.info(_("No %s inventory loaded"), plugin_key)
             LOG.info(_("%(plugin_key)s: %(function_name)s with args %(args)s "
                        "ignored"), locals())
index ed2230c4981bd0f15c208e61215d2a51740d56ef..22a77e3498fb3f840b3eff5a280dd96724637f0e 100644 (file)
@@ -1,6 +1,7 @@
 # vim: tabstop=4 shiftwidth=4 softtabstop=4
-#
-# Copyright 2012 Cisco Systems, Inc.  All rights reserved.
+
+# Copyright 2012 Cisco Systems, Inc.
+# All rights reserved.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
 #    not use this file except in compliance with the License. You may obtain
@@ -16,6 +17,7 @@
 #
 # @author: Sumit Naiksatam, Cisco Systems, Inc.
 # @author: Rohit Agarwalla, Cisco Systems, Inc.
+#
 
 from copy import deepcopy
 import inspect
@@ -34,6 +36,7 @@ from quantum.plugins.cisco import l2network_plugin_configuration as conf
 from quantum.plugins.openvswitch import ovs_db_v2 as odb
 from quantum import quantum_plugin_base_v2
 
+
 LOG = logging.getLogger(__name__)
 
 
@@ -114,7 +117,7 @@ class VirtualPhysicalSwitchModelV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
         Invokes a device plugin's relevant functions (on the it's
         inventory and plugin implementation) for completing this operation.
         """
-        if not plugin_key in self._plugins.keys():
+        if plugin_key not in self._plugins:
             LOG.info(_("No %s Plugin loaded"), plugin_key)
             LOG.info(_("%(plugin_key)s: %(function_name)s with args %(args)s "
                      "ignored"), locals())
@@ -139,7 +142,7 @@ class VirtualPhysicalSwitchModelV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
         Invokes the relevant function on a device plugin's
         inventory for completing this operation.
         """
-        if not plugin_key in self._inventory.keys():
+        if plugin_key not in self._inventory:
             LOG.info(_("No %s inventory loaded"), plugin_key)
             LOG.info(_("%(plugin_key)s: %(function_name)s with args %(args)s "
                      "ignored"), locals())
index fb62ddc927ab8fd3aa32c789bcd94362b1261ab6..232bad945d7c6ceafbb8909d2b19bffe1a366cc2 100644 (file)
@@ -1,6 +1,7 @@
 # vim: tabstop=4 shiftwidth=4 softtabstop=4
-#
-# Copyright 2012 Cisco Systems, Inc.  All rights reserved.
+
+# Copyright 2012 Cisco Systems, Inc.
+# All rights reserved.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
 #    not use this file except in compliance with the License. You may obtain
 # @author: Edgar Magana, Cisco Systems, Inc.
 # @author: Arvind Somya, Cisco Systems, Inc. (asomya@cisco.com)
 #
+
 """
 PlugIn for Nexus OS driver
 """
+
 import logging
 
 from quantum.common import exceptions as exc
@@ -55,7 +58,7 @@ class NexusPlugin(L2DevicePluginBase):
         self.credentials = {}
 
     def get_credential(self, nexus_ip):
-        if not nexus_ip in self.credentials.keys():
+        if nexus_ip not in self.credentials:
             _nexus_username = cred.Store.get_username(nexus_ip)
             _nexus_password = cred.Store.get_password(nexus_ip)
             self.credentials[nexus_ip] = {
index 57f8fc8e944d0d81d36a5f839e27258a59fa88b1..d09a67ee0dca86f5a2a4bf5c2616238510584513 100644 (file)
@@ -1,6 +1,7 @@
 # vim: tabstop=4 shiftwidth=4 softtabstop=4
-#
-# Copyright 2011 Cisco Systems, Inc.  All rights reserved.
+
+# Copyright 2011 Cisco Systems, Inc.
+# All rights reserved.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
 #    not use this file except in compliance with the License. You may obtain
@@ -15,6 +16,8 @@
 #    under the License.
 #
 #    @author: Edgar Magana, Cisco Systems
+#
+
 """
 Logistic components for Service Insertion utility
 """
@@ -109,7 +112,7 @@ class ServicesLogistics():
         for key in conf.PLUGINS[const.PLUGINS].keys():
             plugin_obj = conf.PLUGINS[const.PLUGINS][key]
             _plugins[key] = importutils.import_object(plugin_obj)
-        if not plugin_key in _plugins.keys():
+        if plugin_key not in _plugins:
             LOG.debug(_("No %s Plugin loaded"), plugin_key)
             return False
         else: