Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 67 lines (57 sloc) 1.829 kB
b03dfd9 Adding two more tests
BuzzTroll authored
1 #!/usr/bin/env python
2
3 import pexpect
4 import sys
5 import os
6 import uuid
7
8 to=90
9 cc_home=os.environ['CLOUD_CLIENT_HOME']
10 nh=os.environ['NIMBUS_HOME']
11 logfile = sys.stdout
12 common_image = str(uuid.uuid1()).replace("-", "")
13
14 cmd = "%s/bin/nimbus-public-image /etc/group %s" % (nh, common_image)
15 (x, rc)=pexpect.run(cmd, withexitstatus=1, logfile=logfile)
16 if rc != 0:
17 print "failed create the public image"
18 sys.exit(1)
19
20 cmd = "%s/bin/cloud-client.sh --run --name %s --hours .25" % (cc_home, common_image)
21 child = pexpect.spawn (cmd, timeout=to, maxread=20000, logfile=logfile)
22 rc = child.expect ('Running:')
23 if rc != 0:
24 print "group not found in the list"
25 sys.exit(1)
26 handle = child.readline().strip().replace("'", "")
27 rc = child.expect(pexpect.EOF)
28 if rc != 0:
29 print "run"
30 sys.exit(1)
31
32 cmd = "%s/bin/cloud-client.sh --handle %s --save" % (cc_home, handle)
33 print cmd
34 (x, rc)=pexpect.run(cmd, withexitstatus=1, logfile=logfile)
35 print x
36 if rc != 0:
37 print "failed to save"
38 sys.exit(1)
39
40
41 cmd = "%s/bin/cloud-client.sh --run --name %s --hours .25" % (cc_home, common_image)
42 child = pexpect.spawn (cmd, timeout=to, maxread=20000, logfile=logfile)
43 rc = child.expect ('Running:')
44 if rc != 0:
45 print "group not found in the list"
46 sys.exit(1)
47 handle = child.readline().strip().replace("'", "")
48 rc = child.expect(pexpect.EOF)
49 if rc != 0:
50 print "run"
51 sys.exit(1)
52 cmd = "%s/bin/cloud-client.sh --terminate --handle %s" % (cc_home, handle)
53 print cmd
54 (x, rc)=pexpect.run(cmd, withexitstatus=1, timeout=to, logfile=logfile)
55 print x
56 if rc != 0:
57 print "failed to terminate"
58 sys.exit(1)
59
60
61 cmd = "%s/bin/nimbus-public-image --delete %s" % (nh, common_image)
62 (x, rc)=pexpect.run(cmd, withexitstatus=1, logfile=logfile)
63 if rc != 0:
64 print "failed create the public image"
65 sys.exit(1)
66 sys.exit(0)
Something went wrong with that request. Please try again.