Skip to content

Commit 6083c75

Browse files
authored
Merge pull request #69 from QualiSystems/dev
A preview release of cloudshell-networking-cisco-5.0.24
2 parents e73b8c0 + df3b803 commit 6083c75

File tree

10 files changed

+59
-113
lines changed

10 files changed

+59
-113
lines changed

cloudshell/networking/cisco/autoload/cisco_generic_snmp_autoload.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
class CiscoGenericSNMPAutoload(object):
1515
IF_ENTITY = "ifDescr"
1616
ENTITY_PHYSICAL = "entPhysicalDescr"
17+
SNMP_ERRORS = [r'No\s+Such\s+Object\s+currently\s+exists']
1718

1819
def __init__(self, snmp_handler, shell_name, shell_type, resource_name, logger):
1920
"""Basic init with injected snmp handler and logger
@@ -29,6 +30,7 @@ def __init__(self, snmp_handler, shell_name, shell_type, resource_name, logger):
2930
self.resource_name = resource_name
3031
self.logger = logger
3132
self.elements = {}
33+
self.snmp_handler.set_snmp_errors(self.SNMP_ERRORS)
3234
self.resource = GenericResource(shell_name=shell_name,
3335
shell_type=shell_type,
3436
name=resource_name,
Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,69 @@
1+
from collections import defaultdict
2+
3+
14
class SnmpPortAttrTables(object):
25
def __init__(self, snmp_handler, logger):
36
self._snmp = snmp_handler
47
self._logger = logger
5-
self._lldp_remote_table = dict()
6-
self._lldp_local_table = dict()
7-
self._cdp_table = dict()
8-
self._duplex_table = dict()
9-
self._ip_v4_table = dict()
10-
self._ip_v6_table = dict()
11-
self._port_channel_ports = dict()
8+
self._lldp_remote_table = None
9+
self._lldp_local_table = None
10+
self._cdp_table = None
11+
self._duplex_table = None
12+
self._ip_v4_table = None
13+
self._ip_v6_table = None
14+
self._port_channel_ports = None
1215

1316
@property
1417
def lldp_remote_table(self):
15-
if not self._lldp_remote_table:
16-
self._lldp_remote_table = self._snmp.get_table('LLDP-MIB', 'lldpRemSysName')
18+
if self._lldp_remote_table is None:
19+
self._lldp_remote_table = self._snmp.get_table('LLDP-MIB', 'lldpRemSysName') or defaultdict()
1720
self._logger.info('lldpRemSysName table loaded')
1821
return self._lldp_remote_table
1922

2023
@property
2124
def lldp_local_table(self):
22-
if not self._lldp_remote_table:
23-
lldp_local_table = self._snmp.get_table('LLDP-MIB', 'lldpLocPortDesc')
25+
if self._lldp_local_table is None:
26+
lldp_local_table = self._snmp.get_table('LLDP-MIB', 'lldpLocPortDesc') or defaultdict()
2427
if lldp_local_table:
25-
self._lldp_local_table = dict([(v['lldpLocPortDesc'].lower(), k) for k, v in lldp_local_table.iteritems()])
28+
self._lldp_local_table = dict(
29+
[(v['lldpLocPortDesc'].lower(), k) for k, v in lldp_local_table.iteritems()])
30+
else:
31+
self._lldp_local_table = defaultdict()
2632
self._logger.info('lldpLocPortDesc table loaded')
27-
return self._lldp_remote_table
33+
return self._lldp_local_table
2834

2935
@property
3036
def cdp_table(self):
31-
if not self._cdp_table:
32-
self._cdp_table = self._snmp.get_table('CISCO-CDP-MIB', 'cdpCacheDeviceId')
37+
if self._cdp_table is None:
38+
self._cdp_table = self._snmp.get_table('CISCO-CDP-MIB', 'cdpCacheDeviceId') or defaultdict()
3339
self._logger.info('cdpCacheDeviceId table loaded')
3440
return self._cdp_table
3541

3642
@property
3743
def duplex_table(self):
38-
if not self._duplex_table:
39-
self._duplex_table = self._snmp.get_table('EtherLike-MIB', 'dot3StatsIndex')
44+
if self._duplex_table is None:
45+
self._duplex_table = self._snmp.get_table('EtherLike-MIB', 'dot3StatsIndex') or defaultdict()
4046
self._logger.info('dot3StatsIndex table loaded')
4147
return self._duplex_table
4248

4349
@property
4450
def ip_v4_table(self):
45-
if not self._ip_v4_table:
46-
self._ip_v4_table = self._snmp.get_table('IP-MIB', 'ipAddrTable')
51+
if self._ip_v4_table is None:
52+
self._ip_v4_table = self._snmp.get_table('IP-MIB', 'ipAddrTable') or defaultdict()
4753
self._logger.info('ipAddrTable table loaded')
4854
return self._ip_v4_table
4955

5056
@property
5157
def ip_v6_table(self):
52-
if not self._ip_v6_table:
53-
self._ip_v6_table = self._snmp.get_table('IPV6-MIB', 'ipv6AddrEntry')
58+
if self._ip_v6_table is None:
59+
self._ip_v6_table = self._snmp.get_table('IPV6-MIB', 'ipv6AddrEntry') or defaultdict()
5460
self._logger.info('ipv6AddrEntry table loaded')
5561
return self._ip_v6_table
5662

5763
@property
5864
def port_channel_ports(self):
59-
if not self._port_channel_ports:
60-
self._port_channel_ports = self._snmp.get_table('IEEE8023-LAG-MIB', 'dot3adAggPortAttachedAggID')
65+
if self._port_channel_ports is None:
66+
self._port_channel_ports = self._snmp.get_table('IEEE8023-LAG-MIB',
67+
'dot3adAggPortAttachedAggID') or defaultdict()
6168
self._logger.info('dot3adAggPortAttachedAggID table loaded')
6269
return self._port_channel_ports

cloudshell/networking/cisco/command_actions/add_remove_vlan_actions.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ def set_vlan_to_interface(self, vlan_range, port_mode, port_name, qnq, c_tag,
9292
vlan_command_template.SWITCHPORT_MODE,
9393
action_map=action_map,
9494
error_map=error_map).execute_command(port_mode=port_mode)
95+
if qnq:
96+
CommandTemplateExecutor(self._cli_service,
97+
vlan_command_template.L2_TUNNEL,
98+
action_map=action_map,
99+
error_map=error_map).execute_command()
95100

96101
if 'trunk' not in port_mode:
97102

cloudshell/networking/cisco/command_actions/iface_actions.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from cloudshell.cli.command_template.command_template_executor import CommandTemplateExecutor
77
from cloudshell.networking.cisco.command_templates import iface as iface_command_template
8+
from cloudshell.networking.cisco.command_templates import add_remove_vlan as vlan_command_template
89
from cloudshell.networking.cisco.command_templates import configuration
910

1011

@@ -82,5 +83,8 @@ def clean_interface_switchport_config(self, current_config, action_map=None, err
8283
CommandTemplateExecutor(self._cli_service,
8384
configuration.NO, action_map=action_map,
8485
error_map=error_map).execute_command(command=line_to_remove)
85-
86-
self._logger.debug("Completed cleaning interface switchport configuration")
86+
if "switchport mode dot1q-tunnel" in current_config.lower():
87+
CommandTemplateExecutor(self._cli_service,
88+
vlan_command_template.NO_L2_TUNNEL, action_map=action_map,
89+
error_map=error_map).execute_command()
90+
self._logger.debug("Completed cleaning interface switchport configuration")

cloudshell/networking/cisco/command_templates/add_remove_vlan.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
ACTION_MAP = OrderedDict({"[\[\(][Yy]es/[Nn]o[\)\]]|\[confirm\]": lambda session: session.send_line("yes"),
88
"[\[\(][Yy]/[Nn][\)\]]": lambda session: session.send_line("y")})
99
ERROR_MAP = OrderedDict({"[Ii]nvalid\s*([Ii]nput|[Cc]ommand)|[Cc]ommand rejected":
10-
Exception("SWITCHPORT_MODE", "Failed to switch port mode"),
10+
Exception("SWITCHPORT_MODE", "Failed to switch port mode"),
1111
})
1212

1313
VLAN_SUB_IFACE = CommandTemplate(command="encapsulation dot1q {vlan_id} [, untagged{untagged}] [second-dot1q any{qnq}]")
@@ -23,3 +23,11 @@
2323
SWITCHPORT_MODE = CommandTemplate("switchport [mode {port_mode}]",
2424
action_map=ACTION_MAP,
2525
error_map=ERROR_MAP)
26+
27+
L2_TUNNEL = CommandTemplate("l2protocol-tunnel",
28+
action_map=ACTION_MAP,
29+
error_map=ERROR_MAP)
30+
31+
NO_L2_TUNNEL = CommandTemplate("no l2protocol-tunnel",
32+
action_map=ACTION_MAP,
33+
error_map=ERROR_MAP)

cloudshell/networking/cisco/firmware_data/__init__.py

Lines changed: 0 additions & 2 deletions
This file was deleted.

cloudshell/networking/cisco/firmware_data/cisco_firmware_data.py

Lines changed: 0 additions & 33 deletions
This file was deleted.

cloudshell/networking/cisco/firmware_data/firmware_data.py

Lines changed: 0 additions & 45 deletions
This file was deleted.

cloudshell/networking/cisco/flows/cisco_autoload_flow.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
class CiscoSnmpAutoloadFlow(AutoloadFlow):
99
def execute_flow(self, supported_os, shell_name, shell_type, resource_name):
10-
with self._snmp_handler.get_snmp_service() as snpm_service:
11-
cisco_snmp_autoload = CiscoGenericSNMPAutoload(snpm_service,
10+
with self._snmp_handler.get_snmp_service() as snmp_service:
11+
cisco_snmp_autoload = CiscoGenericSNMPAutoload(snmp_service,
1212
shell_name,
1313
shell_type,
1414
resource_name,

dev_requirements.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
-e git+https://github.com/QualiSystems/cloudshell-shell-core.git@dev#egg=cloudshell-shell-core
2-
-e git+https://github.com/QualiSystems/cloudshell-cli.git@dev#egg=cloudshell-cli
3-
-e git+https://github.com/QualiSystems/cloudshell-snmp.git@dev#egg=cloudshell-snmp
4-
-e git+https://github.com/QualiSystems/cloudshell-networking.git@dev#egg=cloudshell-networking
5-
-e git+https://github.com/QualiSystems/cloudshell-networking-devices.git@dev#egg=cloudshell-networking-devices
1+
git+https://github.com/QualiSystems/cloudshell-shell-core.git@dev#egg=cloudshell-shell-core
2+
git+https://github.com/QualiSystems/cloudshell-cli.git@dev#egg=cloudshell-cli
3+
git+https://github.com/QualiSystems/cloudshell-snmp.git@dev#egg=cloudshell-snmp
4+
git+https://github.com/QualiSystems/cloudshell-networking.git@dev#egg=cloudshell-networking
5+
git+https://github.com/QualiSystems/cloudshell-networking-devices.git@dev#egg=cloudshell-networking-devices

0 commit comments

Comments
 (0)