Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def connect(serv_ip, serv_port,
- serv_ssh_username,
- serv_ssh_password,
- radio_module_ip,
- radio_module_port=2323,
- host_ip='127.0.0.1',
- host_port=10022):
- def decorator(f):
- def wrapper():
- with SSHTunnelForwarder(
- (serv_ip, int(serv_port)),
- ssh_username=serv_ssh_username,
- ssh_password=serv_ssh_password,
- remote_bind_address=(radio_module_ip, int(radio_module_port)),
- local_bind_address=(host_ip, int(host_port)),
- # for debugging purposes:
- # logger=create_logger(loglevel=1),
- ):
- with TelnetClient(host_ip, int(host_port)) as telnet:
- f(telnet)
- return wrapper
- return decorator
- from server import Server
- class SystemModule(object):
- def __init__(self, server, username, password, hostname):
- self.server = server
- self.hostname = hostname
- self.username = username
- self.password = password
- @connect(
- serv_ip=???,
- serv_port=???,
- serv_ssh_username=???,
- serv_ssh_password=???,
- radio_module_ip=???,
- )
- def do_some_stuff(self, connection):
- #doing stuff
Add Comment
Please, Sign In to add comment