32 lines
1.0 KiB
Python
32 lines
1.0 KiB
Python
import paramiko
|
|
import json
|
|
|
|
ssh = paramiko.SSHClient()
|
|
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
ssh.connect('161.97.93.156', username='carlos', password='Innova1978+*?')
|
|
|
|
payload = json.dumps({
|
|
"instanceName": "DripZone",
|
|
"token": "83B5BD230796-4324-AE73-3508F69E279D",
|
|
"qrcode": True,
|
|
"integration": "WHATSAPP-BAILEYS"
|
|
})
|
|
|
|
sftp = ssh.open_sftp()
|
|
with sftp.file('/tmp/create_instance.json', 'w') as f:
|
|
f.write(payload)
|
|
sftp.close()
|
|
|
|
cmd = "curl -s -X POST http://172.21.0.3:8080/instance/create -H 'apikey: c2JDrHn0T3QbfORAEmrlLJmgU1BpcKSD' -H 'Content-Type: application/json' -d @/tmp/create_instance.json"
|
|
stdin, stdout, stderr = ssh.exec_command(cmd)
|
|
res = stdout.read().decode('utf-8')
|
|
print("Create Instance Response:", res[:500])
|
|
|
|
# Ahora ver instancias
|
|
cmd2 = "curl -s http://172.21.0.3:8080/instance/fetchInstances -H 'apikey: c2JDrHn0T3QbfORAEmrlLJmgU1BpcKSD'"
|
|
stdin, stdout, stderr = ssh.exec_command(cmd2)
|
|
res2 = stdout.read().decode('utf-8')
|
|
print("Fetch Instances:", res2[:500])
|
|
|
|
ssh.close()
|