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("-v","--verbose", action="store_true", dest="verbose", default=False,
28 help="Run in verbose mode")
30 parser.add_option("-g","--debug", action="store", dest="debug",
31 help="Run in debug mode for eventual virtual problems")
33 parser.add_option("-d","--display", action="store", dest="Xterm", default='bellami:0.0',
34 help="sets DISPLAY for vmplayer")
36 (self.options, self.args) = parser.parse_args()
43 #test the existence of the URL
44 if (len (self.args) > 2):
47 elif (len (self.args) == 1):
51 url_file=open("%s/URL"%self.path)
52 url=url_file.read().strip()
55 print "Cannot determine myplc url"
58 utils.header('* Using myplc at url : %s'%url)
59 #check where to display Virtual machines
60 if (self.options.Xterm):
61 display=self.options.Xterm
62 utils.header('X11 display : %s'% display)
64 if (self.options.debug):
65 file=self.path+'/'+self.options.debug+'/node.vmx'
66 if os.path.exists(file):
67 print 'vmx file is',file
68 arg='< /dev/null &>/dev/null &'
69 os.system('DISPLAY=%s vmplayer %s %s '%(display,file,arg))
72 print "no way to find the virtual file"
75 utils.header('Saving current myplc url into URL')
76 fsave=open('%s/URL'%self.path,"w")
81 pp = pprint.PrettyPrinter(indent=4,depth=2)
82 for plc_spec in TestConfig.plc_specs:
83 utils.header('Creating plc with spec')
85 test_plc = TestPlc(plc_spec)
87 test_plcs.append(test_plc)
88 test_plc.cleanup_plc()
89 utils.header('Installing myplc from url %s'%url)
90 test_plc.install_plc(url)
91 test_plc.config_plc(plc_spec)
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 utils.header('Creating site')
97 test_site = test_plc.init_site(site_spec)
98 for node_spec in site_spec['nodes']:
99 utils.header('Creating node')
101 test_nodes.append(node_spec)
102 test_node = test_plc.init_node(test_site,node_spec,self.path)
103 test_node.create_slice ("pi")
104 utils.header('Starting vmware nodes')
105 test_site.run_vmware(test_nodes,display)
106 utils.header('Checking nodes')
107 if(test_site.node_check_status(test_nodes,True)):
109 test_site.slice_access()
110 print "System test successful"
113 print "System test failed"
119 if __name__ == "__main__":