22 |
|
|
23 |
""" |
""" |
24 |
################################################################### |
################################################################### |
25 |
# Es necesario hacer comparacion name in out y no al reves # |
# Checks name in out # |
26 |
# ya que salida devuelve hostname con \n y si no no se cumple cond# |
# because output includes hostname with \n and it fails otherwise# |
27 |
################################################################### |
################################################################### |
28 |
""" |
""" |
29 |
|
|
39 |
print name |
print name |
40 |
while name not in out and j<40: |
while name not in out and j<40: |
41 |
try: |
try: |
42 |
#print 'abro popen' |
#print 'open popen' |
43 |
fout = sub.Popen(cmd,bufsize=-1,shell=True,stdout=sub.PIPE, stderr=sub.STDOUT,close_fds=True) |
fout = sub.Popen(cmd,bufsize=-1,shell=True,stdout=sub.PIPE, stderr=sub.STDOUT,close_fds=True) |
44 |
#print 'salgo popen' |
#print 'exit popen' |
45 |
out,err =fout.communicate(input=None) |
out,err =fout.communicate(input=None) |
46 |
# print 'communicate' |
# print 'communicate' |
47 |
j = j + 1; |
j = j + 1; |
52 |
print 'Host not available', j |
print 'Host not available', j |
53 |
time.sleep(float(5)) |
time.sleep(float(5)) |
54 |
elif name not in out and j >= 40: |
elif name not in out and j >= 40: |
55 |
print 'Sobrepasado el numero de intentos. 40' |
print 'Number of trials exeeded. 40' |
56 |
if j < 40 and name in out: |
if j < 40 and name in out: |
57 |
print 'Host:', name, 'is ssh available', ip |
print 'Host:', name, 'is ssh available', ip |
58 |
|
|
80 |
print 'Host available', out, ip, j, err |
print 'Host available', out, ip, j, err |
81 |
time.sleep(float(5)) |
time.sleep(float(5)) |
82 |
elif name in out and j >= 40: |
elif name in out and j >= 40: |
83 |
print 'Sobrepasado el numero de intentos. 40' |
print 'Number of trials exceeded. 40' |
84 |
if j < 40 and name not in out: |
if j < 40 and name not in out: |
85 |
print 'Host:', name, 'is not ssh available', j |
print 'Host:', name, 'is not ssh available', j |
86 |
|
|
87 |
|
|
88 |
def ssh_qhost(ip): |
def ssh_qhost(ip): |
89 |
"Comprobacion del qhost" |
"Checking qhost" |
90 |
# |
# |
91 |
cmd = 'ssh -q '+ip+' qhost -xml' |
cmd = 'ssh -q '+ip+' qhost -xml' |
92 |
out='command not found' |
out='command not found' |
94 |
fout = sub.Popen(cmd,bufsize=-1,shell=True,stdout=sub.PIPE, stderr=sub.STDOUT) |
fout = sub.Popen(cmd,bufsize=-1,shell=True,stdout=sub.PIPE, stderr=sub.STDOUT) |
95 |
out,err =fout.communicate() |
out,err =fout.communicate() |
96 |
|
|
97 |
#print 'Salida qhost', out |
#print 'Exit qhost', out |
98 |
return out |
return out |
99 |
|
|
100 |
|
|
115 |
# config.parse(file1) |
# config.parse(file1) |
116 |
# o = config.lookup('ip') |
# o = config.lookup('ip') |
117 |
# print 'nada', o |
# print 'nada', o |
118 |
# #print 'Dame el passwd para la clave' |
# #print 'Give password:' |
119 |
# #passwd=input() |
# #passwd=input() |
120 |
# #print passwd |
# #print passwd |
121 |
# try: |
# try: |