5 from optparse import OptionParser
9 from TestPlc import TestPlc
10 from TestSite import TestSite
11 from TestNode import TestNode
16 subversion_id = "$Id$"
19 self.path=os.path.dirname(sys.argv[0])
23 usage = """usage: %prog [options] [myplc-url]
24 myplc-url defaults to the last value used, as stored in URL"""
25 parser=OptionParser(usage=usage,version=self.subversion_id)
27 parser.add_option("-d","--display", action="store", dest="Xdisplay", default='bellami:0.0',
28 help="sets DISPLAY for vmplayer")
29 parser.add_option("-v","--verbose", action="store_true", dest="verbose", default=False,
30 help="Run in verbose mode")
31 parser.add_option("-r","--run", action="store", dest="run_node",
32 help="Only starts vmplayer for the specified node")
33 (self.options, self.args) = parser.parse_args()
40 #test the existence of the URL
41 if (len (self.args) > 2):
44 elif (len (self.args) == 1):
48 url_file=open("%s/URL"%self.path)
49 url=url_file.read().strip()
52 print "Cannot determine myplc url"
55 utils.header('* Using myplc at url : %s'%url)
56 #check where to display Virtual machines
57 if (self.options.Xdisplay):
58 display=self.options.Xdisplay
59 utils.header('X11 display : %s'% display)
61 if (self.options.run_node):
62 file=self.path+'/vmplayer-'+self.options.run_node+'/node.vmx'
63 if os.path.exists(file):
64 utils.header('starting vmplayer for node %s'%self.options.run_node)
65 os.system('DISPLAY=%s vmplayer %s '%(display,file))
68 utils.header ('File not found %s - exiting'%file)
71 utils.header('Saving current myplc url into URL')
72 fsave=open('%s/URL'%self.path,"w")
77 pp = pprint.PrettyPrinter(indent=4,depth=2)
78 for plc_spec in TestConfig.plc_specs:
79 utils.header('Creating plc with spec')
81 test_plc = TestPlc(plc_spec)
83 test_plcs.append(test_plc)
84 test_plc.cleanup_plc()
85 utils.header('Installing myplc from url %s'%url)
86 test_plc.install_plc(url)
87 test_plc.config_plc(plc_spec)
88 ##create all the sites under the new plc,and then populate them with
89 ##nodes,persons and slices(with initscripts)
90 for site_spec in plc_spec['sites']:
91 utils.header('Creating site')
93 test_site = test_plc.init_site(site_spec)
94 for node_spec in site_spec['nodes']:
95 utils.header('Creating node')
97 test_nodes.append(node_spec)
98 test_node = test_plc.init_node(test_site,node_spec,self.path)
99 test_node.add_initscripts()
100 test_node.create_slice ("pi")
101 utils.header('Starting vmware nodes')
102 test_site.run_vmware(test_nodes,display)
103 utils.header('Checking nodes')
104 if(test_site.node_check_status(test_nodes,True)):
106 test_site.slice_access()
107 print "System test successful"
110 print "System test failed"
116 if __name__ == "__main__":