Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 82 lines (69 sloc) 2.06 kB
a389f8c after translating the unprop name from common space to user space we …
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 src_file = "/etc/group"
15 sfa = src_file.split("/")
16 image_name = sfa[len(sfa) - 1]
17 size=os.path.getsize(src_file)
18
19 cmd = "%s/bin/nimbus-public-image %s %s" % (nh, src_file, common_image)
20 (x, rc)=pexpect.run(cmd, withexitstatus=1, logfile=logfile)
21 if rc != 0:
22 print "failed create the public image"
23 sys.exit(1)
24
25 cmd = "%s/bin/cloud-client.sh --run --name %s --hours .25" % (cc_home, common_image)
26 child = pexpect.spawn (cmd, timeout=to, maxread=20000, logfile=logfile)
27 rc = child.expect ('Running:')
28 if rc != 0:
29 print "group not found in the list"
30 sys.exit(1)
31 handle = child.readline().strip().replace("'", "")
32 rc = child.expect(pexpect.EOF)
33 if rc != 0:
34 print "run"
35 sys.exit(1)
36
37 cmd = "%s/bin/cloud-client.sh --save --handle %s" % (cc_home, handle)
38 print cmd
39 (x, rc)=pexpect.run(cmd, withexitstatus=1, logfile=logfile)
40 print x
41 if rc != 0:
42 print "failed to terminate"
43 sys.exit(1)
44
45 # check the various params
46 cmd = "%s/bin/cloud-client.sh --list" % (cc_home)
47 child = pexpect.spawn (cmd, timeout=to, maxread=20000, logfile=logfile)
48 rc = child.expect (common_image)
49 if rc != 0:
50 print "%s not found in the list" % (common_image)
51 sys.exit(1)
52
53 line = child.readline()
54 print line
55 line = child.readline()
56 print line
57 token = "Size: "
58 ndx = line.find(token)
59 if ndx < 0:
60 print "%s not found in line %s" % (token, line)
61 sys.exit(1)
62 line = line[ndx + len(token):]
63 ndx = line.find(" ")
64 if ndx < 0:
65 print "%s ndx space not found %s" % (token, line)
66 sys.exit(1)
67 line = line[0:ndx].strip()
68
69 show_size = int(line)
70
71 if show_size != size:
72 print "%d != %d" % (show_size, size)
73 sys.exit(1)
74
75
76 cmd = "%s/bin/nimbus-public-image --delete %s" % (nh, common_image)
77 (x, rc)=pexpect.run(cmd, withexitstatus=1, logfile=logfile)
78 if rc != 0:
79 print "failed create the public image"
80 sys.exit(1)
81 sys.exit(0)
Something went wrong with that request. Please try again.