]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
pep8 passed
authoreperdomo@cisco.com <>
Tue, 16 Aug 2011 00:17:20 +0000 (17:17 -0700)
committereperdomo@cisco.com <>
Tue, 16 Aug 2011 00:17:20 +0000 (17:17 -0700)
pylint 8.83

quantum/plugins/cisco/nexus/__init__.py
quantum/plugins/cisco/nexus/cisco_nexus_configuration.py
quantum/plugins/cisco/nexus/cisco_nexus_network_driver.py
quantum/plugins/cisco/nexus/cisco_nexus_plugin.py
quantum/plugins/cisco/nexus/cisco_nexus_snippets.py

index db695fb0afb5d6a63f051006fba6aae6297a7414..963eb547f80969f72f25819207c0b9618867a868 100644 (file)
@@ -15,4 +15,7 @@
 #    under the License.
 #
 # @author: Sumit Naiksatam, Cisco Systems, Inc.
-#
+# @author: Edgar Magana, Cisco Systems, Inc.
+"""
+Init module for Nexus Driver
+"""
index b8987a5ce9d357a706da76af971188abc189ff1d..507ccd2a6d3c347be22a4b9b849e2264abb51b79 100644 (file)
 # @author: Sumit Naiksatam, Cisco Systems, Inc.
 # @author: Edgar Magana, Cisco Systems, Inc.
 #
-
+"""
+Configuration consolidation for the Nexus Driver
+This module will export the configuration parameters
+from the nexus.ini file
+"""
 import os
 
 from quantum.plugins.cisco.common import cisco_configparser as confp
 
 CONF_FILE = "../conf/nexus.ini"
 
