"""
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
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)
# @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
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)
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
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)
"""
import logging as LOG
-import string
-import subprocess
from quantum.plugins.cisco.common import cisco_constants as const
# 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>
</vlan>
"""
-cmd_no_vlan_conf_snippet = """
+CMD_NO_VLAN_CONF_SNIPPET = """
<no>
<vlan>
<vlan-id-create-delete>
</no>
"""
-cmd_vlan_int_snippet = """
+CMD_VLAN_INT_SNIPPET = """
<interface>
<ethernet>
<interface>%s</interface>
</interface>
"""
-cmd_port_trunk = """
+CMD_PORT_TRUNK = """
<interface>
<ethernet>
<interface>%s</interface>
</interface>
"""
-cmd_no_switchport = """
+CMD_NO_SWITCHPORT = """
<interface>
<ethernet>
<interface>%s</interface>
"""
-cmd_no_vlan_int_snippet = """
+CMD_NO_VLAN_INT_SNIPPET = """
<interface>
<ethernet>C: 1: Missing docstring
<interface>%s</interface>
"""
-filter_show_vlan_brief_snippet = """
+FILTER_SHOW_VLAN_BRIEF_SNIPPET = """
<show xmlns="http://www.cisco.com/nxos:1.0:vlan_mgr_cli">
<vlan>
<brief/>