Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. def conecta(_usuario="",_password="",_IP="",_puerto=""):
  2. conexion=False
  3. intentos=3
  4. while not conexion and intentos>0:
  5. #Pedir usuario
  6. if len(_usuario)==0:
  7. usuario=raw_input("Usuario: (Dejarlo vacio para salir) ")
  8. if len(usuario)==0:
  9. print("Saliendo...")
  10. break
  11. else:
  12. usuario=_usuario
  13.  
  14. #Pedir contraseña
  15. if len(_password)==0:
  16. password=raw_input("Password: ")
  17. else:
  18. password=_password
  19.  
  20. #Pedir IP admin, por defecto localhost
  21. if len(_IP)==0:
  22. IP=raw_input("IP[localhost]: ")
  23. if len(IP) == 0:
  24. IP="localhost"
  25. else:
  26. IP=_IP
  27.  
  28. #Pedir puerto conexión, por defecto 7001
  29. if len(_puerto)==0:
  30. puerto=raw_input("Puerto[7001]: ")
  31. if len(puerto) == 0:
  32. puerto="7001"
  33. else:
  34. puerto=_puerto
  35.  
  36. #Hacer conexión
  37. print("Realizando conexion")
  38. try:
  39. intentos-=1
  40. connect(usuario,password,"t3://"+IP+":"+puerto)
  41. print("Realizada conexion con exito")
  42. conexion=True
  43. except:
  44. print("Problemas en la conexion")
  45. return conexion
  46.  
  47.  
  48. conectado=conecta(_usuario="Admin",_password="password1",_IP="192.168.1.230",_puerto="7001")
  49. if conectado:
  50. domainRuntime()
  51. servidores=domainRuntimeService.getServerRuntimes()
  52. for servidor in servidores:
  53. if servidor.getName()=="inst3":
  54. try:
  55. servidor.shutdown()
  56. except:
  57. print("Quizas esté ya parado")
  58.  
  59. serverConfig()
  60. edit()
  61. startEdit()
  62. servidores=cmo.getServers()
  63. for servidor in servidores:
  64. print servidor
  65. if servidor.getName()=="inst3":
  66. puerto=servidor.getListenPort()
  67. puerto+=10
  68. servidor.setListenPort(puerto)
  69. save()
  70. activate(block="true")
  71.  
  72. #domainRuntime()
  73. #servidores=domainRuntimeService.getServerRuntimes()
  74. for servidor in servidores:
  75. if servidor.getName()=="inst3":
  76. print("Carlos, trata de arrancarlo")
  77. start(servidor.getName())
  78. disconnect()
  79. else:
  80. print("No estoy conectado")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement