-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcomp_setup.py
executable file
·58 lines (52 loc) · 1.45 KB
/
comp_setup.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
52
53
54
55
56
57
58
#!/usr/bin/env python
# coding: utf-8
import os
import sys
import ssh
import subprocess
import time
def main(co):
count = 1024
time.sleep(300);
while(count):
p = subprocess.Popen(('nc -z {0} 22'.format(co)).split(),
shell=False,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stdout, stderr = p.communicate()
count -= 1;
r = p.wait();
print str(r)
if r != 0:
print "pinging failed, trying, " + str(count) + " left"
time.sleep(2)
continue
else :
break;
else:
print "connecting failed"
exit(-1)
s = ssh.Connection(host=co,username="stack",password="vai12345",port=22)
s.put('cache/stack.tar.gz')
s.put('cache/devstack.tar.gz')
s.put('cache/pip.tar.gz')
s.put('imroot')
s.put('localrc_compute')
s.put('start_compute.sh')
s.put('ssh.tar.gz')
s.execute("chmod +x imroot");
o = s.execute('echo vai12345 | /home/stack/imroot')
#print o
s.execute("chmod +x start_compute.sh")
o = s.execute('/home/stack/start_compute.sh')
for l in o:
print l.rstrip()
x = open("HOSTADDR").readline().rstrip();
if x:
o = s.execute("sudo mount -t nfs {0}:/srv/instances /opt/stack/nova/instances".format(x))
if(o):
print("mount errro");
s.close()
if __name__ == '__main__':
main(sys.argv[1])
sys.exit(0)