Skip to content
This repository
Newer
Older
100755 84 lines (71 sloc) 2.214 kb
a389f8c7 »
2010-11-04 after translating the unprop name from common space to user space we …
1 #!/usr/bin/env python
2
3 import pexpect
4 import sys
5 import os
6 import uuid
7
f3cd4956 »
2011-06-13 breaking out the image name from the image location
8 tst_image_name = os.environ['NIMBUS_TEST_IMAGE']
9 tst_image_src = os.environ['NIMBUS_SOURCE_TEST_IMAGE']
899db051 »
2011-06-13 this time remembering to quote the env
10 to=int(os.environ["NIMBUS_TEST_TIMEOUT"])
a389f8c7 »
2010-11-04 after translating the unprop name from common space to user space we …
11 cc_home=os.environ['CLOUD_CLIENT_HOME']
12 nh=os.environ['NIMBUS_HOME']
13 logfile = sys.stdout
14 common_image = str(uuid.uuid1()).replace("-", "")
15
f3cd4956 »
2011-06-13 breaking out the image name from the image location
16 src_file = tst_image_src
a389f8c7 »
2010-11-04 after translating the unprop name from common space to user space we …
17 sfa = src_file.split("/")
18 image_name = sfa[len(sfa) - 1]
19 size=os.path.getsize(src_file)
20
21 cmd = "%s/bin/nimbus-public-image %s %s" % (nh, src_file, common_image)
22 (x, rc)=pexpect.run(cmd, withexitstatus=1, logfile=logfile)
23 if rc != 0:
24 print "failed create the public image"
25 sys.exit(1)
26
888af830 »
2011-11-29 increasing the submission time for real tests
27 cmd = "%s/bin/cloud-client.sh --run --name %s --hours .5" % (cc_home, common_image)
9c735f41 »
2011-11-21 using the image determined by env
28 child = pexpect.spawn (cmd, timeout=to, maxread=20000, logfile=logfile)
a389f8c7 »
2010-11-04 after translating the unprop name from common space to user space we …
29 rc = child.expect ('Running:')
30 if rc != 0:
d7716350 »
2011-06-13 removing harded references to group
31 print "Running not found in the list"
a389f8c7 »
2010-11-04 after translating the unprop name from common space to user space we …
32 sys.exit(1)
33 handle = child.readline().strip().replace("'", "")
34 rc = child.expect(pexpect.EOF)
35 if rc != 0:
36 print "run"
37 sys.exit(1)
38
39 cmd = "%s/bin/cloud-client.sh --save --handle %s" % (cc_home, handle)
40 print cmd
9921a92b »
2011-11-21 adding timeouts to tests
41 (x, rc)=pexpect.run(cmd, withexitstatus=1, logfile=logfile, timeout=to)
a389f8c7 »
2010-11-04 after translating the unprop name from common space to user space we …
42 print x
43 if rc != 0:
44 print "failed to terminate"
45 sys.exit(1)
46
47 # check the various params
48 cmd = "%s/bin/cloud-client.sh --list" % (cc_home)
49 child = pexpect.spawn (cmd, timeout=to, maxread=20000, logfile=logfile)
50 rc = child.expect (common_image)
51 if rc != 0:
52 print "%s not found in the list" % (common_image)
53 sys.exit(1)
54
55 line = child.readline()
56 print line
57 line = child.readline()
58 print line
59 token = "Size: "
60 ndx = line.find(token)
61 if ndx < 0:
62 print "%s not found in line %s" % (token, line)
63 sys.exit(1)
64 line = line[ndx + len(token):]
65 ndx = line.find(" ")
66 if ndx < 0:
67 print "%s ndx space not found %s" % (token, line)
68 sys.exit(1)
69 line = line[0:ndx].strip()
70
71 show_size = int(line)
72
73 if show_size != size:
74 print "%d != %d" % (show_size, size)
75 sys.exit(1)
76
77
78 cmd = "%s/bin/nimbus-public-image --delete %s" % (nh, common_image)
79 (x, rc)=pexpect.run(cmd, withexitstatus=1, logfile=logfile)
80 if rc != 0:
81 print "failed create the public image"
82 sys.exit(1)
83 sys.exit(0)
Something went wrong with that request. Please try again.