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 display_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('set -x; service plc safestop')
66 #####detecting the last myplc version installed and remove it
67 os.system('set -x; rpm -e myplc')
68 ##### Clean up the /plc directory
69 os.system('set -x; rm -rf /plc/data')
71 def install_plc(self,url):
72 os.system('set -x; rpm -Uvh '+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(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