Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Releasing v24.10 #105

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions docs/changelog/2024/october.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
October 2024
==========

October 29 - Unicon v24.10
------------------------



.. csv-table:: Module Versions
:header: "Modules", "Versions"

``unicon.plugins``, v24.10
``unicon``, v24.10




Changelogs
^^^^^^^^^^
--------------------------------------------------------------------------------
Fix
--------------------------------------------------------------------------------

* generic
* service_implementations/Configure
* update the pattern for update_hostname in the configure service.

* iosxr/spitfire
* patterns
* remove the config and enable pattern


1 change: 1 addition & 0 deletions docs/changelog/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog
.. toctree::
:maxdepth: 2

2024/october
2024/September
2024/august
2024/july
Expand Down
36 changes: 36 additions & 0 deletions docs/changelog_plugins/2024/october.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
October 2024
==========

October 29 - Unicon.Plugins v24.10
------------------------



.. csv-table:: Module Versions
:header: "Modules", "Versions"

``unicon.plugins``, v24.10
``unicon``, v24.10




Changelogs
^^^^^^^^^^
--------------------------------------------------------------------------------
Fix
--------------------------------------------------------------------------------

* pid tokens
* Updated PID tokens to support NCS devices


--------------------------------------------------------------------------------
Add
--------------------------------------------------------------------------------

* apic plugin
* Modified the regex patterns in the post_service method in Execute to remove extra junk values and retain the newline character in the output.
* Added a configure class to eliminate extra junk values from the output.


1 change: 1 addition & 0 deletions docs/changelog_plugins/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Plugins Changelog
.. toctree::
:maxdepth: 2

2024/october
2024/September
2024/august
2024/july
Expand Down
2 changes: 1 addition & 1 deletion src/unicon/plugins/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '24.9'
__version__ = '24.10'

