5 from random import Random
6 from time import localtime
7 from qa.utils import commands
8 from qa.Config import Config
9 from qa.tests.vserver_create import vserver_create
10 from qa.tests.vserver_delete import vserver_delete
11 from qa.tests.plc_configure import plc_configure
12 from qa.tests.plc_start import plc_start
13 from qa.tests.add_test_data import add_test_data
14 from qa.tests.sync_person_key import sync_person_key
15 from qa.tests.boot_node import boot_node
16 from qa.tests.get_boot_state import get_boot_state
17 from qa.tests.node_remote_call import node_remote_call
18 from qa.tests.access_slice import access_slice
21 def randint(min = 0.0, max = 1.0):
22 return float(min) + (random.random() * (float(max) - float(min)))
24 # Determine vserver name, distribution and mailto
25 # The distribution and current date will be part of of the vserver name
27 VSERVER_HOME = '/vservers/'
28 VSERVER_BASENAME = 'plc'
30 SVNPATH='http://svn.planet-lab.org/svn/tests/trunk/'
32 YEAR, MONTH, DAY = [str(x) for x in localtime()[:3]]
33 DATE = ".".join([YEAR, MONTH, DAY])
35 TEST_VSERVER = VSERVER_BASENAME + "-"+ FCDISTRO + "-" + DATE
36 VSERVER_PATH = VSERVER_HOME +os.sep+ TEST_VSERVER
37 MAILTO = 'tmack@cs.princeton.edu'
43 config.load("qa/config.py")
44 config.plcs[PLCNAME]['vserver'] = TEST_VSERVER
45 config.plcs[PLCNAME]['ip'] = config.ip
46 config.plcs[PLCNAME]['api_path'] = ""
47 config.plcs[PLCNAME]['port'] = str(randint(49152, 65535))
48 config.plcs[PLCNAME].config.update_api(config.plcs[PLCNAME])
50 # create a vserer for this system test
51 vserver_create(config)(TEST_VSERVER, FCDISTRO, MAILTO)
53 # configure the plc in this vserver
54 plc_configure(config)(PLCNAME)
55 plc_start(config)(PLCNAME)
57 # Add test site, node, person and slice data
58 # Adds slice to node and person to slice
59 add_test_data(config)(PLCNAME)
60 person_email = config.persons.values()[0]['email']
61 sync_person_key(config)(person_email)
63 # Boot test node and confirm boot state
64 node_hostname = config.nodes.values()[0]['hostname']
65 boot_node(config)(node_hostname)
68 # only keep the newest MAX_VSERVERS
69 vserver_basepath = "%(VSERVER_HOME)s/%(VSERVER_BASENAME)s"
70 vservers = os.listdir("%(vserver_basepath)s*" % locals())
73 deleted_vservers = vservers[5:]
74 for vserver in deleted_vservers:
75 utils.header("Deleting vserver: %(vserver)s" % locals())
76 #vserver_delete()(vserver)