Skip to content

Commit 86a61a2

Browse files
author
Thomas Ryan
committed
Releasing v24.10
1 parent 009cad7 commit 86a61a2

19 files changed

+265
-69
lines changed

docs/changelog/2024/october.rst

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
October 2024
2+
==========
3+
4+
October 29 - Unicon v24.10
5+
------------------------
6+
7+
8+
9+
.. csv-table:: Module Versions
10+
:header: "Modules", "Versions"
11+
12+
``unicon.plugins``, v24.10
13+
``unicon``, v24.10
14+
15+
16+
17+
18+
Changelogs
19+
^^^^^^^^^^
20+
--------------------------------------------------------------------------------
21+
Fix
22+
--------------------------------------------------------------------------------
23+
24+
* generic
25+
* service_implementations/Configure
26+
* update the pattern for update_hostname in the configure service.
27+
28+
* iosxr/spitfire
29+
* patterns
30+
* remove the config and enable pattern
31+
32+

docs/changelog/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Changelog
44
.. toctree::
55
:maxdepth: 2
66

7+
2024/october
78
2024/September
89
2024/august
910
2024/july
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
October 2024
2+
==========
3+
4+
October 29 - Unicon.Plugins v24.10
5+
------------------------
6+
7+
8+
9+
.. csv-table:: Module Versions
10+
:header: "Modules", "Versions"
11+
12+
``unicon.plugins``, v24.10
13+
``unicon``, v24.10
14+
15+
16+
17+
18+
Changelogs
19+
^^^^^^^^^^
20+
--------------------------------------------------------------------------------
21+
Fix
22+
--------------------------------------------------------------------------------
23+
24+
* pid tokens
25+
* Updated PID tokens to support NCS devices
26+
27+
28+
--------------------------------------------------------------------------------
29+
Add
30+
--------------------------------------------------------------------------------
31+
32+
* apic plugin
33+
* Modified the regex patterns in the post_service method in Execute to remove extra junk values and retain the newline character in the output.
34+
* Added a configure class to eliminate extra junk values from the output.
35+
36+

docs/changelog_plugins/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Plugins Changelog
44
.. toctree::
55
:maxdepth: 2
66

7+
2024/october
78
2024/September
89
2024/august
910
2024/july

src/unicon/plugins/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = '24.9'
1+
__version__ = '24.10'
22

