cloudshell-networking-cisco 2.0.160__tar.gz → 7.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. cloudshell_networking_cisco-7.1.0/MANIFEST.in +5 -0
  2. cloudshell_networking_cisco-7.1.0/PKG-INFO +29 -0
  3. cloudshell_networking_cisco-7.1.0/README.md +13 -0
  4. {cloudshell-networking-cisco-2.0.160/cloudshell/networking/cisco/firmware_data → cloudshell_networking_cisco-7.1.0/cloudshell}/__init__.py +1 -0
  5. {cloudshell-networking-cisco-2.0.160/cloudshell/networking/cisco/autoload → cloudshell_networking_cisco-7.1.0/cloudshell/networking}/__init__.py +1 -1
  6. {cloudshell-networking-cisco-2.0.160/cloudshell → cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco}/__init__.py +1 -1
  7. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/autoload/__init__.py +3 -0
  8. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/autoload/cisco_generic_snmp_autoload.py +38 -0
  9. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/autoload/cisco_snmp_if_port.py +19 -0
  10. cloudshell-networking-cisco-2.0.160/third_party_requirements.txt → cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/autoload/constants/__init__.py +0 -0
  11. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/autoload/constants/snmp_constants.py +6 -0
  12. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/autoload/snmp_tables/__init__.py +0 -0
  13. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/autoload/snmp_tables/cisco_duplex_table.py +31 -0
  14. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/autoload/snmp_tables/cisco_ports_auto_neg.py +28 -0
  15. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/autoload/snmp_tables/cisco_ports_duplex.py +28 -0
  16. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/autoload/snmp_tables/cisco_ports_neighbours.py +54 -0
  17. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/autoload/snmp_tables/cisco_snmp_port_table.py +25 -0
  18. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/autoload/table_services/__init__.py +0 -0
  19. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/autoload/table_services/cisco_ports_table.py +16 -0
  20. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/autoload/table_services/cisco_sys_info_table.py +53 -0
  21. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/cisco_constants.py +3 -0
  22. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/cli/__init__.py +3 -0
  23. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/cli/cisco_cli_handler.py +89 -0
  24. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/cli/cisco_command_modes.py +150 -0
  25. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/command_actions/__init__.py +3 -0
  26. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/command_actions/add_remove_vlan_actions.py +297 -0
  27. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/command_actions/enable_disable_snmp_actions.py +280 -0
  28. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/command_actions/iface_actions.py +164 -0
  29. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/command_actions/system_actions.py +359 -0
  30. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/command_templates/__init__.py +3 -0
  31. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/command_templates/add_remove_vlan.py +55 -0
  32. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/command_templates/configuration.py +159 -0
  33. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/command_templates/enable_disable_snmp.py +58 -0
  34. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/command_templates/firmware.py +11 -0
  35. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/command_templates/iface.py +42 -0
  36. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/errors/__init__.py +0 -0
  37. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/errors/cisco_errors.py +22 -0
  38. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/flows/__init__.py +3 -0
  39. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/flows/cisco_autoload_flow.py +63 -0
  40. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/flows/cisco_configuration_flow.py +107 -0
  41. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/flows/cisco_connectivity_flow.py +229 -0
  42. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/flows/cisco_disable_snmp_flow.py +85 -0
  43. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/flows/cisco_enable_snmp_flow.py +113 -0
  44. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/flows/cisco_load_firmware_flow.py +158 -0
  45. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/flows/cisco_run_command_flow.py +5 -0
  46. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/flows/cisco_state_flow.py +5 -0
  47. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/mibs/CISCO-CDP-MIB.json +1398 -0
  48. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/mibs/CISCO-ENTITY-VENDORTYPE-OID-MIB.json +49233 -0
  49. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/mibs/CISCO-PRODUCTS-MIB.json +13479 -0
  50. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/mibs/CISCO-SMI.json +407 -0
  51. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/mibs/CISCO-STACK-MIB.json +16780 -0
  52. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/mibs/CISCO-TC.json +1212 -0
  53. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/mibs/CISCO-VTP-MIB.json +3916 -0
  54. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/mibs/FDDI-SMT73-MIB.json +2236 -0
  55. {cloudshell-networking-cisco-2.0.160/cloudshell/networking/cisco → cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/mibs}/__init__.py +4 -3
  56. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/mibs/device_names_map.csv +398 -0
  57. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/sessions/__init__.py +3 -0
  58. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/snmp/__init__.py +3 -0
  59. cloudshell_networking_cisco-7.1.0/cloudshell/networking/cisco/snmp/cisco_snmp_handler.py +38 -0
  60. cloudshell_networking_cisco-7.1.0/cloudshell_networking_cisco.egg-info/PKG-INFO +29 -0
  61. cloudshell_networking_cisco-7.1.0/cloudshell_networking_cisco.egg-info/SOURCES.txt +96 -0
  62. {cloudshell-networking-cisco-2.0.160 → cloudshell_networking_cisco-7.1.0}/cloudshell_networking_cisco.egg-info/dependency_links.txt +0 -0
  63. cloudshell_networking_cisco-7.1.0/cloudshell_networking_cisco.egg-info/requires.txt +6 -0
  64. {cloudshell-networking-cisco-2.0.160 → cloudshell_networking_cisco-7.1.0}/cloudshell_networking_cisco.egg-info/top_level.txt +1 -0
  65. cloudshell_networking_cisco-7.1.0/dev_requirements.txt +5 -0
  66. cloudshell_networking_cisco-7.1.0/requirements.txt +6 -0
  67. {cloudshell-networking-cisco-2.0.160 → cloudshell_networking_cisco-7.1.0}/setup.cfg +0 -1
  68. cloudshell_networking_cisco-7.1.0/setup.py +34 -0
  69. cloudshell_networking_cisco-7.1.0/test_requirements.txt +3 -0
  70. cloudshell_networking_cisco-7.1.0/tests/__init__.py +3 -0
  71. cloudshell_networking_cisco-7.1.0/tests/networking/__init__.py +3 -0
  72. cloudshell_networking_cisco-7.1.0/tests/networking/cisco/__init__.py +3 -0
  73. cloudshell_networking_cisco-7.1.0/tests/networking/cisco/autoload/__init__.py +3 -0
  74. cloudshell_networking_cisco-7.1.0/tests/networking/cisco/autoload/test_cisco_if_port.py +113 -0
  75. cloudshell_networking_cisco-7.1.0/tests/networking/cisco/autoload/test_cisco_snmp_autoload.py +40 -0
  76. cloudshell_networking_cisco-7.1.0/tests/networking/cisco/cli/__init__.py +3 -0
  77. cloudshell_networking_cisco-7.1.0/tests/networking/cisco/cli/tests_cisco_cli_handler.py +151 -0
  78. cloudshell_networking_cisco-7.1.0/tests/networking/cisco/command_actions/__init__.py +3 -0
  79. cloudshell_networking_cisco-7.1.0/tests/networking/cisco/command_actions/system_actions/__init__.py +3 -0
  80. cloudshell_networking_cisco-7.1.0/tests/networking/cisco/command_actions/system_actions/system_actions_output.py +841 -0
  81. cloudshell_networking_cisco-7.1.0/tests/networking/cisco/command_actions/system_actions/test_system_actions_copy.py +84 -0
  82. cloudshell_networking_cisco-7.1.0/tests/networking/cisco/command_actions/system_actions/test_system_actions_prepare_action_map.py +219 -0
  83. cloudshell_networking_cisco-7.1.0/tests/networking/cisco/command_actions/system_actions/test_system_actions_restore_override.py +47 -0
  84. cloudshell_networking_cisco-7.1.0/tests/networking/cisco/command_actions/test_enable_disable_snmp_actions.py +78 -0
  85. cloudshell_networking_cisco-7.1.0/tests/networking/cisco/command_actions/test_iface_actions.py +60 -0
  86. cloudshell_networking_cisco-7.1.0/tests/networking/cisco/command_actions/test_vlan_actions.py +454 -0
  87. cloudshell_networking_cisco-7.1.0/tests/networking/cisco/command_templates/__init__.py +1 -0
  88. cloudshell_networking_cisco-7.1.0/tests/networking/cisco/command_templates/test_configuration_templates.py +89 -0
  89. cloudshell_networking_cisco-7.1.0/tests/networking/cisco/flows/__init__.py +3 -0
  90. cloudshell_networking_cisco-7.1.0/tests/networking/cisco/flows/test_connectivity_flow.py +260 -0
  91. cloudshell_networking_cisco-7.1.0/tests/networking/cisco/flows/test_disable_snmp_flow.py +112 -0
  92. cloudshell_networking_cisco-7.1.0/tests/networking/cisco/flows/test_enable_snmp_flow.py +192 -0
  93. cloudshell_networking_cisco-7.1.0/tests/networking/cisco/flows/test_firmware_flow.py +45 -0
  94. cloudshell_networking_cisco-7.1.0/tests/networking/cisco/flows/test_restore_configuration_flow.py +72 -0
  95. cloudshell_networking_cisco-7.1.0/tests/networking/cisco/flows/test_save_configuration_flow.py +70 -0
  96. cloudshell_networking_cisco-7.1.0/tests/networking/cisco/runners/__init__.py +3 -0
  97. cloudshell_networking_cisco-7.1.0/tox.ini +43 -0
  98. cloudshell_networking_cisco-7.1.0/version.txt +1 -0
  99. cloudshell-networking-cisco-2.0.160/MANIFEST.in +0 -2
  100. cloudshell-networking-cisco-2.0.160/PKG-INFO +0 -10
  101. cloudshell-networking-cisco-2.0.160/README.txt +0 -1
  102. cloudshell-networking-cisco-2.0.160/cloudshell/networking/__init__.py +0 -2
  103. cloudshell-networking-cisco-2.0.160/cloudshell/networking/cisco/autoload/cisco_generic_snmp_autoload.py +0 -647
  104. cloudshell-networking-cisco-2.0.160/cloudshell/networking/cisco/cisco_configuration_operations.py +0 -413
  105. cloudshell-networking-cisco-2.0.160/cloudshell/networking/cisco/cisco_connectivity_operations.py +0 -263
  106. cloudshell-networking-cisco-2.0.160/cloudshell/networking/cisco/cisco_send_command_operations.py +0 -111
  107. cloudshell-networking-cisco-2.0.160/cloudshell/networking/cisco/command_templates/__init__.py +0 -3
  108. cloudshell-networking-cisco-2.0.160/cloudshell/networking/cisco/command_templates/cisco_interface.py +0 -5
  109. cloudshell-networking-cisco-2.0.160/cloudshell/networking/cisco/command_templates/ethernet.py +0 -34
  110. cloudshell-networking-cisco-2.0.160/cloudshell/networking/cisco/command_templates/interfaces_configurator.py +0 -58
  111. cloudshell-networking-cisco-2.0.160/cloudshell/networking/cisco/command_templates/mgmt.py +0 -24
  112. cloudshell-networking-cisco-2.0.160/cloudshell/networking/cisco/command_templates/port_channel.py +0 -38
  113. cloudshell-networking-cisco-2.0.160/cloudshell/networking/cisco/command_templates/vlan.py +0 -23
  114. cloudshell-networking-cisco-2.0.160/cloudshell/networking/cisco/firmware_data/cisco_firmware_data.py +0 -33
  115. cloudshell-networking-cisco-2.0.160/cloudshell/networking/cisco/firmware_data/firmware_data.py +0 -45
  116. cloudshell-networking-cisco-2.0.160/cloudshell/networking/cisco/mibs/CISCO-CDP-MIB.py +0 -180
  117. cloudshell-networking-cisco-2.0.160/cloudshell/networking/cisco/mibs/CISCO-ENTITY-VENDORTYPE-OID-MIB.py +0 -7412
  118. cloudshell-networking-cisco-2.0.160/cloudshell/networking/cisco/mibs/CISCO-PRODUCTS-MIB.py +0 -2034
  119. cloudshell-networking-cisco-2.0.160/cloudshell/networking/cisco/mibs/CISCO-SMI.py +0 -131
  120. cloudshell-networking-cisco-2.0.160/cloudshell/networking/cisco/mibs/CISCO-STACK-MIB.py +0 -1468
  121. cloudshell-networking-cisco-2.0.160/cloudshell/networking/cisco/mibs/CISCO-TC.py +0 -171
  122. cloudshell-networking-cisco-2.0.160/cloudshell/networking/cisco/mibs/CISCO-VTP-MIB.py +0 -549
  123. cloudshell-networking-cisco-2.0.160/cloudshell/networking/cisco/mibs/__init__.py +0 -3
  124. cloudshell-networking-cisco-2.0.160/cloudshell/networking/cisco/resource_drivers_map.py +0 -12
  125. cloudshell-networking-cisco-2.0.160/cloudshell/tests/__init__.py +0 -2
  126. cloudshell-networking-cisco-2.0.160/cloudshell/tests/cloudshell_networking_cisco_tests.py +0 -15
  127. cloudshell-networking-cisco-2.0.160/cloudshell/tests/networking/__init__.py +0 -2
  128. cloudshell-networking-cisco-2.0.160/cloudshell/tests/networking/cisco/__init__.py +0 -2
  129. cloudshell-networking-cisco-2.0.160/cloudshell/tests/networking/cisco/cisco_handler_base/__init__.py +0 -2
  130. cloudshell-networking-cisco-2.0.160/cloudshell/tests/networking/cisco/cisco_handler_base/connectivity_methods/__init__.py +0 -2
  131. cloudshell-networking-cisco-2.0.160/cloudshell/tests/networking/cisco/cisco_handler_base/connectivity_methods/test_apply_connectivity_changes.py +0 -71
  132. cloudshell-networking-cisco-2.0.160/cloudshell/tests/networking/cisco/cisco_handler_base/save_restore_methods/__init__.py +0 -2
  133. cloudshell-networking-cisco-2.0.160/cloudshell/tests/networking/cisco/cisco_handler_base/save_restore_methods/test_backup_configuration_fixed_bugs.py +0 -135
  134. cloudshell-networking-cisco-2.0.160/cloudshell/tests/networking/cisco/cisco_handler_base/save_restore_methods/test_backup_configuration_parameter_validation.py +0 -53
  135. cloudshell-networking-cisco-2.0.160/cloudshell/tests/networking/cisco/cisco_handler_base/save_restore_methods/test_restore_configuration_fixed_bugs.py +0 -117
  136. cloudshell-networking-cisco-2.0.160/cloudshell/tests/networking/cisco/config_for_tests.py +0 -45
  137. cloudshell-networking-cisco-2.0.160/cloudshell_networking_cisco.egg-info/PKG-INFO +0 -10
  138. cloudshell-networking-cisco-2.0.160/cloudshell_networking_cisco.egg-info/SOURCES.txt +0 -52
  139. cloudshell-networking-cisco-2.0.160/cloudshell_networking_cisco.egg-info/requires.txt +0 -1
  140. cloudshell-networking-cisco-2.0.160/requirements.txt +0 -1
  141. cloudshell-networking-cisco-2.0.160/setup.py +0 -25
  142. cloudshell-networking-cisco-2.0.160/test_requirements.txt +0 -3
  143. cloudshell-networking-cisco-2.0.160/version.txt +0 -1
