1 #!/usr/bin/env python -u
5 from optparse import OptionParser
6 from TestPlc import TestPlc
7 from TestSite import TestSite
8 from TestNode import TestNode
14 subversion_id = "$Id$"
17 self.path=os.path.dirname(sys.argv[0])
21 usage = """usage: %prog [options] [myplc-url]
22 myplc-url defaults to the last value used, as stored in URL"""
23 parser=OptionParser(usage=usage,version=self.subversion_id)
25 parser.add_option("-v","--verbose", action="store_true", dest="verbose", default=False,
26 help="Run in verbose mode")
28 parser.add_option("-g","--debug", action="store", dest="debug",
29 help="Run in debug mode for eventual virtual problems")
31 parser.add_option("-d","--display", action="store", dest="Xterm", default='bellami:0.0',
32 help="export the display on the mentionneted one")
34 (self.options, self.args) = parser.parse_args()
41 timset=time.strftime("%H:%M:%S", time.localtime())
42 #test the existence of the URL
43 if (len (self.args) > 2):
46 elif (len (self.args) == 1):
50 url=open("%s/URL"%self.path)
51 url=url_file.read().strip()
54 print "Cannot determine myplc url"
57 print '* Using myplc url:',url
58 #check where to display Virtual machines
59 if (self.options.Xterm):
60 display=self.options.Xterm
61 print 'the display is', display
63 if (self.options.debug):
64 file=self.path+'/'+self.options.debug+'/My_Virtual_Machine.vmx'
65 if os.path.exists(file):
66 print 'vmx file is',file
67 arg='< /dev/null &>/dev/null &'
68 os.system('DISPLAY=%s vmplayer %s %s '%(display,file,arg))
71 print "no way to find the virtual file"
74 print 'Saving myplc url into URL'
75 fsave=open('%s/URL'%self.path,"w")
80 for plc_spec in TestConfig.plc_specs:
81 print '========>Creating plc at '+timset+':',plc_spec
82 test_plc = TestPlc(plc_spec)
84 test_plcs.append(test_plc)
85 test_plc.cleanup_plc()
86 print '========>Installing myplc at: ', timset
87 if (len(sys.argv) > 1):
88 test_plc.install_plc(url)
89 test_plc.config_plc(plc_spec)
91 print "========>PLease insert a valid url for the myplc install"
92 ##create all the sites under the new plc,and then populate them with
93 ##nodes,persons and slices
94 for site_spec in plc_spec['sites']:
95 print '========>Creating site at '+timset+ ':',site_spec
96 test_site = test_plc.init_site(site_spec)
97 for node_spec in site_spec['nodes']:
98 print '========>Creating node at '+ timset+' :',node_spec
99 test_nodes.append(node_spec)
100 test_node = test_plc.init_node(test_site,node_spec,self.path)
101 test_node.create_slice ("pi")
102 print 'Runing Checkers and Vmwares for Site nodes at :',timset
103 test_site.run_vmware(test_nodes,display)
104 if(test_site.node_check_status(test_nodes,True)):
106 test_site.slice_access(test_nodes)
107 print "all is alright"
110 print "There is something wrong"
116 if __name__ == "__main__":