-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathsetInform.py
executable file
·51 lines (39 loc) · 1.64 KB
/
setInform.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/python
# -------------------------------------------------------------------------------
# "THE BEER-WARE LICENSE" (Revision 42):
# <[email protected]> wrote this script. As long as you retain this notice you
# can do whatever you want with this stuff. If we meet some day, and you think
# this stuff is worth it, you can buy me a beer in return.
#
# - Patrick Kerwood @ LinuxBloggen.dk
# -------------------------------------------------------------------------------
import paramiko
informAddr = "http://controller-ip:8080/inform"
sshUser = "admin"
sshPass = "passw0rd"
clients = [
'10.0.0.10',
'10.0.0.11',
'10.0.0.12',
]
class bcolors:
OKGREEN = '\033[92m'
FAIL = '\033[91m'
ENDC = '\033[0m'
print "\nConnecting to devices....\n"
for ip in clients:
try:
client = paramiko.SSHClient()
client.load_system_host_keys()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(ip, username=sshUser, password=sshPass, allow_agent=False)
stdin, stdout, stderr = client.exec_command("mca-cli <<EOF\nset-inform %s\nquit\nEOF" % informAddr)
if stdout.channel.recv_exit_status() == 0:
for line in stdout:
if "Adoption request sent to" in line:
print " %s[+] Adoption request sent to %s from %s %s" % (bcolors.OKGREEN, informAddr, ip, bcolors.ENDC)
except paramiko.AuthenticationException:
print " %s[-] Authentication failed on %s!%s" % (bcolors.FAIL, ip, bcolors.ENDC)
except:
print " %s[-]Something went wrong on %s!%s" % (bcolors.FAIL, ip, bcolors.ENDC)
print