Set RESTAPI Driver as default for ML2 Nexus

The ML2 Nexus Driver uses either a RESTAPI driver or the
ncclient driver to configure the Nexus devices.  This changeset makes
the REST API driver the default choice for use by the ML2 Nexus driver.
This replaces the original ssh/ncclient driver.  The Nexus 9K handles
the REST API more efficiently and with less session limitations.
Additionally, The REST API Driver will be enhanced with new features
while ncclient will not.  In time, the ncclient driver will become
deprecated in Queens release.

For the ML2 Nexus REST API driver to be successful, it requires more
recent Cisco Nexus N9K NXAPI images starting from Cisco NX-OS 7.0(3)I5.

Code has been added in this changeset to warn in log file that the
ncclient/ssh driver and associated config options are deprecated.

If ncclient is configured, the following warning will be logged.
DeprecationWarning: Using class 'CiscoNexusSshDriver' (either directly
or via inheritance) is deprecated in version 'Cisco 5.1.0' and will be
removed in version 'Cisco 7.0.0': CiscoNexusSshDriver replaced by
default CiscoNexusRestapiDriver.

Other configuration variables associated with ncclient have been tagged
for deprecation.  The following sample warning message will appear
for those marked as deprecated.
Option "never_cache_ssh_connection" from group "ml2_cisco" is deprecated
for removal.  Its value may be silently ignored in the future.

Change-Id: I20c9554999d2dcaa14de78d2d43da53e3d29317d
Closes-bug:  #1705036
This commit is contained in:
Carol Bouchard 2017-07-19 10:59:04 -04:00
parent 924ea0b371
commit 708bd97dee
9 changed files with 69 additions and 30 deletions

View File

@ -14,16 +14,21 @@
# (BoolOpt) A flag to enable strict hostkey checks when connecting to
# Nexus switches. Defaults to False (No hostkey checks)
# This will be deprecated along with nexus_driver since this is
# associated to the ncclient driver which is going away.
# host_key_checks = False
# (ListOp) A choice of drivers to configure Nexus devices. The
# default choice is 'ncclient' which was the original driver
# until rest api driver was developed. To choose the
# rest api driver, set nexus_driver to 'restapi' which
# has better performance and no Nexus session limits.
# This option should only be selected if you have a
# Nexus 9K image version 7.0(3)I5(2) or greater.
# nexus_driver = ncclient
# (ListOp) A choice of driver methods to configure Nexus devices.
# The default choice has changed to 'restapi' which replaces the
# original 'ncclient' driver. The RESTAPI driver has better
# performance with less Nexus session limits. Additionally,
# new feature development is applied only to restapi driver.
# Plans are to remove ncclient driver in Cisco 7.0.0 release.
# To use the restapi driver, the Nexus 9K image version must be
# 7.0(3)I5(2) or greater. For short term, the original driver can be
# used by setting the nexus_driver to 'ncclient'. The default is
# set to:
# nexus_driver = restapi
#
# (StrOpt) The name of the physical_network managed via the Cisco Nexus Switch.
@ -132,6 +137,8 @@
# CLI 'copy run start' after applying successful configurations.
# (default) This flag defaults to False keep consistent with
# existing functionality.
# This will be deprecated along with nexus_driver since this is
# associated to the ncclient driver which is going away.
#
# persistent_switch_config = False
@ -145,6 +152,8 @@
# (default) This flag defaults to False which indicates that ssh
# connections to a Nexus switch are cached when the neutron
# controller has fewer than 8 processes.
# This will be deprecated along with nexus_driver since this is
# associated to the ncclient driver which is going away.
#
# never_cache_ssh_connection = False

View File

