5 from TestSite import TestSite
6 from TestNode import TestNode
10 def __init__ (self,plc_spec):
11 self.plc_spec=plc_spec
12 self.url="https://%s:443/PLCAPI/"%plc_spec['hostname']
13 self.server=xmlrpclib.Server(self.url,allow_none=True)
14 self.path=os.path.dirname(sys.argv[0])
17 # tricky : define les methodes de l'API sur cet object
21 return {'Username':self.plc_spec['PLC_ROOT_USER'],
22 'AuthMethod':'password',
23 'AuthString':self.plc_spec['PLC_ROOT_PASSWORD'],
24 'Role' : self.plc_spec['role']
26 def affiche_results(self, test_case_name, status, timers):
27 timers=datetime.datetime.now()
28 fileHandle = open (self.path+'/results.txt', 'a' )
29 fileHandle.write ( str(test_case_name)+' ' +str(status)+' '+str(timers))
34 def config_plc(self,plc_spec):
36 # now plc-config-tty silently creates needed directories
37 # os.system('mkdir -p /etc/planetlab/configs')
39 fileconf=open('tty_conf','w')
40 for var in [ 'PLC_NAME',
44 'PLC_MAIL_SUPPORT_ADDRESS',
51 fileconf.write ('e %s\n%s\n'%(var,plc_spec[var]))
55 os.system('set -x ; cat tty_conf')
56 os.system('set -x ; chroot /plc/root plc-config-tty < tty_conf')
57 os.system('set -x ; service plc start')
58 os.system('set -x; service sendmail stop')
59 os.system('set -x; chroot /plc/root service sendmail restart')
61 def cleanup_plc(self):
62 os.system('service plc safestop')
63 #####detecting the last myplc version installed and remove it
64 os.system('set -x; rpm -e myplc')
65 print "=======================>Remove Myplc DONE!"
66 ##### Clean up the /plc directory
67 os.system('set -x; rm -rf /plc/data')
68 print "=======================>Clean up DONE!"
70 def install_plc(self,url):
72 os.system('set -x; rpm -ivh '+url)
73 os.system('set -x; service plc mount')
75 def init_site (self,site_spec):
76 test_site = TestSite (self,site_spec)
77 test_site.create_site()
78 for key in site_spec['users']:
79 test_site.create_user(key)
80 test_site.enable_user(key)
81 test_site.add_key_user(key)
84 def init_node (self,test_site,node_spec,path):
86 test_node = TestNode(self, test_site, node_spec)
87 test_node.create_node ("pi")
88 test_node.create_node ("tech")
89 test_node.create_boot_cd(node_spec,path)
94 t=datetime.datetime.now()
96 dump='/var/lib/pgsql/backups/planetlab4-'+str(d)+'-2nodes'
97 os.system('chroot /plc/root pg_dump -U pgsqluser planetlab4 -f '+ dump)
98 print 'dump is done',dump