@@ -0,0 +1,5 @@
1
+ include *.txt
2
+ global-include *.csv
3
+ global-include *.ini
4
+ global-include *.json
5
+ prune .tox
@@ -0,0 +1,29 @@
1
+ Metadata-Version: 2.4
2
+ Name: cloudshell-networking-cisco
3
+ Version: 7.1.0
4
+ Summary: QualiSystems networking cisco specific package
5
+ Home-page: http://www.qualisystems.com/
6
+ Author: QualiSystems
7
+ Author-email: info@qualisystems.com
8
+ Classifier: Programming Language :: Python :: 3.9
9
+ Classifier: Programming Language :: Python :: 3.10
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Requires-Python: >=3.9
14
+ Requires-Dist: cloudshell-shell-flows<3.0,>=2.0.3
15
+ Requires-Dist: cloudshell-shell-connectivity-flow<4.0,>=3.1.3
16
+ Requires-Dist: cloudshell-snmp<7.0,>=6.0
17
+ Requires-Dist: cloudshell-snmp-autoload<4.0,>=3.0
18
+ Requires-Dist: cloudshell-cli~=5.0
19
+ Requires-Dist: attrs<23,>=21
20
+ Dynamic: author
21
+ Dynamic: author-email
22
+ Dynamic: classifier
23
+ Dynamic: description
24
+ Dynamic: home-page
25
+ Dynamic: requires-dist
26
+ Dynamic: requires-python
27
+ Dynamic: summary
28
+
29
+ QualiSystems networking cisco specific package
@@ -0,0 +1,13 @@
1
+ # cloudshell-networking-cisco
2
+ [![Build status](https://github.com/QualiSystems/cloudshell-networking-cisco/workflows/CI/badge.svg?branch=master)](https://github.com/QualiSystems/cloudshell-networking-cisco/actions?query=branch%3Amaster)
3
+ [![codecov](https://codecov.io/gh/QualiSystems/cloudshell-networking-cisco/branch/master/graph/badge.svg)](https://codecov.io/gh/QualiSystems/cloudshell-networking-cisco)
4
+ [![PyPI version](https://badge.fury.io/py/cloudshell-networking-cisco.svg)](https://badge.fury.io/py/cloudshell-networking-cisco)
5
+ [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black)
6
+
7
+ <p align="center">
8
+ <img src="https://github.com/QualiSystems/devguide_source/raw/master/logo.png"></img>
9
+ </p>
10
+
11
+ # CloudShell Networking Cisco
12
+
13
+ We use tox and pre-commit for testing. [Services description](https://github.com/QualiSystems/cloudshell-package-repo-template#description-of-services)
@@ -1,2 +1,3 @@
1
1
  from pkgutil import extend_path
2
+
2
3
  __path__ = extend_path(__path__, __name__)
@@ -1,3 +1,3 @@
1
- __author__ = 'coye'
2
1
  from pkgutil import extend_path
2
+
3
3
  __path__ = extend_path(__path__, __name__)
@@ -1,3 +1,3 @@
1
- __author__ = 'coye'
2
1
  from pkgutil import extend_path
2
+
3
3
  __path__ = extend_path(__path__, __name__)
@@ -0,0 +1,3 @@
1
+ from pkgutil import extend_path
2
+
3
+ __path__ = extend_path(__path__, __name__)
@@ -0,0 +1,38 @@
1
+ from functools import lru_cache
2
+
3
+ from cloudshell.snmp.autoload.generic_snmp_autoload import GenericSNMPAutoload
4
+
5
+ from cloudshell.networking.cisco.autoload.snmp_tables.cisco_snmp_port_table import (
6
+ CiscoSnmpPortsTable,
7
+ )
8
+ from cloudshell.networking.cisco.autoload.table_services.cisco_ports_table import (
9
+ CiscoPortsTable,
10
+ )
11
+ from cloudshell.networking.cisco.autoload.table_services.cisco_sys_info_table import (
12
+ CiscoSnmpSystemInfo,
13
+ )
14
+
15
+
16
+ class CiscoGenericSNMPAutoload(GenericSNMPAutoload):
17
+ @property
18
+ @lru_cache()
19
+ def system_info_service(self) -> CiscoSnmpSystemInfo:
20
+ """Get system info service."""
21
+ return CiscoSnmpSystemInfo(self.snmp_handler, self.logger)
22
+
23
+ @property
24
+ @lru_cache()
25
+ def port_snmp_table(self) -> CiscoSnmpPortsTable:
26
+ """Get port snmp table."""
27
+ return CiscoSnmpPortsTable(snmp_handler=self.snmp_handler, logger=self.logger)
28
+
29
+ @property
30
+ def port_table_service(self) -> CiscoPortsTable:
31
+ """Get port table service."""
32
+ if not self._port_table_service:
33
+ self._port_table_service = CiscoPortsTable(
34
+ resource_model=self._resource_model,
35
+ ports_snmp_table=self.port_snmp_table,
36
+ logger=self.logger,
37
+ )
38
+ return self._port_table_service
@@ -0,0 +1,19 @@
1
+ import re
2
+
3
+ from cloudshell.snmp.autoload.snmp.entities.snmp_if_entity import SnmpIfEntity
4
+
5
+
6
+ class CiscoSnmpIfPort(SnmpIfEntity):
7
+ """Cisco SNMP If Port."""
8
+
9
+ PORT_NAME_MATCH = re.compile(
10
+ r"^\S*(Ethernet|GigE|Serial|Sonet|Port-channel|Bundle-Ether)",
11
+ re.IGNORECASE,
12
+ )
13
+
14
+ @property
15
+ def port_name(self):
16
+ name = self.if_descr_name
17
+ if not self.PORT_NAME_MATCH.search(name):
18
+ name = self.if_name
19
+ return name.replace("/", "-").replace(":", "_")
@@ -0,0 +1,6 @@
1
+ from cloudshell.snmp.core.domain.snmp_oid import SnmpMibObject
2
+
3
+ CISCO_CDP_DEVICE_ID = SnmpMibObject("CISCO-CDP-MIB", "cdpCacheDeviceId")
4
+ CISCO_CDP_DEVICE_PORT = SnmpMibObject("CISCO-CDP-MIB", "cdpCacheDevicePort")
5
+ CISCO_STACK_DUPLEX = SnmpMibObject("CISCO-STACK-MIB", "portDuplex")
6
+ CISCO_STACK_DUPLEX_ID = SnmpMibObject("CISCO-STACK-MIB", "portIfIndex")
@@ -0,0 +1,31 @@
1
+ from functools import lru_cache
2
+
3
+ from cloudshell.networking.cisco.autoload.constants.snmp_constants import (
4
+ CISCO_STACK_DUPLEX,
5
+ CISCO_STACK_DUPLEX_ID,
6
+ )
7
+
8
+
9
+ class CiscoSnmpStackTable:
10
+ def __init__(self, snmp_handler, logger):
11
+ self._snmp_handler = snmp_handler
12
+ self._logger = logger
13
+ self._data = None
14
+
15
+ @property
16
+ @lru_cache()
17
+ def get_table(self):
18
+ if self._data is None:
19
+ data = self._snmp_handler.get_multiple_columns(
20
+ [CISCO_STACK_DUPLEX_ID, CISCO_STACK_DUPLEX]
21
+ )
22
+ self._data = {
23
+ str(data.get(CISCO_STACK_DUPLEX_ID.object_name, "")): str(
24
+ data.get(CISCO_STACK_DUPLEX.object_name, "")
25
+ ).replace("'", "")
26
+ for key, data in data.items()
27
+ }
28
+ return self._data
29
+
30
+ def get(self, index):
31
+ return self.get_table.get(index, "")
@@ -0,0 +1,28 @@
1
+ from logging import Logger
2
+
3
+ from cloudshell.snmp.autoload.snmp.tables.port_attrs_snmp_tables.snmp_ports_auto_negotioation import ( # noqa: E501
4
+ PortAutoNegotiation,
5
+ )
6
+ from cloudshell.snmp.core.snmp_service import SnmpService
7
+
8
+ from cloudshell.networking.cisco.autoload.snmp_tables.cisco_duplex_table import (
9
+ CiscoSnmpStackTable,
10
+ )
11
+
12
+
13
+ class CiscoPortAutoNegotiation(PortAutoNegotiation):
14
+ def __init__(
15
+ self,
16
+ snmp_service: SnmpService,
17
+ snmp_duplex: CiscoSnmpStackTable,
18
+ logger: Logger,
19
+ ):
20
+ super().__init__(snmp_service, logger)
21
+ self._snmp_duplex = snmp_duplex
22
+
23
+ def get_value_by_index(self, index):
24
+ response = super().get_value_by_index(index)
25
+ auto_neg_data = self._snmp_duplex.get(index)
26
+ if auto_neg_data in ["auto", "disagree"]:
27
+ response = "True"
28
+ return response
@@ -0,0 +1,28 @@
1
+ from logging import Logger
2
+
3
+ from cloudshell.snmp.autoload.snmp.tables.port_attrs_snmp_tables.snmp_ports_duplex_table import ( # noqa: E501
4
+ PortDuplex,
5
+ )
6
+ from cloudshell.snmp.core.snmp_service import SnmpService
7
+
8
+ from cloudshell.networking.cisco.autoload.snmp_tables.cisco_duplex_table import (
9
+ CiscoSnmpStackTable,
10
+ )
11
+
12
+
13
+ class CiscoPortDuplex(PortDuplex):
14
+ def __init__(
15
+ self,
16
+ snmp_service: SnmpService,
17
+ snmp_duplex: CiscoSnmpStackTable,
18
+ logger: Logger,
19
+ ):
20
+ super().__init__(snmp_service, logger)
21
+ self._snmp_duplex = snmp_duplex
22
+
23
+ def get_duplex_by_port_index(self, index):
24
+ response = super().get_duplex_by_port_index(index)
25
+ duplex = self._snmp_duplex.get(index)
26
+ if duplex in ["full", "half"]:
27
+ response = duplex.capitalize()
28
+ return response
@@ -0,0 +1,54 @@
1
+ from functools import lru_cache
2
+ from logging import Logger
3
+
4
+ from cloudshell.snmp.autoload.snmp.tables.port_attrs_snmp_tables.snmp_ports_neighbors_table import ( # noqa: E501
5
+ PortNeighbours,
6
+ )
7
+ from cloudshell.snmp.core.snmp_service import SnmpService
8
+
9
+ from cloudshell.networking.cisco.autoload.constants.snmp_constants import (
10
+ CISCO_CDP_DEVICE_ID,
11
+ CISCO_CDP_DEVICE_PORT,
12
+ )
13
+
14
+
15
+ class CiscoPortNeighbours(PortNeighbours):
16
+ def __init__(self, snmp_service: SnmpService, logger: Logger):
17
+ super().__init__(snmp_service, logger)
18
+ self._cisco_cdp_table = {}
19
+
20
+ @property
21
+ @lru_cache()
22
+ def load_cisco_cdp_table(self):
23
+ self._cisco_cdp_table = self._snmp.get_multiple_columns(
24
+ [CISCO_CDP_DEVICE_ID, CISCO_CDP_DEVICE_PORT]
25
+ )
26
+ return self._cisco_cdp_table
27
+
28
+ def set_port_attributes(self, port_object, port):
29
+ port_object.adjacent = self._get_adjacent(
30
+ port.if_index
31
+ ) or super().get_adjacent_by_port(port=port, port_object=port_object)
32
+
33
+ def _get_adjacent(self, if_index):
34
+ """Get connected device interface and device name to the specified port id.
35
+
36
+ Using cdp or lldp protocols
37
+ :return: device's name and port connected to port id
38
+ :rtype string
39
+ """
40
+ key = next(
41
+ (k for k in self.load_cisco_cdp_table if k.startswith(f"{if_index}.")), None
42
+ )
43
+ if key:
44
+ remote_host = self.load_cisco_cdp_table.get(key).get(
45
+ CISCO_CDP_DEVICE_ID.object_name
46
+ )
47
+ remote_port = self.load_cisco_cdp_table.get(key).get(
48
+ CISCO_CDP_DEVICE_PORT.object_name
49
+ )
50
+ if remote_host and remote_port:
51
+ result = self.ADJACENT_TEMPLATE.format(
52
+ remote_host=remote_host, remote_port=remote_port
53
+ )
54
+ return result
@@ -0,0 +1,25 @@
1
+ from cloudshell.snmp.autoload.snmp.tables.snmp_ports_table import SnmpPortsTable
2
+
3
+ from cloudshell.networking.cisco.autoload.snmp_tables.cisco_duplex_table import (
4
+ CiscoSnmpStackTable,
5
+ )
6
+ from cloudshell.networking.cisco.autoload.snmp_tables.cisco_ports_auto_neg import (
7
+ CiscoPortAutoNegotiation,
8
+ )
9
+ from cloudshell.networking.cisco.autoload.snmp_tables.cisco_ports_duplex import (
10
+ CiscoPortDuplex,
11
+ )
12
+ from cloudshell.networking.cisco.autoload.snmp_tables.cisco_ports_neighbours import (
13
+ CiscoPortNeighbours,
14
+ )
15
+
16
+
17
+ class CiscoSnmpPortsTable(SnmpPortsTable):
18
+ def __init__(self, snmp_handler, logger):
19
+ super().__init__(snmp_handler, logger)
20
+ self._snmp_duplex = CiscoSnmpStackTable(snmp_handler, logger)
21
+ self._port_auto_neg = CiscoPortAutoNegotiation(
22
+ snmp_handler, self._snmp_duplex, logger
23
+ )
24
+ self._port_duplex = CiscoPortDuplex(snmp_handler, self._snmp_duplex, logger)
25
+ self._port_neighbors = CiscoPortNeighbours(snmp_handler, logger)
@@ -0,0 +1,16 @@
1
+ from logging import Logger
2
+
3
+ from cloudshell.snmp.autoload.services.port_table import PortsTable
4
+
5
+ from cloudshell.networking.cisco.autoload.cisco_snmp_if_port import CiscoSnmpIfPort
6
+ from cloudshell.networking.cisco.autoload.snmp_tables.cisco_snmp_port_table import (
7
+ CiscoSnmpPortsTable,
8
+ )
9
+
10
+
11
+ class CiscoPortsTable(PortsTable):
12
+ def __init__(
13
+ self, resource_model, ports_snmp_table: CiscoSnmpPortsTable, logger: Logger
14
+ ):
15
+ super().__init__(resource_model, ports_snmp_table, logger)
16
+ self._if_entity = CiscoSnmpIfPort
@@ -0,0 +1,53 @@
1
+ import re
2
+
3
+ from cloudshell.shell.flows.autoload.autoload_utils import get_device_name
4
+ from cloudshell.snmp.autoload.services.system_info_table import SnmpSystemInfo
5
+
6
+
7
+ class CiscoSnmpSystemInfo(SnmpSystemInfo):
8
+ def _get_device_model(self):
9
+ """Get device model from the SNMPv2 mib.
10
+
11
+ :return: device model
12
+ :rtype: str
13
+ """
14
+ result = super()._get_device_model()
15
+ sys_descr = str(self._snmp_v2_obj.get_system_description())
16
+ match_name = re.search(r"\bvios(_l2)*\b", sys_descr, re.IGNORECASE)
17
+ if match_name:
18
+ result = match_name.group().upper().replace("_", "-")
19
+ result = re.sub("cevchassis", "", result, flags=re.IGNORECASE)
20
+ return result.capitalize()
21
+
22
+ def fill_attributes(self, resource):
23
+ """Get root element attributes.
24
+
25
+ :type resource: cloudshell.shell_standards.autoload_generic_models.GenericResourceModel # noqa: E501
26
+ """
27
+ self._logger.debug("Building Root started")
28
+
29
+ resource.contact_name = self._snmp_v2_obj.get_system_contact()
30
+ resource.system_name = self._snmp_v2_obj.get_system_name()
31
+ resource.location = self._snmp_v2_obj.get_system_location()
32
+ resource.os_version = self._get_device_os_version()
33
+ vendor = self._get_vendor()
34
+ resource.vendor = vendor
35
+
36
+ raw_model = self._get_device_model()
37
+ model = re.sub(rf"^{vendor}", "", raw_model, flags=re.IGNORECASE)
38
+ resource.model = model.capitalize()
39
+ resource.model_name = model.capitalize()
40
+ resource.model_name = self._get_model_name(raw_model, vendor)
41
+
42
+ self._logger.info("Building Root completed")
43
+
44
+ def _get_model_name(self, model, vendor=None):
45
+ result = model
46
+ if self._device_model_map_path:
47
+ result = (
48
+ get_device_name(file_name=self._device_model_map_path, sys_obj_id=model)
49
+ or model
50
+ )
51
+ if result == model and vendor and model.lower().startswith(vendor.lower()):
52
+ result = f"{vendor.capitalize()} {model[len(vendor):].capitalize()}"
53
+ return result
@@ -0,0 +1,3 @@
1
+ DEFAULT_FILE_SYSTEM = "flash:/"
2
+
3
+ DEFAULT_SESSION_POOL_TIMEOUT = 120
@@ -0,0 +1,3 @@
1
+ from pkgutil import extend_path
2
+
3
+ __path__ = extend_path(__path__, __name__)
@@ -0,0 +1,89 @@
1
+ #!/usr/bin/python
2
+ from __future__ import annotations
3
+
4
+ from typing import ClassVar
5
+
6
+ from attrs import define, field
7
+
8
+ from cloudshell.cli.configurator import AbstractModeConfigurator
9
+ from cloudshell.cli.factory.session_factory import (
10
+ ConsoleSessionFactory,
11
+ GenericSessionFactory,
12
+ SessionFactory,
13
+ )
14
+ from cloudshell.cli.service.cli import CLI
15
+ from cloudshell.cli.service.cli_service_impl import CliServiceImpl
16
+ from cloudshell.cli.service.command_mode_helper import CommandModeHelper
17
+ from cloudshell.cli.service.session_pool_manager import SessionPoolManager
18
+ from cloudshell.cli.session.console_ssh import ConsoleSSHSession
19
+ from cloudshell.cli.session.console_telnet import ConsoleTelnetSession
20
+ from cloudshell.cli.session.ssh_session import SSHSession
21
+ from cloudshell.cli.session.telnet_session import TelnetSession
22
+ from cloudshell.cli.types import T_COMMAND_MODE_RELATIONS
23
+
24
+ from cloudshell.networking.cisco.cisco_constants import DEFAULT_SESSION_POOL_TIMEOUT
25
+ from cloudshell.networking.cisco.cli.cisco_command_modes import (
26
+ ConfigCommandMode,
27
+ DefaultCommandMode,
28
+ EnableCommandMode,
29
+ )
30
+
31
+
32
+ class CiscoCli:
33
+ def __init__(self, resource_config, pool_timeout=DEFAULT_SESSION_POOL_TIMEOUT):
34
+ session_pool_size = int(resource_config.sessions_concurrency_limit)
35
+ session_pool = SessionPoolManager(
36
+ max_pool_size=session_pool_size, pool_timeout=pool_timeout
37
+ )
38
+ self.cli = CLI(session_pool=session_pool)
39
+
40
+ def get_cli_handler(self, resource_config, logger):
41
+ return CiscoCliHandler.from_config(resource_config, logger, self.cli)
42
+
43
+
44
+ @define
45
+ class CiscoCliHandler(AbstractModeConfigurator):
46
+ REGISTERED_SESSIONS: ClassVar[tuple[SessionFactory]] = (
47
+ GenericSessionFactory(SSHSession),
48
+ GenericSessionFactory(TelnetSession),
49
+ ConsoleSessionFactory(ConsoleSSHSession),
50
+ ConsoleSessionFactory(
51
+ ConsoleTelnetSession, session_kwargs={"start_with_new_line": False}
52
+ ),
53
+ ConsoleSessionFactory(
54
+ ConsoleTelnetSession, session_kwargs={"start_with_new_line": True}
55
+ ),
56
+ )
57
+ modes: T_COMMAND_MODE_RELATIONS = field(init=False)
58
+
59
+ def __attrs_post_init__(self):
60
+ super().__attrs_post_init__()
61
+ self.modes = CommandModeHelper.create_command_mode(self._auth.enable_password)
62
+
63
+ @property
64
+ def default_mode(self):
65
+ return self.modes[DefaultCommandMode]
66
+
67
+ @property
68
+ def enable_mode(self):
69
+ return self.modes[EnableCommandMode]
70
+
71
+ @property
72
+ def config_mode(self):
73
+ return self.modes[ConfigCommandMode]
74
+
75
+ def _on_session_start(self, session, logger):
76
+ """Send default commands to configure/clear session outputs.
77
+
78
+ :return:
79
+ """
80
+ cli_service = CliServiceImpl(
81
+ session=session, requested_command_mode=self.enable_mode, logger=logger
82
+ )
83
+ cli_service.send_command("terminal length 0", EnableCommandMode.PROMPT)
84
+ cli_service.send_command("terminal width 300", EnableCommandMode.PROMPT)
85
+ cli_service.send_command(
86
+ "terminal no exec prompt timestamp", EnableCommandMode.PROMPT
87
+ )
88
+ with cli_service.enter_mode(self.config_mode) as config_session:
89
+ config_session.send_command("no logging console", ConfigCommandMode.PROMPT)
@@ -0,0 +1,150 @@
1
+ #!/usr/bin/python
2
+
3
+ import re
4
+ import time
5
+ from collections import OrderedDict
6
+
7
+ from cloudshell.cli.service.command_mode import CommandMode
8
+
9
+
10
+ class DefaultCommandMode(CommandMode):
11
+ PROMPT = r">\s*$"
12
+ ENTER_COMMAND = ""
13
+ EXIT_COMMAND = ""
14
+
15
+ def __init__(self, enable_password: str):
16
+ """Initialize Default command mode.
17
+
18
+ Only for cases when session started not in enable mode
19
+ """
20
+ self.enable_password = enable_password
21
+
22
+ CommandMode.__init__(
23
+ self,
24
+ DefaultCommandMode.PROMPT,
25
+ DefaultCommandMode.ENTER_COMMAND,
26
+ DefaultCommandMode.EXIT_COMMAND,
27
+ enter_action_map=self.enter_action_map(),
28
+ exit_action_map=self.exit_action_map(),
29
+ enter_error_map=self.enter_error_map(),
30
+ exit_error_map=self.exit_error_map(),
31
+ )
32
+
33
+ def enter_action_map(self):
34
+ return OrderedDict()
35
+
36
+ def enter_error_map(self):
37
+ return OrderedDict()
38
+
39
+ def exit_action_map(self):
40
+ return OrderedDict()
41
+
42
+ def exit_error_map(self):
43
+ return OrderedDict()
44
+
45
+
46
+ class EnableCommandMode(CommandMode):
47
+ PROMPT = r"(?:(?!\)).)#\s*$"
48
+ ENTER_COMMAND = "enable"
49
+ EXIT_COMMAND = ""
50
+
51
+ def __init__(self, enable_password: str):
52
+ """Initialize Enable command mode - default command mode for Cisco Shells."""
53
+ self.enable_password = enable_password
54
+
55
+ CommandMode.__init__(
56
+ self,
57
+ EnableCommandMode.PROMPT,
58
+ EnableCommandMode.ENTER_COMMAND,
59
+ EnableCommandMode.EXIT_COMMAND,
60
+ enter_action_map=self.enter_action_map(),
61
+ exit_action_map=self.exit_action_map(),
62
+ enter_error_map=self.enter_error_map(),
63
+ exit_error_map=self.exit_error_map(),
64
+ )
65
+
66
+ def enter_action_map(self):
67
+ return {
68
+ "[Pp]assword": lambda session, logger: session.send_line(
69
+ self.enable_password, logger
70
+ )
71
+ }
72
+
73
+ def enter_error_map(self):
74
+ return OrderedDict()
75
+
76
+ def exit_action_map(self):
77
+ return OrderedDict()
78
+
79
+ def exit_error_map(self):
80
+ return OrderedDict()
81
+
82
+
83
+ class ConfigCommandMode(CommandMode):
84
+ MAX_ENTER_CONFIG_MODE_RETRIES = 5
85
+ ENTER_CONFIG_RETRY_TIMEOUT = 5
86
+ PROMPT = r"\(config.*\)#\s*$"
87
+ ENTER_COMMAND = "configure terminal"
88
+ EXIT_COMMAND = "exit"
89
+ ENTER_ACTION_COMMANDS = []
90
+
91
+ def __init__(self, enable_password: str):
92
+ """Initialize Config command mode."""
93
+ self.enable_password = enable_password
94
+
95
+ CommandMode.__init__(
96
+ self,
97
+ ConfigCommandMode.PROMPT,
98
+ ConfigCommandMode.ENTER_COMMAND,
99
+ ConfigCommandMode.EXIT_COMMAND,
100
+ enter_action_map=self.enter_action_map(),
101
+ exit_action_map=self.exit_action_map(),
102
+ enter_error_map=self.enter_error_map(),
103
+ exit_error_map=self.exit_error_map(),
104
+ )
105
+
106
+ def enter_action_map(self):
107
+ return {rf"{EnableCommandMode.PROMPT}.*$": self._check_config_mode}
108
+
109
+ def enter_error_map(self):
110
+ return OrderedDict()
111
+
112
+ def exit_error_map(self):
113
+ return OrderedDict()
114
+
115
+ def exit_action_map(self):
116
+ return {self.PROMPT: lambda session, logger: session.send_line("exit", logger)}
117
+
118
+ def enter_actions(self, cli_service):
119
+ for cmd in self.ENTER_ACTION_COMMANDS:
120
+ cli_service.send_command(cmd)
121
+
122
+ def _check_config_mode(self, session, logger):
123
+ error_message = "Failed to enter config mode, please check logs, for details"
124
+ output = session.hardware_expect(
125
+ "",
126
+ expected_string="{}|{}".format(
127
+ EnableCommandMode.PROMPT, ConfigCommandMode.PROMPT
128
+ ),
129
+ logger=logger,
130
+ )
131
+ retry = 0
132
+ while (
133
+ not re.search(ConfigCommandMode.PROMPT, output)
134
+ ) and retry < self.MAX_ENTER_CONFIG_MODE_RETRIES:
135
+ output = session.hardware_expect(
136
+ ConfigCommandMode.ENTER_COMMAND,
137
+ expected_string="{}|{}".format(
138
+ EnableCommandMode.PROMPT, ConfigCommandMode.PROMPT
139
+ ),
140
+ logger=logger,
141
+ )
142
+ time.sleep(self.ENTER_CONFIG_RETRY_TIMEOUT)
143
+ retry += 1
144
+ if not re.search(ConfigCommandMode.PROMPT, output):
145
+ raise Exception(error_message)
146
+
147
+
148
+ CommandMode.RELATIONS_DICT = {
149
+ DefaultCommandMode: {EnableCommandMode: {ConfigCommandMode: {}}}
150
+ }
@@ -0,0 +1,3 @@
1
+ from pkgutil import extend_path
2
+
3
+ __path__ = extend_path(__path__, __name__)