@ -33,8 +33,10 @@ ml2_cisco_opts = [
cfg.StrOpt('provider_vlan_name_prefix', default='p-',
help=_("VLAN Name prefix for provider vlans")),
cfg.BoolOpt('persistent_switch_config', default=False,
deprecated_for_removal=True,
help=_("To make Nexus configuration persistent")),
cfg.BoolOpt('never_cache_ssh_connection', default=True,
deprecated_for_removal=True,
help=_("Prevent caching ssh connections to Nexus device")),
cfg.IntOpt('switch_heartbeat_time', default=0,
help=_("Periodic time to check switch connection. (0=disabled)")),
@ -49,10 +51,12 @@ ml2_cisco_opts = [
'feature nv overlay, feature vn-segment-vlan-based, '
'interface nve + source-interface loopback')),
cfg.BoolOpt('host_key_checks', default=False,
deprecated_for_removal=True,
help=_("Enable strict host key checks when "
"connecting to Nexus switches")),
cfg.StrOpt('nexus_driver',
default='ncclient',
default='restapi',
deprecated_for_removal=True,
help=_("Choice of Nexus Config Driver to be loaded from "
"the networking_cisco.ml2.nexus_driver namespace.")),

View File

@ -20,7 +20,9 @@ Implements a Nexus-OS NETCONF over SSHv2 API Client
import re
import six
import time
import warnings
from debtcollector import removals
from oslo_concurrency import lockutils
from oslo_config import cfg
from oslo_log import log as logging
@ -40,8 +42,14 @@ from networking_cisco.plugins.ml2.drivers.cisco.nexus import (
nexus_snippets as snipp)
LOG = logging.getLogger(__name__)
warnings.simplefilter('always')
@removals.removed_class('CiscoNexusSshDriver',
message="CiscoNexusSshDriver replaced by "
"default CiscoNexusRestapiDriver.",
version="Cisco 5.1.0",
removal_version="Cisco 7.0.0")
class CiscoNexusSshDriver(basedrvr.CiscoNexusBaseDriver):
"""Nexus Driver Main Class."""
def __init__(self):

View File