33
supported_chassis = [
44
'single_rp',

src/unicon/plugins/apic/connection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from unicon.plugins.generic import GenericSingleRpConnection
22
from unicon.plugins.generic.connection_provider import GenericSingleRpConnectionProvider
33

4-
from unicon.plugins.generic import ServiceList, service_implementation as svc
4+
from unicon.plugins.generic import ServiceList
55
from unicon.eal.dialogs import Statement
66

77
from . import service_implementation as aci_svc
@@ -44,7 +44,7 @@ class AciApicServiceList(ServiceList):
4444
def __init__(self):
4545
super().__init__()
4646
self.execute = aci_svc.Execute
47-
self.configure = svc.Configure
47+
self.configure = aci_svc.Configure
4848
self.reload = aci_svc.Reload
4949

5050

src/unicon/plugins/apic/service_implementation.py

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
from time import sleep
77
from unicon.logs import UniconStreamHandler, UNICON_LOG_FORMAT
88
from unicon.bases.routers.services import BaseService
9-
from unicon.plugins.generic.service_implementation import Execute as GenericExecute
9+
from unicon.plugins.generic.service_implementation import (Execute as GenericExecute,
10+
Configure as GenericConfigure)
1011
from unicon.plugins.generic import GenericUtils
1112
from unicon.core.errors import SubCommandFailure
1213
from unicon.eal.dialogs import Dialog
@@ -16,6 +17,16 @@
1617
utils = GenericUtils()
1718

1819

20+
def clean_command_output(output):
21+
""" Function to clean command output by removing unwanted characters """
22+
output = utils.remove_ansi_escape_codes(output)
23+
output = re.sub('.\x08', '', output)
24+
output = re.sub(r'%\s+\r ', '', output)
25+
output = re.sub(r'\x00+', '', output)
26+
output = re.sub(r'[\r%]+', '', output)
27+
return output
28+
29+
1930
class Execute(GenericExecute):
2031
""" Execute Service implementation
2132
@@ -27,7 +38,6 @@ class Execute(GenericExecute):
2738
command: exec command
2839
reply: Additional Dialog patterns for interactive exec commands.
2940
timeout : Timeout value in sec, Default Value is 60 sec
30-
lines: number of lines to capture when paging is active. Default: 100
3141
3242
Returns:
3343
True on Success, raise SubCommandFailure on failure
@@ -46,15 +56,39 @@ def __init__(self, connection, context, **kwargs):
4656
def post_service(self, *args, clean_output=True, **kwargs):
4757
super().post_service(*args, **kwargs)
4858

49-
if clean_output:
50-
if isinstance(self.result, str):
51-
output = self.result
52-
output = utils.remove_ansi_escape_codes(output)
53-
output = re.sub('.\x08', '', output)
54-
output = re.sub(r'\x00+', '', output)
55-
output = re.sub(r'%(\s+\r )?', '', output)
56-
output = re.sub(r'[\r\n]+', '', output)
57-
self.result = output
59+
if clean_output and isinstance(self.result, str):
60+
self.result = clean_command_output(self.result)
61+
62+
63+
class Configure(GenericConfigure):
64+
""" Configure Service implementation
65+
66+
Service to execute configuration commands on the device and return the
67+
console output. The `reply` option can be passed for interactive configuration commands.
68+
69+
Arguments:
70+
commands : list/single config command
71+
reply: Addition Dialogs for interactive config commands.
72+
timeout : Timeout value in sec, Default Value is 30 sec
73+
74+
Returns:
75+
True on Success, raises SubCommandFailure on failure
76+
77+
Example:
78+
.. code-block:: python
79+
output = rtr.configure('no logging console')
80+
cmd =['hostname si-tvt-7200-28-41', 'no logging console']
81+
output = dev.configure(cmd)
82+
"""
83+
def __init__(self, connection, context, **kwargs):
84+
# Connection object will have all the received details
85+
super().__init__(connection, context, **kwargs)
86+
87+
def post_service(self, *args, clean_output=True, **kwargs):
88+
super().post_service(*args, **kwargs)
89+
90+
if clean_output and isinstance(self.result, str):
91+
self.result = clean_command_output(self.result)
5892

5993

6094
class Reload(BaseService):

src/unicon/plugins/generic/service_implementation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,9 +1034,9 @@ def process_dialog_on_handle(self, handle, dialog, timeout):
10341034

10351035
def update_hostname_if_needed(self, cmd_list):
10361036
for cmd in cmd_list:
1037-
m = re.match(r'^\s*hostname (\S+)', cmd)
1037+
m = re.match(r'^\s*(hostname|switchname) (\S+)', cmd)
10381038
if m:
1039-
self.connection.hostname = m.group(1)
1039+
self.connection.hostname = m.group(2)
10401040
return
10411041

10421042

src/unicon/plugins/iosxr/spitfire/patterns.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ def __init__(self):
77
super().__init__()
88
# Always have the first match group (.*?) as this is the data
99
# returned as the cli output .
10-
self.enable_prompt = \
11-
r'^(.*?)RP/\d+/RP[01]/CPU\d+:(%N|ios)\s*#\s*?$'
12-
self.config_prompt = \
13-
r'^(.*?)RP/\d+/RP[01]/CPU\d+:(%N|ios)\s*\(config.*\)\s*#\s*?$'
1410
self.bmc_prompt = \
1511
r'^(.*?)root@spitfire-arm:.+?#\s*?$'
1612
self.xr_bash_prompt = \

src/unicon/plugins/pid_tokens.csv

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
pid,os,platform,model,submodel
22
2501FRAD-FX,ios,c2k,c2500,
33
2501LANFRAD-FX,ios,c2k,c2500,
4+
8102-64H,iosxr,spitfire,8100,
45
8201,iosxr,spitfire,8200,
6+
8201-24H8FH,iosxr,spitfire,8200,
57
8201-32FH,iosxr,spitfire,8200,
8+
8201-32FH-O,sonic,spitfire,8200,
69
8202,iosxr,spitfire,8200,
710
8202-32FH-M,iosxr,spitfire,8200,
811
8804,iosxr,spitfire,8800,
912
8808,iosxr,spitfire,8800,
1013
8812,iosxr,spitfire,8800,
1114
8818,iosxr,spitfire,8800,
15+
AS2511-RJ,ios,c2500,c2511,
1216
ASR-9001,iosxr,asr9k,asr9000,
1317
ASR-9001-S,iosxr,asr9k,asr9000,
1418
ASR-9006-SYS,iosxr,asr9k,asr9000,
@@ -20,18 +24,19 @@ ASR-9906,iosxr,asr9k,asr9900,
2024
ASR-9910,iosxr,asr9k,asr9900,
2125
ASR-9912,iosxr,asr9k,asr9900,
2226
ASR-9922,iosxr,asr9k,asr9900,
23-
ASR1001,iosxe,asr1k,asr1000,
24-
ASR1001-2XOC3POS,iosxe,asr1k,asr1000,
25-
ASR1001-4X1GE,iosxe,asr1k,asr1000,
26-
ASR1001-4XT3,iosxe,asr1k,asr1000,
27-
ASR1001-8XCHT1E1,iosxe,asr1k,asr1000,
28-
ASR1001-HDD,iosxe,asr1k,asr1000,
29-
ASR1002,iosxe,asr1k,asr1000,
30-
ASR1002-F,iosxe,asr1k,asr1000,
31-
ASR1004,iosxe,asr1k,asr1000,
32-
ASR1006,iosxe,asr1k,asr1000,
33-
ASR1006-X,iosxe,asr1k,asr1000,
34-
ASR1013,iosxe,asr1k,asr1000,
27+
ASR1001,iosxe,asr1k,asr1001,
28+
ASR1001-2XOC3POS,iosxe,asr1k,asr1001,
29+
ASR1001-4X1GE,iosxe,asr1k,asr1001,
30+
ASR1001-4XT3,iosxe,asr1k,asr1001,
31+
ASR1001-8XCHT1E1,iosxe,asr1k,asr1001,
32+
ASR1001-HDD,iosxe,asr1k,asr1001,
33+
ASR1002,iosxe,asr1k,asr1002,
34+
ASR1002-F,iosxe,asr1k,asr1002,
35+
ASR1004,iosxe,asr1k,asr1004,
36+
ASR1006,iosxe,asr1k,asr1006,
37+
ASR1006-X,iosxe,asr1k,asr1006,
38+
ASR1009-X,iosxe,asr1k,asr1009,
39+
ASR1013,iosxe,asr1k,asr1013,
3540
C1000-16FP-2G-L,iosxe,cat1k,c1000,
3641
C1000-16P-2G-L,iosxe,cat1k,c1000,
3742
C1000-16P-E-2G-L,iosxe,cat1k,c1000,
@@ -730,6 +735,15 @@ N3K-C36180YC-R,nxos,n3k,n3600,
730735
N3K-C3636C-R,nxos,n3k,n3600,
731736
N4K-4001I-XPX,nxos,n4k,n4000,
732737
N4K-4005I-XPX,nxos,n4k,n4000,
738+
N540-12Z20G-SYS-A,iosxr,ncs500,ncs540,
739+
N540-24Q8L2DD-SYS,iosxr,ncs500,ncs540,
740+
N540-24Z8Q2C-M,iosxr,ncs500,ncs540,
741+
N540-28Z4C-SYS-A,iosxr,ncs500,ncs540,
742+
N540-ACC-SYS,iosxr,ncs500,ncs540,
743+
N540-FH-CSR-SYS,iosxr,ncs500,ncs540,
744+
N540X-4Z14G2Q-A,iosxr,ncs500,ncs540x,
745+
N540X-8Z16G-SYS-A,iosxr,ncs500,ncs540x,
746+
N540X-ACC-SYS,iosxr,ncs500,ncs540x,
733747
N5K-C5010P-BF,nxos,n5k,n5000,
734748
N5K-C5020P-BF,nxos,n5k,n5000,
735749
N5K-C5548P,nxos,n5k,n5500,
@@ -809,9 +823,12 @@ NCS-5502-SE,iosxr,ncs5k,ncs5500,
809823
NCS-5504,iosxr,ncs5k,ncs5500,
810824
NCS-5508,iosxr,ncs5k,ncs5500,
811825
NCS-5516,iosxr,ncs5k,ncs5500,
812-
NCS-55A1-24Q6H-S,iosxr,ncs5k,ncs5500,
813-
NCS-55A1-36H-SE-S,iosxr,ncs5k,ncs5500,
814-
NCS-55A1-48Q6H,iosxr,ncs5k,ncs5500,
826+
NCS-55A1-24Q6H-S,iosxr,ncs5k,ncs55a1,
827+
NCS-55A1-36H-S,iosxr,ncs5k,ncs55a1,
828+
NCS-55A1-36H-SE-S,iosxr,ncs5k,ncs55a1,
829+
NCS-55A1-48Q6H,iosxr,ncs5k,ncs55a1,
830+
NCS-57C3-MOD-SYS,iosxr,ncs5k,ncs5700,
831+
NCS-57C3-MODS-SYS,iosxr,ncs5k,ncs5700,
815832
NCS-6008,iosxr,ncs6k,ncs6000,
816833
NCS-F-CHASS,iosxr,ncs6k,ncs6000,
817834
NCS1001-K9,iosxr,ncs1k,ncs1000,
@@ -826,11 +843,11 @@ NCS4009-SA-AC,iosxr,ncs4k,ncs4000,
826843
NCS4009-SA-DC,iosxr,ncs4k,ncs4000,
827844
NCS4016-SA-AC,iosxr,ncs4k,ncs4000,
828845
NCS4016-SA-DC,iosxr,ncs4k,ncs4000,
829-
NCS4201-SA,iosxr,ncs4k,ncs4200,
830-
NCS4202-SA,iosxr,ncs4k,ncs4200,
831-
NCS4206-SA,iosxr,ncs4k,ncs4200,
832-
NCS4216-F2B-SA,iosxr,ncs4k,ncs4200,
833-
NCS4216-SA,iosxr,ncs4k,ncs4200,
846+
NCS4201-SA,iosxe,ncs4k,ncs4200,
847+
NCS4202-SA,iosxe,ncs4k,ncs4200,
848+
NCS4206-SA,iosxe,ncs4k,ncs4200,
849+
NCS4216-F2B-SA,iosxe,ncs4k,ncs4200,
850+
NCS4216-SA,iosxe,ncs4k,ncs4200,
834851
NCS4KF-SA-DC,iosxr,ncs4k,ncs4000,
835852
Nexus1000V,nxos,n1k,n1000,
836853
Nexus1000Vh,nxos,n1k,n1000,
@@ -1424,4 +1441,4 @@ WS-C6509-NEB-A,iosxe,cat6k,c6500,
14241441
WS-C6509-V-E,iosxe,cat6k,c6500,
14251442
WS-C6513,iosxe,cat6k,c6500,
14261443
WS-C6513-E,iosxe,cat6k,c6500,
1427-
WS-X3011-CH,iosxe,cat3k,c3000,
1444+
WS-X3011-CH,iosxe,cat3k,c3000,

src/unicon/plugins/tests/mock/mock_device_nxos.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ def exec(self, transport, cmd):
6565
self.set_state(self.transport_handles[transport], 'scp_password')
6666
return True
6767

68+
def config(self, transport, cmd):
69+
m = re.match(r'\s*(hostname|switchname) (\S+)', cmd)
70+
if m:
71+
self.hostname = m.group(2)
72+
return True
6873

6974
class MockDeviceTcpWrapperNXOS(MockDeviceTcpWrapper):
7075

src/unicon/plugins/tests/mock_data/apic/apic_mock_data.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ apic_config:
9393
commands:
9494
"tenant test":
9595
new_state: apic_config_tenant
96+
"switch-group": "\x1b[K\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1b[1C\x1b[?1l\x1b>\x1b[?2004l\r\r\nError: Invalid argument ''. Please check syntax in command reference guide\r\n\x1b[1m\x00\x00\x00\x00\x00\x00\x00\x00\x1b[7m\x00\x00\x00\x00\x00\x00\x00\x00%\x1b[m\x00\x00\x00\x00\x00\x00\x00\x00\x1b[1m\x00\x00\x00\x00\x00\x00\x00\x00\x1b[0m\x00\x00\x00\x00\x00\x00\x00\x00 \r \r\r\x1b[0m\x00\x00\x00\x00\x00\x00\x00\x00\x1b[m\x00\x00\x00\x00\x00\x00\x00\x00\x1b[m\x00\x00\x00\x00\x00\x00\x00\x00\x1b[J\x00"
9697
"end":
9798
new_state: apic_exec
9899

0 commit comments

Comments
 (0)