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 MYPLC-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 parser.add_option("-h","--help", action="store_true", dest="help", default=False,
34 help="Displays this message")
35 (self.options, self.args) = parser.parse_args()
45 #test the existence of the url
46 if (len (self.args) > 2):
49 elif (len (self.args) == 1):
53 url_file=open("%s/MYPLC-URL"%self.path)
54 url=url_file.read().strip()
57 print "Cannot determine myplc url"
60 utils.header('* Using myplc at url : %s'%url)
61 #check where to display Virtual machines
62 if (self.options.Xdisplay):
63 display=self.options.Xdisplay
64 utils.header('X11 display : %s'% display)
66 if (self.options.run_node):
67 file=self.path+'/vmplayer-'+self.options.run_node+'/node.vmx'
68 if os.path.exists(file):
69 utils.header('starting vmplayer for node %s'%self.options.run_node)
70 os.system('DISPLAY=%s vmplayer %s '%(display,file))
73 utils.header ('File not found %s - exiting'%file)
76 utils.header('Saving current myplc url into MYPLC-URL')
77 fsave=open('%s/MYPLC-URL'%self.path,"w")
82 pp = pprint.PrettyPrinter(indent=4,depth=2)
83 for plc_spec in TestConfig.plc_specs:
84 utils.header('Creating plc with spec')
86 test_plc = TestPlc(plc_spec)
88 test_plcs.append(test_plc)
89 test_plc.cleanup_plc()
90 utils.header('Installing myplc from url %s'%url)
91 test_plc.install_plc(url)
92 test_plc.config_plc(plc_spec)
93 ##create all the sites under the new plc,and then populate them with
94 ##nodes,persons and slices(with initscripts)
95 for site_spec in plc_spec['sites']:
96 utils.header('Creating site')
98 test_site = test_plc.init_site(site_spec)
99 for node_spec in site_spec['nodes']:
100 utils.header('Creating node')
102 test_nodes.append(node_spec)
103 test_node = test_plc.init_node(test_site,node_spec,self.path)
104 test_node.add_initscripts()
105 test_node.create_slice ("pi")
106 utils.header('Starting vmware nodes')
107 test_site.run_vmware(test_nodes,display)
108 utils.header('Checking nodes')
109 if(test_site.node_check_status(test_nodes,True)):
111 test_site.slice_access()
112 print "System test successful"
115 print "System test failed"
121 if __name__ == "__main__":