Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 49 lines (42 sloc) 1.508 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
f3cd495 @buzztroll breaking out the image name from the image location
buzztroll authored
8 tst_image_name = os.environ['NIMBUS_TEST_IMAGE']
9 tst_image_src = os.environ['NIMBUS_SOURCE_TEST_IMAGE']
899db05 @buzztroll this time remembering to quote the env
buzztroll authored
10 to=int(os.environ["NIMBUS_TEST_TIMEOUT"])
b03dfd9 Adding two more tests
BuzzTroll authored
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
f3cd495 @buzztroll breaking out the image name from the image location
buzztroll authored
16 cmd = "%s/bin/nimbus-public-image %s %s" % (nh, tst_image_src, common_image)
b03dfd9 Adding two more tests
BuzzTroll authored
17 (x, rc)=pexpect.run(cmd, withexitstatus=1, logfile=logfile)
18 if rc != 0:
19 print "failed create the public image"
20 sys.exit(1)
21
22 for i in range(0, 2):
23 cmd = "%s/bin/cloud-client.sh --run --name %s --hours .25" % (cc_home, common_image)
24 child = pexpect.spawn (cmd, timeout=to, maxread=20000, logfile=logfile)
25 rc = child.expect ('Running:')
26 if rc != 0:
27 print "run failed on try %d" % (i)
28 sys.exit(1)
29 handle = child.readline().strip().replace("'", "")
30 rc = child.expect(pexpect.EOF)
31 if rc != 0:
32 print "run"
33 sys.exit(1)
34
35 cmd = "%s/bin/cloud-client.sh --terminate --handle %s" % (cc_home, handle)
36 print cmd
37 (x, rc)=pexpect.run(cmd, withexitstatus=1, logfile=logfile, timeout=to)
38 print x
39 if rc != 0:
40 print "failed to terminate %s on try %d" % (handle, i)
41 sys.exit(1)
42
43 cmd = "%s/bin/nimbus-public-image --delete %s" % (nh, common_image)
44 (x, rc)=pexpect.run(cmd, withexitstatus=1, logfile=logfile)
45 if rc != 0:
46 print "failed create the public image"
47 sys.exit(1)
48 sys.exit(0)
Something went wrong with that request. Please try again.