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)+'\t' +str(status)+'\t'+str(timers)+'\n')
34 def config_plc(self,plc_spec):
35 tmpname='/tmp/plc-config-tty-%d'%os.getpid()
36 fileconf=open(tmpname,'w')
37 for var in [ 'PLC_NAME',
41 'PLC_MAIL_SUPPORT_ADDRESS',
48 fileconf.write ('e %s\n%s\n'%(var,plc_spec[var]))
52 os.system('set -x ; cat %s'%tmpname)
53 os.system('set -x ; chroot /plc/root plc-config-tty < %s'%tmpname)
54 os.system('set -x ; service plc start')
55 os.system('set -x; service sendmail stop')
56 os.system('set -x; chroot /plc/root service sendmail restart')
57 os.system('set -x; rm %s'%tmpname)
59 def cleanup_plc(self):
60 os.system('set -x; service plc safestop')
61 #####detecting the last myplc version installed and remove it
62 os.system('set -x; rpm -e myplc')
63 ##### Clean up the /plc directory
64 os.system('set -x; rm -rf /plc/data')
66 def install_plc(self,url):
67 os.system('set -x; rpm -Uvh '+url)
68 os.system('set -x; service plc mount')
70 def init_site (self,site_spec):
71 test_site = TestSite (self,site_spec)
72 test_site.create_site()
73 for key in site_spec['users']:
74 test_site.create_user(key)
75 test_site.enable_user(key)
76 test_site.add_key_user(key)
79 def init_node (self,test_site,node_spec,path):
81 test_node = TestNode(self, test_site, node_spec)
82 test_node.create_node ("pi")
83 test_node.create_node ("tech")
84 test_node.create_boot_cd(path)
89 t=datetime.datetime.now()
91 dump='/var/lib/pgsql/backups/planetlab4-'+str(d)+'-2nodes'
92 os.system('chroot /plc/root pg_dump -U pgsqluser planetlab4 -f '+ dump)
93 print 'dump is done',dump