4 from optparse import OptionParser
6 from TestPlc import TestPlc
7 from TestSite import TestSite
8 from TestNode import TestNode
13 subversion_id = "$Id: TestMain.py 767 2007-08-06 08:32:04Z amine $"
16 self.path=os.path.dirname(sys.argv[0])
20 usage = """usage: %prog [options] MyplcURL"""
21 parser=OptionParser(usage=usage,version=self.subversion_id)
23 parser.add_option("-v","--verbose", action="store_true", dest="verbose", default=False,
24 help="Run in verbose mode")
26 parser.add_option("-g","--debug", action="store", dest="debug",
27 help="Run in debug mode for eventual virtual problems")
29 parser.add_option("-d","--display", action="store", dest="Xterm", default='bellami:0.0',
30 help="export the display on the mentionneted one")
33 (self.options, self.args) = parser.parse_args()
41 print 'the myplc url is ',url
43 print "PLease introduce a right URL for the myplc instal"
46 if (self.options.Xterm):
47 display=self.options.Xterm
48 print 'the display is', display
50 if (self.options.debug):
51 file=self.path+'/'+self.options.debug+'/My_Virtual_Machine.vmx'
52 if os.path.exists(file):
53 print 'vmx file is',file
54 arg='< /dev/null &>/dev/null &'
55 os.system('DISPLAY=%s vmplayer %s %s '%(display,file,arg))
58 print "no way to find the virtual file"
66 timset=time.strftime("%H:%M:%S", time.localtime())
68 for plc_spec in TestConfig.plc_specs:
69 print '========>Creating plc at '+timset+':',plc_spec
70 test_plc = TestPlc(plc_spec)
72 test_plcs.append(test_plc)
73 test_plc.cleanup_plc()
74 print '========>Installing myplc at: ', timset
75 if (len(sys.argv) > 1):
76 test_plc.install_plc(url)
77 test_plc.config_plc(plc_spec)
79 print "========>PLease insert a valid url for the myplc install"
81 for site_spec in plc_spec['sites']:
82 print '========>Creating site at '+timset+ ':',site_spec
83 test_site = test_plc.init_site(site_spec)
85 for node_spec in site_spec['nodes']:
86 print '========>Creating node at '+ timset+' :',node_spec
87 test_nodes.append(node_spec)
88 test_node = test_plc.init_node(test_site,node_spec,self.path)
90 test_node.create_slice ("pi",test_nodes)
91 print 'Runing Checkers and Vmwares for Site nodes at :',timset
92 test_site.run_vmware(test_nodes,display)
93 if(test_site.node_check_status(test_nodes,True)):
95 test_site.slice_access(test_nodes)
96 print "all is alright"
100 print "There is something wrong"
107 if __name__ == "__main__":