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