from pathlib import Path
import importlib.resources
from glaciation.helper import SSHHelper
import glaciation.devices as devices
LIB_PATH = importlib.resources.path(devices, "keys").args[0]
TSW_MIRROR_KEY = str(Path(LIB_PATH)) + "./ssh/sin_pass/project/project"
[docs]def clearTSWMirror(ip):
"""Function to disable all connection between TSWs
Parameters
----------
ip : string
ip address of magic tsw
"""
disabled_algorithms = dict(pubkeys=['rsa-sha2-256', 'rsa-sha2-512'])
ssh = SSHHelper(ip, "root", TSW_MIRROR_KEY, disAlgorithms=disabled_algorithms)
ssh.runCommand("mirroring delall")
ssh.close()
[docs]def TSWMirror(ip, P1, P2, bridge):
"""Function to disable link between 2 TSWs
Parameters
----------
ip : string
ip address of tsw
P1 : string
port of tsw. Options (X1,X2,X3,X4,La1,Lb1,La2,Lb2)
P2 : string
port of tsw. Options (X1,X2,X3,X4,La1,Lb1,La2,Lb2)
bridge: int
number os bridge to link 2 ports. Options (1,2,3)
"""
disabled_algorithms = dict(pubkeys=['rsa-sha2-256', 'rsa-sha2-512'])
ssh = SSHHelper(ip, "root", TSW_MIRROR_KEY, disAlgorithms=disabled_algorithms)
ssh.runCommand("mirroring add " + P1 + " " + P2 + " " + str(bridge))
ssh.close()
[docs]def TSWDisableMirror(ip, P1, P2, bridge):
"""Function to disable link between 2 TSWs
Parameters
----------
ip : string
ip address of tsw
P1 : string
port of tsw. Options (X1,X2,X3,X4,La1,Lb1,La2,Lb2)
P2 : string
port of tsw. Options (X1,X2,X3,X4,La1,Lb1,La2,Lb2)
bridge: int
number os bridge to link 2 ports. Options (1,2,3)
"""
disabled_algorithms = dict(pubkeys=['rsa-sha2-256', 'rsa-sha2-512'])
ssh = SSHHelper(ip, "root", TSW_MIRROR_KEY, disAlgorithms=disabled_algorithms)
ssh.runCommand("mirroring del " + P1 + " " + P2 + " " + str(bridge))
ssh.close()
[docs]def checkIsmaelLogs(ip):
"""
Function get ismael logs from a TSW
Parameters
----------
ip : string
ip address of tsw
"""
ssh = SSHHelper(ip, "project", TSW_MIRROR_KEY)
logs = ssh.runCommand("tail -80 /tmp/log/Ismael_etb.log")
ssh.close()
return logs