Merge "Enables Cisco NXOS to configure multiple ports Implements blueprint cisco-nxos-enables-multiple-ports"
This commit is contained in:
commit
c6f591b7ae
@ -1,9 +1,8 @@
|
||||
[SWITCH]
|
||||
# Change the following to reflect the Nexus switch details
|
||||
nexus_ip_address=<put_nexus_switch_ip_address_here>
|
||||
#Interfaces connected from the Nexus 7K Switch to the two UCSM 6120s, e.g.: 1/10 and 1/11
|
||||
nexus_first_port=<put_interface_name_here>
|
||||
nexus_second_port=<put_interface_name_here>
|
||||
#Interfaces connected from the Nexus Switch to the compute hosts ports, e.g.: 1/10 and 1/11
|
||||
ports=<put_interfaces_names_here_separated_by_commas>
|
||||
#Port number where the SSH will be running at the Nexus Switch, e.g.: 22 (Default)
|
||||
nexus_ssh_port=22
|
||||
|
||||
|
@ -97,10 +97,9 @@ nexus_plugin=quantum.plugins.cisco.nexus.cisco_nexus_plugin_v2.NexusPlugin
|
||||
# This will be the address at which Quantum sends and receives configuration
|
||||
# information via SSHv2.
|
||||
nexus_ip_address=10.0.0.1
|
||||
# Port numbers on the Nexus switch to each one of the UCSM 6120s is connected
|
||||
# Use shortened interface syntax, e.g. "1/10" not "Ethernet1/10".
|
||||
nexus_first_port=1/10
|
||||
nexus_second_port=1/11
|
||||
# Port numbers on the Nexus switch to each one of the compute nodes are connected
|
||||
# Use shortened interface syntax, e.g. "1/10" not "Ethernet1/10" and "," between ports.
|
||||
ports=1/10,1/11,1/12
|
||||
#Port number where SSH will be running on the Nexus switch. Typically this is 22
|
||||
#unless you've configured your switch otherwise.
|
||||
nexus_ssh_port=22
|
||||
@ -278,16 +277,14 @@ nexus_plugin=quantum.plugins.cisco.nexus.cisco_nexus_plugin_v2.NexusPlugin
|
||||
When not using Nexus hardware use the following dummy configuration verbatim:
|
||||
[SWITCH]
|
||||
nexus_ip_address=1.1.1.1
|
||||
nexus_first_port=1/10
|
||||
nexus_second_port=1/11
|
||||
ports=1/10,1/11,1/12
|
||||
nexus_ssh_port=22
|
||||
[DRIVER]
|
||||
name=quantum.plugins.cisco.tests.unit.v2.nexus.fake_nexus_driver.CiscoNEXUSFakeDriver
|
||||
Or when using Nexus hardware (put the values relevant to your setup):
|
||||
[SWITCH]
|
||||
nexus_ip_address=1.1.1.1
|
||||
nexus_first_port=1/10
|
||||
nexus_second_port=1/11
|
||||
ports=1/10,1/11,1/12
|
||||
nexus_ssh_port=22
|
||||
[DRIVER]
|
||||
name=quantum.plugins.cisco.nexus.cisco_nexus_network_driver.CiscoNEXUSDriver
|
||||
|
@ -137,6 +137,11 @@ class NexusPortBindingNotFound(exceptions.QuantumException):
|
||||
message = _("Nexus Port Binding %(port_id) is not present")
|
||||
|
||||
|
||||
class NexusPortBindingAlreadyExists(exceptions.QuantumException):
|
||||
"""NexusPort Binding alredy exists"""
|
||||
message = _("Nexus Port Binding %(port_id) already exists")
|
||||
|
||||
|
||||
class UcsmBindingNotFound(exceptions.QuantumException):
|
||||
"""Ucsm Binding is not present"""
|
||||
message = _("Ucsm Binding with ip %(ucsm_ip) is not present")
|
||||
|
@ -29,7 +29,7 @@ from quantum.plugins.cisco.common import cisco_exceptions as cexc
|
||||
from quantum.plugins.cisco.common import cisco_utils as cutil
|
||||
from quantum.plugins.cisco.db import network_db_v2 as cdb
|
||||
from quantum.plugins.cisco import l2network_plugin_configuration as conf
|
||||
from quantum.quantum_plugin_base import QuantumPluginBase
|
||||
from quantum.quantum_plugin_base_v2 import QuantumPluginBaseV2
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
@ -32,8 +32,7 @@ CP = confp.CiscoConfigParser(find_config_file({'plugin': 'cisco'},
|
||||
|
||||
SECTION = CP['SWITCH']
|
||||
NEXUS_IP_ADDRESS = SECTION['nexus_ip_address']
|
||||
NEXUS_FIRST_PORT = SECTION['nexus_first_port']
|
||||
NEXUS_SECOND_PORT = SECTION['nexus_second_port']
|
||||
NEXUS_PORTS = SECTION['ports']
|
||||
NEXUS_SSH_PORT = SECTION['nexus_ssh_port']
|
||||
|
||||
SECTION = CP['DRIVER']
|
||||
|
@ -25,7 +25,7 @@ import logging
|
||||
|
||||
from ncclient import manager
|
||||
|
||||
from quantum.plugins.cisco.db import l2network_db as cdb
|
||||
from quantum.plugins.cisco.db import network_db_v2 as cdb
|
||||
from quantum.plugins.cisco.nexus import cisco_nexus_snippets as snipp
|
||||
|
||||
|
||||
@ -110,8 +110,7 @@ class CiscoNEXUSDriver():
|
||||
mgr.edit_config(target='running', config=confstr)
|
||||
|
||||
def create_vlan(self, vlan_name, vlan_id, nexus_host, nexus_user,
|
||||
nexus_password, nexus_first_interface,
|
||||
nexus_second_interface, nexus_ssh_port):
|
||||
nexus_password, nexus_ports, 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
|
||||
@ -121,14 +120,11 @@ class CiscoNEXUSDriver():
|
||||
self.enable_vlan(man, vlan_id, vlan_name)
|
||||
vlan_ids = self.build_vlans_cmd()
|
||||
LOG.debug("NexusDriver VLAN IDs: %s" % vlan_ids)
|
||||
self.enable_vlan_on_trunk_int(man, nexus_first_interface,
|
||||
vlan_ids)
|
||||
self.enable_vlan_on_trunk_int(man, nexus_second_interface,
|
||||
vlan_ids)
|
||||
for ports in nexus_ports:
|
||||
self.enable_vlan_on_trunk_int(man, ports, vlan_ids)
|
||||
|
||||
def delete_vlan(self, vlan_id, nexus_host, nexus_user, nexus_password,
|
||||
nexus_first_interface, nexus_second_interface,
|
||||
nexus_ssh_port):
|
||||
nexus_ports, nexus_ssh_port):
|
||||
"""
|
||||
Delete a VLAN and Disables trunk mode an interface on Nexus Switch
|
||||
given the VLAN ID and Interface Number
|
||||
@ -136,10 +132,8 @@ class CiscoNEXUSDriver():
|
||||
with self.nxos_connect(nexus_host, int(nexus_ssh_port), nexus_user,
|
||||
nexus_password) as man:
|
||||
self.disable_vlan(man, vlan_id)
|
||||
self.disable_vlan_on_trunk_int(man, nexus_first_interface,
|
||||
vlan_id)
|
||||
self.disable_vlan_on_trunk_int(man, nexus_second_interface,
|
||||
vlan_id)
|
||||
for ports in nexus_ports:
|
||||
self.disable_vlan_on_trunk_int(man, ports, vlan_id)
|
||||
|
||||
def build_vlans_cmd(self):
|
||||
"""
|
||||
|
@ -26,7 +26,8 @@ from quantum.common import exceptions as exc
|
||||
from quantum.db import api as db
|
||||
from quantum.openstack.common import importutils
|
||||
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_credentials_v2 as cred
|
||||
from quantum.plugins.cisco.common import cisco_exceptions as excep
|
||||
from quantum.plugins.cisco.db import network_db_v2 as cdb
|
||||
from quantum.plugins.cisco.db import nexus_db_v2 as nxos_db
|
||||
from quantum.plugins.cisco.l2device_plugin_base import L2DevicePluginBase
|
||||
@ -51,8 +52,7 @@ class NexusPlugin(L2DevicePluginBase):
|
||||
self._nexus_ip = conf.NEXUS_IP_ADDRESS
|
||||
self._nexus_username = cred.Store.get_username(conf.NEXUS_IP_ADDRESS)
|
||||
self._nexus_password = cred.Store.get_password(conf.NEXUS_IP_ADDRESS)
|
||||
self._nexus_first_port = conf.NEXUS_FIRST_PORT
|
||||
self._nexus_second_port = conf.NEXUS_SECOND_PORT
|
||||
self._nexus_ports = conf.NEXUS_PORTS
|
||||
self._nexus_ssh_port = conf.NEXUS_SSH_PORT
|
||||
|
||||
def get_all_networks(self, tenant_id):
|
||||
@ -74,10 +74,12 @@ class NexusPlugin(L2DevicePluginBase):
|
||||
self._client.create_vlan(
|
||||
vlan_name, str(vlan_id), self._nexus_ip,
|
||||
self._nexus_username, self._nexus_password,
|
||||
self._nexus_first_port, self._nexus_second_port,
|
||||
self._nexus_ssh_port)
|
||||
nxos_db.add_nexusport_binding(self._nexus_first_port, str(vlan_id))
|
||||
nxos_db.add_nexusport_binding(self._nexus_second_port, str(vlan_id))
|
||||
self._nexus_ports, self._nexus_ssh_port)
|
||||
for ports in self._nexus_ports:
|
||||
try:
|
||||
nxos_db.add_nexusport_binding(ports, str(vlan_id))
|
||||
except:
|
||||
raise excep.NexusPortBindingAlreadyExists(port_id=ports)
|
||||
|
||||
new_net_dict = {const.NET_ID: net_id,
|
||||
const.NET_NAME: net_name,
|
||||
@ -105,8 +107,7 @@ class NexusPlugin(L2DevicePluginBase):
|
||||
self._client.delete_vlan(
|
||||
str(vlan_id), self._nexus_ip,
|
||||
self._nexus_username, self._nexus_password,
|
||||
self._nexus_first_port, self._nexus_second_port,
|
||||
self._nexus_ssh_port)
|
||||
self._nexus_ports, self._nexus_ssh_port)
|
||||
return net
|
||||
# Network not found
|
||||
raise exc.NetworkNotFound(net_id=net_id)
|
||||
|
@ -99,7 +99,7 @@ CMD_PORT_TRUNK = """
|
||||
</trunk>
|
||||
</mode>
|
||||
</switchport>
|
||||
</__XML__MODE_if-ethernet-switch>C: 1: Missing docstring
|
||||
</__XML__MODE_if-ethernet-switch>
|
||||
</ethernet>
|
||||
</interface>
|
||||
"""
|
||||
@ -121,7 +121,7 @@ CMD_NO_SWITCHPORT = """
|
||||
|
||||
CMD_NO_VLAN_INT_SNIPPET = """
|
||||
<interface>
|
||||
<ethernet>C: 1: Missing docstring
|
||||
<ethernet>
|
||||
<interface>%s</interface>
|
||||
<__XML__MODE_if-ethernet-switch>
|
||||
<switchport></switchport>
|
||||
|
@ -77,8 +77,7 @@ class CiscoNEXUSFakeDriver():
|
||||
pass
|
||||
|
||||
def create_vlan(self, vlan_name, vlan_id, nexus_host, nexus_user,
|
||||
nexus_password, nexus_first_interface,
|
||||
nexus_second_interface, nexus_ssh_port):
|
||||
nexus_password, nexus_ports, 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
|
||||
@ -86,8 +85,7 @@ class CiscoNEXUSFakeDriver():
|
||||
pass
|
||||
|
||||
def delete_vlan(self, vlan_id, nexus_host, nexus_user, nexus_password,
|
||||
nexus_first_interface, nexus_second_interface,
|
||||
nexus_ssh_port):
|
||||
nexus_ports, nexus_ssh_port):
|
||||
"""
|
||||
Delete a VLAN and Disables trunk mode an interface on Nexus Switch
|
||||
given the VLAN ID and Interface Number
|
||||
|
Loading…
Reference in New Issue
Block a user