Skip to content

Commit

Permalink
Merge pull request #72 from laimaretto/devel
Browse files Browse the repository at this point in the history
8.1.1
  • Loading branch information
laimaretto authored Sep 17, 2023
2 parents e1d2753 + b892544 commit b08d78c
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 18 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ The program needs two mandatory inputs: a) DATA file and b) a plugin, which is n
### DATA file
The DATA can be either a CSV file or an Excel file. In both cases you can define a header with column names, or not; it's optional.
- If no header, the file must have in its first column (`_1`), the IP of the routers to which `taskAutom` will connect to.
- If using header, there must be a column named `ip` with the IP addresses of the routers to which `taskAutom` will connect to.
- You can chose a differnt column name by using the configuration option `-gc/--dataGroupColumn myColName`.
- If no headers, the file must have in its first column (`_1`), the IP of the routers to which `taskAutom` will connect to.
- Using a data file without headers is discouraged. It will be deprecated. It's only here for historical reasons.
- If using headers, there must be a column named `ip` with the IP addresses of the routers to which `taskAutom` will connect to.
- You can chose a different column name by using the configuration option `-gc/--dataGroupColumn myColName`.

The first column `_1` or the `ip` column (or eventually changed by `-gc`) allows `taskAutom` to group routers by that column when processing data. This is particularly useful if you have the same router along several rows in the DATA file.

