Guest User

Untitled

a guest
Oct 16th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. def connect(serv_ip, serv_port,
  2. serv_ssh_username,
  3. serv_ssh_password,
  4. radio_module_ip,
  5. radio_module_port=2323,
  6. host_ip='127.0.0.1',
  7. host_port=10022):
  8. def decorator(f):
  9. def wrapper():
  10. with SSHTunnelForwarder(
  11. (serv_ip, int(serv_port)),
  12. ssh_username=serv_ssh_username,
  13. ssh_password=serv_ssh_password,
  14. remote_bind_address=(radio_module_ip, int(radio_module_port)),
  15. local_bind_address=(host_ip, int(host_port)),
  16. # for debugging purposes:
  17. # logger=create_logger(loglevel=1),
  18. ):
  19. with TelnetClient(host_ip, int(host_port)) as telnet:
  20. f(telnet)
  21. return wrapper
  22. return decorator
  23.  
  24. from server import Server
  25.  
  26. class SystemModule(object):
  27. def __init__(self, server, username, password, hostname):
  28. self.server = server
  29. self.hostname = hostname
  30. self.username = username
  31. self.password = password
  32.  
  33. @connect(
  34. serv_ip=???,
  35. serv_port=???,
  36. serv_ssh_username=???,
  37. serv_ssh_password=???,
  38. radio_module_ip=???,
  39. )
  40. def do_some_stuff(self, connection):
  41. #doing stuff
Add Comment
Please, Sign In to add comment