From 4ce8facd2ce9284187ded0098739952b6ca653e8 Mon Sep 17 00:00:00 2001 From: Edgar Magana Date: Tue, 23 Aug 2011 13:05:22 -0700 Subject: [PATCH] Code changed base on Reviews pep8 passed pylint 9.10 --- .../cisco/nexus/cisco_nexus_network_driver.py | 19 +++++++++++++------ .../cisco/nexus/cisco_nexus_snippets.py | 11 ++++------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/quantum/plugins/cisco/nexus/cisco_nexus_network_driver.py b/quantum/plugins/cisco/nexus/cisco_nexus_network_driver.py index 3f9235349..3720bb1aa 100644 --- a/quantum/plugins/cisco/nexus/cisco_nexus_network_driver.py +++ b/quantum/plugins/cisco/nexus/cisco_nexus_network_driver.py @@ -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) diff --git a/quantum/plugins/cisco/nexus/cisco_nexus_snippets.py b/quantum/plugins/cisco/nexus/cisco_nexus_snippets.py index 9c7dab058..df713fb5b 100644 --- a/quantum/plugins/cisco/nexus/cisco_nexus_snippets.py +++ b/quantum/plugins/cisco/nexus/cisco_nexus_snippets.py @@ -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 = """ - <__XML__MODE__exec_configure> -""" - - -EXEC_CONF_POSTFIX = """ + <__XML__MODE__exec_configure>%s @@ -156,4 +152,5 @@ FILTER_SHOW_VLAN_BRIEF_SNIPPET = """ - """ + +""" -- 2.45.2