4 from optparse import OptionParser
5 from TestPlc import TestPlc
6 from TestSite import TestSite
7 from TestNode import TestNode
13 subversion_id = "$Id$"
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")
32 (self.options, self.args) = parser.parse_args()
39 timset=time.strftime("%H:%M:%S", time.localtime())
40 #test the existence of the URL
43 print 'the myplc url is ',url
45 print "PLease introduce a right URL for the myplc instal"
47 #check where to display Virtual machines
48 if (self.options.Xterm):
49 display=self.options.Xterm
50 print 'the display is', display
52 if (self.options.debug):
53 file=self.path+'/'+self.options.debug+'/My_Virtual_Machine.vmx'
54 if os.path.exists(file):
55 print 'vmx file is',file
56 arg='< /dev/null &>/dev/null &'
57 os.system('DISPLAY=%s vmplayer %s %s '%(display,file,arg))
60 print "no way to find the virtual file"
63 for plc_spec in TestConfig.plc_specs:
64 print '========>Creating plc at '+timset+':',plc_spec
65 test_plc = TestPlc(plc_spec)
67 test_plcs.append(test_plc)
68 test_plc.cleanup_plc()
69 print '========>Installing myplc at: ', timset
70 if (len(sys.argv) > 1):
71 test_plc.install_plc(url)
72 test_plc.config_plc(plc_spec)
74 print "========>PLease insert a valid url for the myplc install"
75 ##create all the sites under the new plc,and then populate them with
76 ##nodes,persons and slices
77 for site_spec in plc_spec['sites']:
78 print '========>Creating site at '+timset+ ':',site_spec
79 test_site = test_plc.init_site(site_spec)
80 for node_spec in site_spec['nodes']:
81 print '========>Creating node at '+ timset+' :',node_spec
82 test_nodes.append(node_spec)
83 test_node = test_plc.init_node(test_site,node_spec,self.path)
84 test_node.create_slice ("pi")
85 print 'Runing Checkers and Vmwares for Site nodes at :',timset
86 test_site.run_vmware(test_nodes,display)
87 if(test_site.node_check_status(test_nodes,True)):
89 test_site.slice_access(test_nodes)
90 print "all is alright"
93 print "There is something wrong"
99 if __name__ == "__main__":