supported_chassis = [
'single_rp',
Expand Down
4 changes: 2 additions & 2 deletions src/unicon/plugins/apic/connection.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from unicon.plugins.generic import GenericSingleRpConnection
from unicon.plugins.generic.connection_provider import GenericSingleRpConnectionProvider

from unicon.plugins.generic import ServiceList, service_implementation as svc
from unicon.plugins.generic import ServiceList
from unicon.eal.dialogs import Statement

from . import service_implementation as aci_svc
Expand Down Expand Up @@ -44,7 +44,7 @@ class AciApicServiceList(ServiceList):
def __init__(self):
super().__init__()
self.execute = aci_svc.Execute
self.configure = svc.Configure
self.configure = aci_svc.Configure
self.reload = aci_svc.Reload


Expand Down
56 changes: 45 additions & 11 deletions src/unicon/plugins/apic/service_implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
from time import sleep
from unicon.logs import UniconStreamHandler, UNICON_LOG_FORMAT
from unicon.bases.routers.services import BaseService
from unicon.plugins.generic.service_implementation import Execute as GenericExecute
from unicon.plugins.generic.service_implementation import (Execute as GenericExecute,
Configure as GenericConfigure)
from unicon.plugins.generic import GenericUtils
from unicon.core.errors import SubCommandFailure
from unicon.eal.dialogs import Dialog
Expand All @@ -16,6 +17,16 @@
utils = GenericUtils()


def clean_command_output(output):
""" Function to clean command output by removing unwanted characters """
output = utils.remove_ansi_escape_codes(output)
output = re.sub('.\x08', '', output)
output = re.sub(r'%\s+\r ', '', output)
output = re.sub(r'\x00+', '', output)
output = re.sub(r'[\r%]+', '', output)
return output


class Execute(GenericExecute):
""" Execute Service implementation

Expand All @@ -27,7 +38,6 @@ class Execute(GenericExecute):
command: exec command
reply: Additional Dialog patterns for interactive exec commands.
timeout : Timeout value in sec, Default Value is 60 sec
lines: number of lines to capture when paging is active. Default: 100

Returns:
True on Success, raise SubCommandFailure on failure
Expand All @@ -46,15 +56,39 @@ def __init__(self, connection, context, **kwargs):
def post_service(self, *args, clean_output=True, **kwargs):
super().post_service(*args, **kwargs)

if clean_output:
if isinstance(self.result, str):
output = self.result
output = utils.remove_ansi_escape_codes(output)
output = re.sub('.\x08', '', output)
output = re.sub(r'\x00+', '', output)
output = re.sub(r'%(\s+\r )?', '', output)
output = re.sub(r'[\r\n]+', '', output)
self.result = output
if clean_output and isinstance(self.result, str):
self.result = clean_command_output(self.result)


class Configure(GenericConfigure):
""" Configure Service implementation

Service to execute configuration commands on the device and return the
console output. The `reply` option can be passed for interactive configuration commands.

Arguments:
commands : list/single config command
reply: Addition Dialogs for interactive config commands.
timeout : Timeout value in sec, Default Value is 30 sec

Returns:
True on Success, raises SubCommandFailure on failure

Example:
.. code-block:: python
output = rtr.configure('no logging console')
cmd =['hostname si-tvt-7200-28-41', 'no logging console']
output = dev.configure(cmd)
"""
def __init__(self, connection, context, **kwargs):
# Connection object will have all the received details
super().__init__(connection, context, **kwargs)

def post_service(self, *args, clean_output=True, **kwargs):
super().post_service(*args, **kwargs)

if clean_output and isinstance(self.result, str):
self.result = clean_command_output(self.result)


class Reload(BaseService):
Expand Down
4 changes: 2 additions & 2 deletions src/unicon/plugins/generic/service_implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1034,9 +1034,9 @@ def process_dialog_on_handle(self, handle, dialog, timeout):

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


Expand Down
4 changes: 0 additions & 4 deletions src/unicon/plugins/iosxr/spitfire/patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ def __init__(self):
super().__init__()
# Always have the first match group (.*?) as this is the data
# returned as the cli output .
self.enable_prompt = \
r'^(.*?)RP/\d+/RP[01]/CPU\d+:(%N|ios)\s*#\s*?$'
self.config_prompt = \
r'^(.*?)RP/\d+/RP[01]/CPU\d+:(%N|ios)\s*\(config.*\)\s*#\s*?$'
self.bmc_prompt = \
r'^(.*?)root@spitfire-arm:.+?#\s*?$'
self.xr_bash_prompt = \
Expand Down
59 changes: 38 additions & 21 deletions src/unicon/plugins/pid_tokens.csv
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
pid,os,platform,model,submodel
2501FRAD-FX,ios,c2k,c2500,
2501LANFRAD-FX,ios,c2k,c2500,
8102-64H,iosxr,spitfire,8100,
8201,iosxr,spitfire,8200,
8201-24H8FH,iosxr,spitfire,8200,
8201-32FH,iosxr,spitfire,8200,
8201-32FH-O,sonic,spitfire,8200,
8202,iosxr,spitfire,8200,
8202-32FH-M,iosxr,spitfire,8200,
8804,iosxr,spitfire,8800,
8808,iosxr,spitfire,8800,
8812,iosxr,spitfire,8800,
8818,iosxr,spitfire,8800,
AS2511-RJ,ios,c2500,c2511,
ASR-9001,iosxr,asr9k,asr9000,
ASR-9001-S,iosxr,asr9k,asr9000,
ASR-9006-SYS,iosxr,asr9k,asr9000,
Expand All @@ -20,18 +24,19 @@ ASR-9906,iosxr,asr9k,asr9900,
ASR-9910,iosxr,asr9k,asr9900,
ASR-9912,iosxr,asr9k,asr9900,
ASR-9922,iosxr,asr9k,asr9900,
ASR1001,iosxe,asr1k,asr1000,
ASR1001-2XOC3POS,iosxe,asr1k,asr1000,
ASR1001-4X1GE,iosxe,asr1k,asr1000,
ASR1001-4XT3,iosxe,asr1k,asr1000,
ASR1001-8XCHT1E1,iosxe,asr1k,asr1000,
ASR1001-HDD,iosxe,asr1k,asr1000,
ASR1002,iosxe,asr1k,asr1000,
ASR1002-F,iosxe,asr1k,asr1000,
ASR1004,iosxe,asr1k,asr1000,
ASR1006,iosxe,asr1k,asr1000,
ASR1006-X,iosxe,asr1k,asr1000,
ASR1013,iosxe,asr1k,asr1000,
ASR1001,iosxe,asr1k,asr1001,
ASR1001-2XOC3POS,iosxe,asr1k,asr1001,
ASR1001-4X1GE,iosxe,asr1k,asr1001,
ASR1001-4XT3,iosxe,asr1k,asr1001,
ASR1001-8XCHT1E1,iosxe,asr1k,asr1001,
ASR1001-HDD,iosxe,asr1k,asr1001,
ASR1002,iosxe,asr1k,asr1002,
ASR1002-F,iosxe,asr1k,asr1002,
ASR1004,iosxe,asr1k,asr1004,
ASR1006,iosxe,asr1k,asr1006,
ASR1006-X,iosxe,asr1k,asr1006,
ASR1009-X,iosxe,asr1k,asr1009,
ASR1013,iosxe,asr1k,asr1013,
C1000-16FP-2G-L,iosxe,cat1k,c1000,
C1000-16P-2G-L,iosxe,cat1k,c1000,
C1000-16P-E-2G-L,iosxe,cat1k,c1000,
Expand Down Expand Up @@ -730,6 +735,15 @@ N3K-C36180YC-R,nxos,n3k,n3600,
N3K-C3636C-R,nxos,n3k,n3600,
N4K-4001I-XPX,nxos,n4k,n4000,
N4K-4005I-XPX,nxos,n4k,n4000,
N540-12Z20G-SYS-A,iosxr,ncs500,ncs540,
N540-24Q8L2DD-SYS,iosxr,ncs500,ncs540,
N540-24Z8Q2C-M,iosxr,ncs500,ncs540,
N540-28Z4C-SYS-A,iosxr,ncs500,ncs540,
N540-ACC-SYS,iosxr,ncs500,ncs540,
N540-FH-CSR-SYS,iosxr,ncs500,ncs540,
N540X-4Z14G2Q-A,iosxr,ncs500,ncs540x,
N540X-8Z16G-SYS-A,iosxr,ncs500,ncs540x,
N540X-ACC-SYS,iosxr,ncs500,ncs540x,
N5K-C5010P-BF,nxos,n5k,n5000,
N5K-C5020P-BF,nxos,n5k,n5000,
N5K-C5548P,nxos,n5k,n5500,
Expand Down Expand Up @@ -809,9 +823,12 @@ NCS-5502-SE,iosxr,ncs5k,ncs5500,
NCS-5504,iosxr,ncs5k,ncs5500,
NCS-5508,iosxr,ncs5k,ncs5500,
NCS-5516,iosxr,ncs5k,ncs5500,
NCS-55A1-24Q6H-S,iosxr,ncs5k,ncs5500,
NCS-55A1-36H-SE-S,iosxr,ncs5k,ncs5500,
NCS-55A1-48Q6H,iosxr,ncs5k,ncs5500,
NCS-55A1-24Q6H-S,iosxr,ncs5k,ncs55a1,
NCS-55A1-36H-S,iosxr,ncs5k,ncs55a1,
NCS-55A1-36H-SE-S,iosxr,ncs5k,ncs55a1,
NCS-55A1-48Q6H,iosxr,ncs5k,ncs55a1,
NCS-57C3-MOD-SYS,iosxr,ncs5k,ncs5700,
NCS-57C3-MODS-SYS,iosxr,ncs5k,ncs5700,
NCS-6008,iosxr,ncs6k,ncs6000,
NCS-F-CHASS,iosxr,ncs6k,ncs6000,
NCS1001-K9,iosxr,ncs1k,ncs1000,
Expand All @@ -826,11 +843,11 @@ NCS4009-SA-AC,iosxr,ncs4k,ncs4000,
NCS4009-SA-DC,iosxr,ncs4k,ncs4000,
NCS4016-SA-AC,iosxr,ncs4k,ncs4000,
NCS4016-SA-DC,iosxr,ncs4k,ncs4000,
NCS4201-SA,iosxr,ncs4k,ncs4200,
NCS4202-SA,iosxr,ncs4k,ncs4200,
NCS4206-SA,iosxr,ncs4k,ncs4200,
NCS4216-F2B-SA,iosxr,ncs4k,ncs4200,
NCS4216-SA,iosxr,ncs4k,ncs4200,
NCS4201-SA,iosxe,ncs4k,ncs4200,
NCS4202-SA,iosxe,ncs4k,ncs4200,
NCS4206-SA,iosxe,ncs4k,ncs4200,
NCS4216-F2B-SA,iosxe,ncs4k,ncs4200,
NCS4216-SA,iosxe,ncs4k,ncs4200,
NCS4KF-SA-DC,iosxr,ncs4k,ncs4000,
Nexus1000V,nxos,n1k,n1000,
Nexus1000Vh,nxos,n1k,n1000,
Expand Down Expand Up @@ -1424,4 +1441,4 @@ WS-C6509-NEB-A,iosxe,cat6k,c6500,
WS-C6509-V-E,iosxe,cat6k,c6500,
WS-C6513,iosxe,cat6k,c6500,
WS-C6513-E,iosxe,cat6k,c6500,
WS-X3011-CH,iosxe,cat3k,c3000,
WS-X3011-CH,iosxe,cat3k,c3000,
5 changes: 5 additions & 0 deletions src/unicon/plugins/tests/mock/mock_device_nxos.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ def exec(self, transport, cmd):
self.set_state(self.transport_handles[transport], 'scp_password')
return True

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

class MockDeviceTcpWrapperNXOS(MockDeviceTcpWrapper):

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ apic_config:
commands:
"tenant test":
new_state: apic_config_tenant
"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"
"end":
new_state: apic_exec

Expand Down
Loading
Loading