@ -328,6 +328,7 @@ class TestCiscoNexusDevice(test_cisco_nexus_base.TestCiscoNexusBase,
def setUp(self):
"""Sets up mock ncclient, and switch and credentials dictionaries."""
cfg.CONF.set_override('nexus_driver', 'ncclient', 'ml2_cisco')
cfg.CONF.set_override('never_cache_ssh_connection', False, 'ml2_cisco')
super(TestCiscoNexusDevice, self).setUp()
self.mock_ncclient.reset_mock()
@ -632,6 +633,7 @@ class TestCiscoNexusDeviceFailure(test_cisco_nexus_base.TestCiscoNexusBase,
def setUp(self):
"""Sets up mock ncclient, and switch and credentials dictionaries."""
cfg.CONF.set_override('nexus_driver', 'ncclient', 'ml2_cisco')
cfg.CONF.set_override('never_cache_ssh_connection', False, 'ml2_cisco')
super(TestCiscoNexusDeviceFailure, self).setUp()
self.mock_ncclient.reset_mock()
@ -1045,6 +1047,7 @@ class TestCiscoNexusDeviceInit(test_cisco_nexus_base.TestCiscoNexusBase,
def setUp(self):
"""Sets up mock ncclient, and switch and credentials dictionaries."""
cfg.CONF.set_override('nexus_driver', 'ncclient', 'ml2_cisco')
cfg.CONF.set_override('never_cache_ssh_connection', False, 'ml2_cisco')
super(TestCiscoNexusDeviceInit, self).setUp()
self.results = TestCiscoNexusInitResults()
@ -1259,6 +1262,7 @@ class TestCiscoNexusBaremetalDevice(test_cisco_nexus_base.TestCiscoNexusBase):
def setUp(self):
"""Sets up mock ncclient, and switch and credentials dictionaries."""
cfg.CONF.set_override('nexus_driver', 'ncclient', 'ml2_cisco')
cfg.CONF.set_override('never_cache_ssh_connection', False, 'ml2_cisco')
super(TestCiscoNexusBaremetalDevice, self).setUp()
self.results = TestCiscoNexusBaremetalResults()
@ -1580,6 +1584,11 @@ class TestCiscoNexusNonCacheSshDevice(
format('ethernet', '1\/10', 267),
test_cisco_nexus_base.RESULT_DEL_VLAN.format(267)])
def setUp(self):
cfg.CONF.set_override('nexus_driver', 'ncclient', 'ml2_cisco')
super(TestCiscoNexusNonCacheSshDevice, self).setUp()
self.mock_ncclient.reset_mock()
def test_create_delete_basic(self):
"""Basic creation and deletion test of 1 ethernet port."""

View File

@ -231,6 +231,7 @@ class TestCiscoNexusVxlanDevice(test_cisco_nexus_base.TestCiscoNexusBase,
def setUp(self):
"""Sets up mock ncclient, and switch and credentials dictionaries."""
cfg.CONF.set_override('nexus_driver', 'ncclient', 'ml2_cisco')
cfg.CONF.set_override('never_cache_ssh_connection', False, 'ml2_cisco')
super(TestCiscoNexusVxlanDevice, self).setUp()
self.mock_ncclient.reset_mock()

View File

@ -258,6 +258,7 @@ class TestCiscoNexusReplay(test_cisco_nexus_base.TestCiscoNexusReplayBase):
def setUp(self):
"""Sets up mock ncclient, and switch and credentials dictionaries."""
cfg.CONF.set_override('nexus_driver', 'ncclient', 'ml2_cisco')
cfg.CONF.set_override('never_cache_ssh_connection', False, 'ml2_cisco')
super(TestCiscoNexusReplay, self).setUp()
self.results = TestCiscoNexusReplayResults()
@ -1207,6 +1208,7 @@ class TestCiscoNexusBaremetalReplay(
def setUp(self):
"""Sets up mock ncclient, and switch and credentials dictionaries."""
cfg.CONF.set_override('nexus_driver', 'ncclient', 'ml2_cisco')
cfg.CONF.set_override('never_cache_ssh_connection', False, 'ml2_cisco')
super(TestCiscoNexusBaremetalReplay, self).setUp()
self.results = TestCiscoNexusBaremetalReplayResults()
@ -1432,6 +1434,11 @@ class TestCiscoNexusNonCachedSshReplay(
test_cisco_nexus_base.NORMAL_VNIC),
}
def setUp(self):
cfg.CONF.set_override('nexus_driver', 'ncclient', 'ml2_cisco')
super(TestCiscoNexusNonCachedSshReplay, self).setUp()
self.mock_ncclient.reset_mock()
def test_basic_replay_NonCacheSsh(self):
"""Basic none cached ssh replay test."""

View File

@ -29,8 +29,6 @@ redundant.
import mock
from oslo_config import cfg
from networking_cisco.plugins.ml2.drivers.cisco.nexus import (
nexus_db_v2 as nxos_db)
from networking_cisco.plugins.ml2.drivers.cisco.nexus import (
@ -228,8 +226,10 @@ class TestCiscoNexusRestDevice(test_cisco_nexus_events.TestCiscoNexusDevice):
"""Unit tests for Cisco ML2 Nexus restapi device driver"""
def setUp(self):
cfg.CONF.set_override('nexus_driver', 'restapi', 'ml2_cisco')
super(TestCiscoNexusRestDevice, self).setUp()
# Call Grandfather's setUp(); otherwise parent will set driver to
# 'ncclient' instead of 'restapi'.
super(test_cisco_nexus_events.TestCiscoNexusDevice, self).setUp()
self.mock_ncclient.reset_mock()
self.results = TestCiscoNexusRestDeviceResults()
def test_create_delete_duplicate_ports(self):
@ -399,9 +399,9 @@ class TestCiscoNexusRestDeviceInit(
def setUp(self):
"""Sets up mock ncclient, and switch and credentials dictionaries."""
cfg.CONF.set_override('nexus_driver', 'restapi', 'ml2_cisco')
cfg.CONF.set_override('never_cache_ssh_connection', False, 'ml2_cisco')
super(TestCiscoNexusRestDeviceInit, self).setUp()
# Call Grandfather's setUp(); otherwise parent will set driver to
# 'ncclient' instead of 'restapi'.
super(test_cisco_nexus_events.TestCiscoNexusDeviceInit, self).setUp()
self.results = TestCiscoNexusRestInitResults()
def test_verify_initialization(self):
@ -799,9 +799,10 @@ class TestCiscoNexusRestBaremetalDevice(
mock.patch.object(nxos_db,
'_get_free_vpcids_on_switches',
new=new_get_free_vpcids_on_switches).start()
cfg.CONF.set_override('nexus_driver', 'restapi', 'ml2_cisco')
cfg.CONF.set_override('never_cache_ssh_connection', False, 'ml2_cisco')
super(TestCiscoNexusRestBaremetalDevice, self).setUp()
# Call Grandfather's setUp(); otherwise parent will set driver to
# 'ncclient' instead of 'restapi'.
super(test_cisco_nexus_events.TestCiscoNexusBaremetalDevice,
self).setUp()
self.results = TestCiscoNexusRestBaremetalResults()
def test_create_delete_basic_bm_ethernet_port_and_vm(self):

View File

@ -28,7 +28,6 @@ apply to ssh only OR because rerunning the test would be
redundant.
"""
from oslo_config import cfg
from networking_cisco.plugins.ml2.drivers.cisco.nexus import (
nexus_restapi_snippets as snipp)
@ -242,9 +241,10 @@ class TestCiscoNexusRestVxlanDevice(
def setUp(self):
"""Sets up mock ncclient, and switch and credentials dictionaries."""
cfg.CONF.set_override('nexus_driver', 'restapi', 'ml2_cisco')
cfg.CONF.set_override('never_cache_ssh_connection', False, 'ml2_cisco')
super(TestCiscoNexusRestVxlanDevice, self).setUp()
# Call Grandfather's setUp(); otherwise parent will set driver to
# 'ncclient' instead of 'restapi'.
super(test_cisco_nexus_events_vxlan.TestCiscoNexusVxlanDevice,
self).setUp()
self.mock_ncclient.reset_mock()
self.addCleanup(self._clear_nve_db)
self.results = TestCiscoNexusRestVxlanResults()

View File

@ -29,7 +29,6 @@ redundant.
"""
import mock
from oslo_config import cfg
from networking_cisco.plugins.ml2.drivers.cisco.nexus import (
nexus_db_v2 as nxos_db)
@ -257,9 +256,9 @@ class TestCiscoNexusRestReplay(test_cisco_nexus_replay.TestCiscoNexusReplay):
def setUp(self):
"""Sets up mock ncclient, and switch and credentials dictionaries."""
cfg.CONF.set_override('nexus_driver', 'restapi', 'ml2_cisco')
cfg.CONF.set_override('never_cache_ssh_connection', False, 'ml2_cisco')
super(TestCiscoNexusRestReplay, self).setUp()
# Call Grandfather's setUp(); otherwise parent will set driver to
# 'ncclient' instead of 'restapi'.
super(test_cisco_nexus_replay.TestCiscoNexusReplay, self).setUp()
self.results = TestCiscoNexusRestReplayResults()
def test_replay_unique_ports(self):
@ -899,9 +898,10 @@ class TestCiscoNexusRestBaremetalReplay(
mock.patch.object(nxos_db,
'_get_free_vpcids_on_switches',
new=new_get_free_vpcids_on_switches).start()
cfg.CONF.set_override('nexus_driver', 'restapi', 'ml2_cisco')
cfg.CONF.set_override('never_cache_ssh_connection', False, 'ml2_cisco')
super(TestCiscoNexusRestBaremetalReplay, self).setUp()
# Call Grandfather's setUp(); otherwise parent will set driver to
# 'ncclient' instead of 'restapi'.
super(test_cisco_nexus_replay.TestCiscoNexusBaremetalReplay,
self).setUp()
self.results = TestCiscoNexusRestBaremetalReplayResults()
def test_replay_unique_ethernet_ports(self):