Expand Down Expand Up @@ -95,7 +96,7 @@ def construir_cliLine(m, datos, lenData, mop=None):
if m == lenData-1:
cfg = cfg + f'/configure router interface {intName} no shutdown\n'
return cfg
return cfg
```

#### Notes on plugin
Expand All @@ -114,6 +115,7 @@ ip|username|password|useSSHTunnel|readTimeOut|deviceType|jumpHost|
--|--------|--------|------------|----------|--------|---------
10.0.0.1|user1|pass1|yes|15|nokia_sros|server1|1000
10.0.0.2|user2|pass2|no|90|nokia_sros_telnet|
10.0.0.3|user3|pass3|no|90|nokia_srl|

If fieds in the inventory CSV file are left empty, default values are used.

Expand Down
7 changes: 7 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Versions #

## [8.1.1] - 2023-09-17

- Update to have taskAutom support access to SRLinux devices. A new device type `nokia_srl` has been included under the `DICT_VENDOR` general dictionary.
- Netmiko, by default, disables pagination either by using `environment no more` or `environment more false`. The `FIRST_LINE=""` from now on for device type `nokia_sros`.
- The device_type `md_nokia_sros` has been removed from the `-dt` option.
- `00_report.json` now includes timing information.

## [8.0.6] - 2023-06-24

- The function `fncPrintResults()` now created a new data file, `00_faildeDataFile`, which is a subset of the original data file. Thisincludes only the devices which have presented errors during exectuion.ssh-tunnels.
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from importlib.metadata import entry_points
from setuptools import setup

setup(
name='taskAutom',
version='8.0.6',
version='8.1.1',
description='A simple task automation tool',
long_description='A simple task automation tool for NOKIA SROS based routers',
long_description_content_type='text/x-rst',
Expand Down
2 changes: 1 addition & 1 deletion src/taskAutom/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = "8.0.6"
__version__ = "8.1.1"
__author__ = 'Lucas Aimaretto'
51 changes: 40 additions & 11 deletions src/taskAutom/taskAutom.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from docx.shared import Pt


LATEST_VERSION = '8.0.6'
LATEST_VERSION = '8.1.1'

# Constants
IP_LOCALHOST = "127.0.0.1"
Expand Down Expand Up @@ -70,14 +70,15 @@
passByRow = True,
genMop = False,
dataGroupColumn = 'ip',
version = LATEST_VERSION
version = LATEST_VERSION,
xlsSheetName = None,
)

# - Parameters per vendor
DICT_VENDOR = dict(
nokia_sros=dict(
START_SCRIPT = "",
FIRST_LINE = "/environment no more\n",
FIRST_LINE = "",
LAST_LINE = "\nexit all\n",
FIN_SCRIPT = "#FINSCRIPT",
VERSION = "show version", # no \n in the end
Expand Down Expand Up @@ -135,6 +136,26 @@
SFTP_PORT = 22,
SFTP_REGEX_CF = r"(cf\d+:\/|cf\d+:)",
),
nokia_srl=dict(
START_SCRIPT = "",
FIRST_LINE = "",
LAST_LINE = "",
FIN_SCRIPT = "",
VERSION = "show version", # no \n in the end
VERSION_REGEX = "(v\d+.\d+.\d+)",
HOSTNAME = "show version", # no \n in the end
HOSTNAME_REGEX = "Hostname\s+:\s(\S+)",
HW_TYPE = "show version", # no \n in the end
HW_TYPE_REGEX = "Chassis Type\s+:\s(.+)",
SHOW = "",
SEND_CMD_REGEX = None,
MAJOR_ERROR_LIST = ["^FAILED:.+","^ERROR:.+","^Error:.+","invalid token","not allowed"],
MINOR_ERROR_LIST = ["^MINOR:.+"],
INFO_ERROR_LIST = ["^INFO:.+"],
REMOTE_PORT = 22,
SFTP_PORT = 22,
SFTP_REGEX_CF = r"(cf\d+:\/|cf\d+:)",
),
)

####
Expand Down Expand Up @@ -204,19 +225,22 @@ def fncPrintResults(listOfRouters, timeTotalStart, dictParam):
if dictParam['outputJob'] > 0:

timeTotalEnd = time.time()
timeTotal = timeTotalEnd - timeTotalStart

outTxt += f"{separator}\n"

df = pd.concat(LOG_GLOBAL)

timeTotal = fncFormatTime(timeTotalEnd - timeTotalStart)
timeMin = fncFormatTime(df["time"].min())
timeAvg = fncFormatTime(df["time"].mean())
timeMax = fncFormatTime(df["time"].max())

outTxt += f"\nTiming:\n"

outTxt += f' timeMin {fncFormatTime(df["time"].min())}\n'
outTxt += f' timeAvg: {fncFormatTime(df["time"].mean())}\n'
outTxt += f' timeMax: {fncFormatTime(df["time"].max())}\n'
outTxt += f' timeTotal: {fncFormatTime(timeTotal)}\n'
outTxt += f' timeTotal/totalRouters: {fncFormatTime(timeTotal/len(LOG_GLOBAL))}\n'
outTxt += f' timeMin {timeMin}\n'
outTxt += f' timeAvg: {timeAvg}\n'
outTxt += f' timeMax: {timeMax}\n'
outTxt += f' timeTotal: {timeTotal}\n'

outTxt += f"{separator}\n"

Expand Down Expand Up @@ -267,6 +291,11 @@ def fncPrintResults(listOfRouters, timeTotalStart, dictParam):
if len(dictParam['inventory']) > 0:
for ip in dictParam['inventory']:
dictParam['inventory'][ip]['password'] = '*****'
dictParam['timing'] = {}
dictParam['timing']['min'] = timeMin
dictParam['timing']['avg'] = timeAvg
dictParam['timing']['max'] = timeMax
dictParam['timing']['total'] = timeTotal
json.dump(dictParam, f)
f.close()

Expand Down Expand Up @@ -528,7 +557,7 @@ def verifyData(dictParam):
else:
useHeader = None

if dictParam['xlsSheetName'] == None:
if dictParam['xlsSheetName'] is None:

# We have CSV
try:
Expand Down Expand Up @@ -1786,7 +1815,7 @@ def getDictParam():
connGroup.add_argument('-th' ,'--threads' , type=int, help='Number of threads. Default=1', default=1,)
connGroup.add_argument('-tun','--sshTunnel', type=str, help='Use SSH Tunnel to routers. Default=yes', default='yes', choices=['no','yes'])
connGroup.add_argument('-jh' ,'--jumpHostsFile', type=str, help='jumpHosts file. Default=servers.yml', default='servers.yml')
connGroup.add_argument('-dt', '--deviceType', type=str, help='Device Type. Default=nokia_sros', default='nokia_sros', choices=['nokia_sros','md_nokia_sros','nokia_sros_telnet'])
connGroup.add_argument('-dt', '--deviceType', type=str, help='Device Type. Default=nokia_sros', default='nokia_sros', choices=['nokia_sros','nokia_sros_telnet','nokia_srl'])
connGroup.add_argument('-cv', '--cmdVerify', type=str, help='Enable --cmdVerify when interacting with router. Disable only if connection problems. Default=yes', default='yes', choices=['no','yes'])
connGroup.add_argument('-rto' ,'--readTimeOut', type=int, help='Read Timeout. Time in seconds which to wait for data from router. Default=10', default=10,)
connGroup.add_argument('-tbr' ,'--timeBetweenRouters', type=int, help='Time to wait between routers, in miliseconds (ms), before sending scripts to the router. Default=0', default=0,)
Expand Down

0 comments on commit b08d78c

Please sign in to comment.