]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Code changed base on Reviews
authorEdgar Magana <eperdomo@cisco.com>
Tue, 23 Aug 2011 20:05:22 +0000 (13:05 -0700)
committerEdgar Magana <eperdomo@cisco.com>
Tue, 23 Aug 2011 20:05:22 +0000 (13:05 -0700)
pep8 passed
pylint 9.10

quantum/plugins/cisco/nexus/cisco_nexus_network_driver.py
quantum/plugins/cisco/nexus/cisco_nexus_snippets.py

index 3f92353492e4b6bef4cb4860b551c1fe3d26dfa6..3720bb1aa2219399b0faad547e0c53247ae7dd9d 100644 (file)
@@ -48,12 +48,19 @@ class CiscoNEXUSDriver():
                                 username=nexus_user, password=nexus_password)
         return man
 
+    def create_xml_snippet(self, cutomized_config):
+        """
+        Creates the Proper XML structure for the Nexus Switch Configuration
+        """
+        conf_xml_snippet = snipp.EXEC_CONF_SNIPPET % (cutomized_config)
+        return conf_xml_snippet
+
     def enable_vlan(self, mgr, vlanid, vlanname):
         """
         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
+        confstr = self.create_xml_snippet(confstr)
         mgr.edit_config(target='running', config=confstr)
 
     def disable_vlan(self, mgr, vlanid):
@@ -61,7 +68,7 @@ class CiscoNEXUSDriver():
         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
+        confstr = self.create_xml_snippet(confstr)
         mgr.edit_config(target='running', config=confstr)
 
     def enable_port_trunk(self, mgr, interface):
@@ -69,7 +76,7 @@ class CiscoNEXUSDriver():
         Enables trunk mode an interface on Nexus Switch
         """
         confstr = snipp.CMD_PORT_TRUNK % (interface)
-        confstr = snipp.EXEC_CONF_PREFIX + confstr + snipp.EXEC_CONF_POSTFIX
+        confstr = self.create_xml_snippet(confstr)
         LOG.debug("NexusDriver: %s" % confstr)
         mgr.edit_config(target='running', config=confstr)
 
@@ -78,7 +85,7 @@ class CiscoNEXUSDriver():
         Disables trunk mode an interface on Nexus Switch
         """
         confstr = snipp.CMD_NO_SWITCHPORT % (interface)
-        confstr = snipp.EXEC_CONF_PREFIX + confstr + snipp.EXEC_CONF_POSTFIX
+        confstr = self.create_xml_snippet(confstr)
         LOG.debug("NexusDriver: %s" % confstr)
         mgr.edit_config(target='running', config=confstr)
 
@@ -88,7 +95,7 @@ class CiscoNEXUSDriver():
         VLANID
         """
         confstr = snipp.CMD_VLAN_INT_SNIPPET % (interface, vlanid)
-        confstr = snipp.EXEC_CONF_PREFIX + confstr + snipp.EXEC_CONF_POSTFIX
+        confstr = self.create_xml_snippet(confstr)
         LOG.debug("NexusDriver: %s" % confstr)
         mgr.edit_config(target='running', config=confstr)
 
@@ -98,7 +105,7 @@ class CiscoNEXUSDriver():
         VLANID
         """
         confstr = snipp.CMD_NO_VLAN_INT_SNIPPET % (interface, vlanid)
-        confstr = snipp.EXEC_CONF_PREFIX + confstr + snipp.EXEC_CONF_POSTFIX
+        confstr = self.create_xml_snippet(confstr)
         LOG.debug("NexusDriver: %s" % confstr)
         mgr.edit_config(target='running', config=confstr)
 
index 9c7dab058ecdc03c3c1b37a99ad476c5c4a4aae2..df713fb5bc03420655213b233d70bc8395ba8b2d 100644 (file)
@@ -29,14 +29,10 @@ LOG.getLogger(const.LOGGER_COMPONENT_NAME)
 
 
 # The following are standard strings, messages used to communicate with Nexus,
-EXEC_CONF_PREFIX = """
+EXEC_CONF_SNIPPET = """
       <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 = """
+          <__XML__MODE__exec_configure>%s
           </__XML__MODE__exec_configure>
         </configure>
       </config>
@@ -156,4 +152,5 @@ FILTER_SHOW_VLAN_BRIEF_SNIPPET = """
         <vlan>
           <brief/>
         </vlan>
-      </show> """
+      </show>
+"""