-cp = confp.CiscoConfigParser(os.path.dirname(os.path.realpath(__file__)) \
+CP = confp.CiscoConfigParser(os.path.dirname(os.path.realpath(__file__)) \
                              + "/" + CONF_FILE)
 
-section = cp['SWITCH']
-NEXUS_IP_ADDRESS = section['nexus_ip_address']
-NEXUS_PORT = section['nexus_port']
-NEXUS_SSH_PORT = section['nexus_ssh_port']
+SECTION = CP['SWITCH']
+NEXUS_IP_ADDRESS = SECTION['nexus_ip_address']
+NEXUS_PORT = SECTION['nexus_port']
+NEXUS_SSH_PORT = SECTION['nexus_ssh_port']
 
-section = cp['DRIVER']
-NEXUS_DRIVER = section['name']
+SECTION = CP['DRIVER']
+NEXUS_DRIVER = SECTION['name']
 
 
 def main():
+    """
+    Indicates the value of the Nexus Port
+    """
     print NEXUS_PORT
 
 if __name__ == '__main__':
index f0c16274f6704f28a3b1fac6835636640839fe09..3f92353492e4b6bef4cb4860b551c1fe3d26dfa6 100644 (file)
@@ -22,11 +22,8 @@ Implements a Nexus-OS NETCONF over SSHv2 API Client
 """
 
 import logging as LOG
-import string
-import subprocess
 
 from quantum.plugins.cisco.common import cisco_constants as const
-from quantum.plugins.cisco.common import cisco_exceptions as cexc
 from quantum.plugins.cisco.nexus import cisco_nexus_snippets as snipp
 
 from ncclient import manager
@@ -36,60 +33,93 @@ LOG.getLogger(const.LOGGER_COMPONENT_NAME)
 
 
 class CiscoNEXUSDriver():
-
+    """
+    Nexus Driver Main Class
+    """
     def __init__(self):
         pass
 
     def nxos_connect(self, nexus_host, nexus_ssh_port, nexus_user,
                      nexus_password):
-            m = manager.connect(host=nexus_host, port=nexus_ssh_port,
+        """
+        Makes the SSH connection to the Nexus Switch
+        """
+        man = manager.connect(host=nexus_host, port=nexus_ssh_port,
                                 username=nexus_user, password=nexus_password)
-            return m
+        return man
 
     def enable_vlan(self, mgr, vlanid, vlanname):
-        confstr = snipp.cmd_vlan_conf_snippet % (vlanid, vlanname)
-        confstr = snipp.exec_conf_prefix + confstr + snipp.exec_conf_postfix
+        """
+        Creates a VLAN on Nexus Switch given the VLAN ID and Name
+        """
+        confstr = snipp.CMD_VLAN_CONF_SNIPPET % (vlanid, vlanname)
+        confstr = snipp.EXEC_CONF_PREFIX + confstr + snipp.EXEC_CONF_POSTFIX
         mgr.edit_config(target='running', config=confstr)
 
     def disable_vlan(self, mgr, vlanid):
-        confstr = snipp.cmd_no_vlan_conf_snippet % vlanid
-        confstr = snipp.exec_conf_prefix + confstr + snipp.exec_conf_postfix
+        """
+        Delete a VLAN on Nexus Switch given the VLAN ID
+        """
+        confstr = snipp.CMD_NO_VLAN_CONF_SNIPPET % vlanid
+        confstr = snipp.EXEC_CONF_PREFIX + confstr + snipp.EXEC_CONF_POSTFIX
         mgr.edit_config(target='running', config=confstr)
 
     def enable_port_trunk(self, mgr, interface):
-        confstr = snipp.cmd_port_trunk % (interface)
-        confstr = snipp.exec_conf_prefix + confstr + snipp.exec_conf_postfix
+        """
+        Enables trunk mode an interface on Nexus Switch
+        """
+        confstr = snipp.CMD_PORT_TRUNK % (interface)
+        confstr = snipp.EXEC_CONF_PREFIX + confstr + snipp.EXEC_CONF_POSTFIX
         LOG.debug("NexusDriver: %s" % confstr)
         mgr.edit_config(target='running', config=confstr)
 
     def disable_switch_port(self, mgr, interface):
-        confstr = snipp.cmd_no_switchport % (interface)
-        confstr = snipp.exec_conf_prefix + confstr + snipp.exec_conf_postfix
+        """
+        Disables trunk mode an interface on Nexus Switch
+        """
+        confstr = snipp.CMD_NO_SWITCHPORT % (interface)
+        confstr = snipp.EXEC_CONF_PREFIX + confstr + snipp.EXEC_CONF_POSTFIX
         LOG.debug("NexusDriver: %s" % confstr)
         mgr.edit_config(target='running', config=confstr)
 
     def enable_vlan_on_trunk_int(self, mgr, interface, vlanid):
-        confstr = snipp.cmd_vlan_int_snippet % (interface, vlanid)
-        confstr = snipp.exec_conf_prefix + confstr + snipp.exec_conf_postfix
+        """
+        Enables trunk mode vlan access an interface on Nexus Switch given
+        VLANID
+        """
+        confstr = snipp.CMD_VLAN_INT_SNIPPET % (interface, vlanid)
+        confstr = snipp.EXEC_CONF_PREFIX + confstr + snipp.EXEC_CONF_POSTFIX
         LOG.debug("NexusDriver: %s" % confstr)
         mgr.edit_config(target='running', config=confstr)
 
     def disable_vlan_on_trunk_int(self, mgr, interface, vlanid):
-        confstr = snipp.cmd_no_vlan_int_snippet % (interface, vlanid)
-        confstr = snipp.exec_conf_prefix + confstr + snipp.exec_conf_postfix
+        """
+        Enables trunk mode vlan access an interface on Nexus Switch given
+        VLANID
+        """
+        confstr = snipp.CMD_NO_VLAN_INT_SNIPPET % (interface, vlanid)
+        confstr = snipp.EXEC_CONF_PREFIX + confstr + snipp.EXEC_CONF_POSTFIX
         LOG.debug("NexusDriver: %s" % confstr)
         mgr.edit_config(target='running', config=confstr)
 
     def create_vlan(self, vlan_name, vlan_id, nexus_host, nexus_user,
                     nexus_password, nexus_interface, nexus_ssh_port):
+        """
+        Creates a VLAN and Enable on trunk mode an interface on Nexus Switch
+        given the VLAN ID and Name and Interface Number
+        """
         with self.nxos_connect(nexus_host, int(nexus_ssh_port), nexus_user,
-                               nexus_password) as m:
-            self.enable_vlan(m, vlan_id, vlan_name)
-            self.enable_vlan_on_trunk_int(m, nexus_interface, vlan_id)
+                               nexus_password) as man:
+            self.enable_vlan(man, vlan_id, vlan_name)
+            self.enable_vlan_on_trunk_int(man, nexus_interface, vlan_id)
 
     def delete_vlan(self, vlan_id, nexus_host, nexus_user,
                     nexus_password, nexus_interface, nexus_ssh_port):
+        """
+        Delete a VLAN and Disables trunk mode an interface on Nexus Switch
+        given the VLAN ID and Interface Number
+        """
         with self.nxos_connect(nexus_host, int(nexus_ssh_port), nexus_user,
-                               nexus_password) as m:
-            self.disable_vlan(m, vlan_id)
-            self.disable_switch_port(m, nexus_interface)
+                               nexus_password) as man:
+            self.disable_vlan(man, vlan_id)
+            self.disable_switch_port(man, nexus_interface)
index e27269ed64ff927ce257dbadc9e2c66c84f2580f..84085ff3f0807c2825fdbaa445c745bd786b4ac1 100644 (file)
 # @author: Sumit Naiksatam, Cisco Systems, Inc.
 # @author: Edgar Magana, Cisco Systems, Inc.
 #
+"""
+PlugIn for Nexus OS driver
+"""
 import logging as LOG
 
 from quantum.common import exceptions as exc
 from quantum.common import utils
 from quantum.plugins.cisco.common import cisco_constants as const
 from quantum.plugins.cisco.common import cisco_credentials as cred
-from quantum.plugins.cisco.common import cisco_exceptions as cexc
-from quantum.plugins.cisco.common import cisco_utils as cutil
 from quantum.plugins.cisco.l2device_plugin_base import L2DevicePluginBase
 from quantum.plugins.cisco.nexus import cisco_nexus_configuration as conf
 
@@ -33,12 +34,17 @@ LOG.getLogger(const.LOGGER_COMPONENT_NAME)
 
 
 class NexusPlugin(L2DevicePluginBase):
+    """
+    Nexus PLugIn Main Class
+    """
     _networks = {}
 
     def __init__(self):
+        """
+        Extracts the configuration parameters from the configuration file
+        """
         self._client = utils.import_object(conf.NEXUS_DRIVER)
         LOG.debug("Loaded driver %s\n" % conf.NEXUS_DRIVER)
-        #TODO (Edgar) Using just one Nexus 7K Switch and Port
         self._nexus_ip = conf.NEXUS_IP_ADDRESS
         self._nexus_username = cred.Store.getUsername(conf.NEXUS_IP_ADDRESS)
         self._nexus_password = cred.Store.getPassword(conf.NEXUS_IP_ADDRESS)
@@ -103,7 +109,6 @@ class NexusPlugin(L2DevicePluginBase):
         Updates the symbolic name belonging to a particular
         Virtual Network.
         """
-        #TODO (Edgar) We need to add an update method in the Nexus Driver
         LOG.debug("NexusPlugin:rename_network() called\n")
         network = self._get_network(tenant_id, net_id)
         network[const.NET_NAME] = new_name
@@ -160,11 +165,17 @@ class NexusPlugin(L2DevicePluginBase):
         LOG.debug("NexusPlugin:unplug_interface() called\n")
 
     def _get_vlan_id_for_network(self, tenant_id, network_id):
+        """
+        Obtain the VLAN ID given the Network ID
+        """
         net = self._get_network(tenant_id, network_id)
         vlan_id = net[const.NET_VLAN_ID]
         return vlan_id
 
     def _get_network(self, tenant_id, network_id):
+        """
+        Gets the NETWORK ID
+        """
         network = self._networks.get(network_id)
         if not network:
             raise exc.NetworkNotFound(net_id=network_id)
index a3bc004d2d0c1a6d7b68d3f8d53289c1c4d49962..9c7dab058ecdc03c3c1b37a99ad476c5c4a4aae2 100644 (file)
@@ -21,8 +21,6 @@ Nexus-OS XML-based configuration snippets
 """
 
 import logging as LOG
-import string
-import subprocess
 
 from quantum.plugins.cisco.common import cisco_constants as const
 
@@ -31,21 +29,21 @@ LOG.getLogger(const.LOGGER_COMPONENT_NAME)
 
 
 # The following are standard strings, messages used to communicate with Nexus,
-exec_conf_prefix = """
+EXEC_CONF_PREFIX = """
       <config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0">
         <configure xmlns="http://www.cisco.com/nxos:1.0:vlan_mgr_cli">
           <__XML__MODE__exec_configure>
 """
 
 
-exec_conf_postfix = """
+EXEC_CONF_POSTFIX = """
           </__XML__MODE__exec_configure>
         </configure>
       </config>
 """
 
 
-cmd_vlan_conf_snippet = """
+CMD_VLAN_CONF_SNIPPET = """
             <vlan>
               <vlan-id-create-delete>
                 <__XML__PARAM_value>%s</__XML__PARAM_value>
@@ -64,7 +62,7 @@ cmd_vlan_conf_snippet = """
             </vlan>
 """
 
-cmd_no_vlan_conf_snippet = """
+CMD_NO_VLAN_CONF_SNIPPET = """
           <no>
           <vlan>
             <vlan-id-create-delete>
@@ -74,7 +72,7 @@ cmd_no_vlan_conf_snippet = """
           </no>
 """
 
-cmd_vlan_int_snippet = """
+CMD_VLAN_INT_SNIPPET = """
           <interface>
             <ethernet>
               <interface>%s</interface>
@@ -96,7 +94,7 @@ cmd_vlan_int_snippet = """
           </interface>
 """
 
-cmd_port_trunk = """
+CMD_PORT_TRUNK = """
           <interface>
             <ethernet>
               <interface>%s</interface>
@@ -113,7 +111,7 @@ cmd_port_trunk = """
           </interface>
 """
 
-cmd_no_switchport = """
+CMD_NO_SWITCHPORT = """
           <interface>
             <ethernet>
               <interface>%s</interface>
@@ -128,7 +126,7 @@ cmd_no_switchport = """
 """
 
 
-cmd_no_vlan_int_snippet = """
+CMD_NO_VLAN_INT_SNIPPET = """
           <interface>
             <ethernet>C:  1: Missing docstring
               <interface>%s</interface>
@@ -153,7 +151,7 @@ cmd_no_vlan_int_snippet = """
 """
 
 
-filter_show_vlan_brief_snippet = """
+FILTER_SHOW_VLAN_BRIEF_SNIPPET = """
       <show xmlns="http://www.cisco.com/nxos:1.0:vlan_mgr_cli">
         <vlan>
           <brief/>