Skip to content

Commit

Permalink
Merge pull request #69 from laimaretto/devel
Browse files Browse the repository at this point in the history
8.0.5
  • Loading branch information
laimaretto authored Jun 23, 2023
2 parents 26e6a61 + e2c6ea4 commit 95b595e
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 25 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Versions #

## [8.0.5] - 2023-06-22

- The method `fncSshServer()` has been refactored. Better detection of problematic connections over ssh-tunnels.

## [8.0.4] - 2023-06-22

- The method `fncUploadFile()` decides between SCP or SFTP depending on the Timos version. If taskAutom cannot detect the Timos version, SCP will be selected.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

setup(
name='taskAutom',
version='8.0.4',
version='8.0.5',
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.4"
__version__ = "8.0.5"
__author__ = 'Lucas Aimaretto'
54 changes: 31 additions & 23 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.4'
LATEST_VERSION = '8.0.5'

# Constants
IP_LOCALHOST = "127.0.0.1"
Expand Down Expand Up @@ -1015,7 +1015,7 @@ def run(self):
if bool(self.connInfo['conn2rtr']) is True or self.connInfo['aluLogged'] is True:
self.connInfo['conn2rtr'].disconnect()

if self.connInfo['useSSHTunnel'] is True and bool(self.connInfo['sshServer']) == True:
if self.connInfo['useSSHTunnel'] is True and bool(self.connInfo['sshServer']) is True:
self.connInfo['sshServer'].stop(force=True)

# #
Expand Down Expand Up @@ -1294,9 +1294,9 @@ def sendFiles(sftp,ftpFiles):
def fncSshServer(self, connInfo, sftp=False):

controlPlaneAccess = False
localPort = -1
server = -1
aluLogReason = '-1'
localPort = None
server = None
aluLogReason = 'no-ssh-tunnel'

jumpHost = connInfo['jumpHost']
servers = connInfo['jumpHosts']
Expand Down Expand Up @@ -1324,37 +1324,45 @@ def fncSshServer(self, connInfo, sftp=False):

except Exception as e:

aluLogReason = str(e).replace('\n',' ')
server = -1
aluLogReason = "Problems creating SSH server: " + str(e).replace('\n',' ')
fncPrintConsole(connInfo['strConn'] + str(aluLogReason))
server.stop(force=True)
controlPlaneAccess = False
localPort = None
server = None

if server != -1:
if server is not None:

try:

server.start()
localPort = server.local_bind_port

fncPrintConsole(connInfo['strConn'] + "Trying sshServerTunnel on port: " + str(localPort))
except Exception as e:
fncPrintConsole(connInfo['strConn'] + "Trying sshServerTunnel on port: " + str(localPort))
fncPrintConsole(connInfo['strConn'] + "Trying router " + IP_LOCALHOST + ":" + str(localPort) + " -> " + connInfo['systemIP'] + ":" + str(connInfo['remotePort']))
aluLogReason = "Problems starting SSH server: " + str(e).replace('\n',' ')
fncPrintConsole(connInfo['strConn'] + aluLogReason)
server.stop(force=True)
controlPlaneAccess = False
localPort = None
server = None

if server is not None:

server.check_tunnels()
fncPrintConsole(connInfo['strConn'] + "Trying router " + IP_LOCALHOST + ":" + str(localPort) + " -> " + connInfo['systemIP'] + ":" + str(connInfo['remotePort']))

if server.tunnel_is_up[('0.0.0.0',localPort)] == False:
aluLogReason = 'SSH Error: Tunnel is not up.'
fncPrintConsole(connInfo['strConn'] + aluLogReason)
controlPlaneAccess = False
server.stop(force=True)
else:
controlPlaneAccess = True
server.check_tunnels()

except Exception as e:
#fncPrintConsole(e)
aluLogReason = "Problems starting the SSH tunnel."
if server.tunnel_is_up[('0.0.0.0',localPort)] is False:
aluLogReason = 'SSH Error: Tunnel is not up.'
fncPrintConsole(connInfo['strConn'] + aluLogReason)
controlPlaneAccess = False
server.stop(force=True)
controlPlaneAccess = False
localPort = None
server = None
else:
controlPlaneAccess = True



connInfo['aluLogReason'] = aluLogReason
connInfo['controlPlaneAccess'] = controlPlaneAccess
Expand Down

0 comments on commit 95b595e

Please sign in to comment.