- for slicespec in TestConfig.slices_specs :
- utils.header('Creating Slice')
- pp = pprint.PrettyPrinter(indent=4)
- pp.pprint(slicespec)
- slice_id=self.test_plc.server.AddSlice(auth,slicespec['slice_spec'])
- for sliceuser in slicespec['slice_users']:
- self.test_plc.server.AddPersonToSlice(auth,
- sliceuser['email'],
- slice_id)
- for slicenode in slicespec['slice_nodes']:
- liste_hosts.append(slicenode['hostname'])
- self.test_plc.server.AddSliceToNodes(auth,
- slice_id,
- liste_hosts)
-
- self.test_plc.server.AddSliceAttribute(self.test_plc.auth_root(),
- slice_id, 'initscript',
- slicespec['slice_initscript']['name'])
+ ownername = self.node_spec['owner']
+ user_spec = self.test_site.locate_user(ownername)
+ test_user = TestUser(self.test_plc,self.test_site,user_spec)
+ auth = test_user.auth()
+ except:
+ auth=self.test_plc.auth_root()
+ self.test_plc.apiserver.DeleteNode(auth,self.name())
+
+ # Do most of the stuff locally - will be pushed on host_box - *not* the plc - later if needed
+ def qemu_local_init(self):
+ utils.system("rm -rf %s"%self.nodedir())
+ utils.system("mkdir %s"%self.nodedir())
+ if not self.is_qemu():
+ return True
+ return utils.system("rsync -v -a --exclude .svn template-qemu/ %s/"%self.nodedir())==0
+
+ def bootcd(self):
+ utils.header("Calling GetBootMedium for %s"%self.name())
+ options = []
+ if self.is_qemu():
+ options.append('serial')
+ options.append('no-hangcheck')
+ encoded=self.test_plc.apiserver.GetBootMedium(self.test_plc.auth_root(),
+ self.name(), 'node-iso', '', options)
+ if (encoded == ''):
+ raise Exception, 'GetBootmedium failed'
+
+ filename="%s/%s.iso"%(self.nodedir(),self.name())
+ utils.header('Storing boot medium into %s'%filename)
+ if self.test_plc.options.dry_run:
+ print "Dry_run: skipped writing of iso image"
+ return True
+ else:
+ file(filename,'w').write(base64.b64decode(encoded))
+ return True
+
+ def nodestate_reinstall (self):
+ self.test_plc.apiserver.UpdateNode(self.test_plc.auth_root(),
+ self.name(),{'boot_state':'reinstall'})
+ return True
+
+ def nodestate_safeboot (self):
+ self.test_plc.apiserver.UpdateNode(self.test_plc.auth_root(),
+ self.name(),{'boot_state':'safeboot'})
+ return True
+
+ def nodestate_boot (self):
+ self.test_plc.apiserver.UpdateNode(self.test_plc.auth_root(),
+ self.name(),{'boot_state':'boot'})
+ return True
+
+ def nodestate_show (self):
+ if self.test_plc.options.dry_run:
+ print "Dry_run: skipped getting current node state"
+ return True
+ state=self.test_plc.apiserver.GetNodes(self.test_plc.auth_root(), self.name(), ['boot_state'])[0]['boot_state']
+ print self.name(),':',state
+ return True
+
+ def qemu_local_config(self):
+ if not self.is_qemu():
+ return
+ mac=self.node_spec['interface_fields']['mac']
+ hostname=self.node_spec['node_fields']['hostname']
+ ip=self.node_spec['interface_fields']['ip']
+ auth=self.test_plc.auth_root()
+ target_arch=self.test_plc.apiserver.GetPlcRelease(auth)['build']['target-arch']
+ conf_filename="%s/qemu.conf"%(self.nodedir())
+ if self.test_plc.options.dry_run:
+ print "dry_run: skipped actual storage of qemu.conf"
+ return True
+ utils.header('Storing qemu config for %s in %s'%(self.name(),conf_filename))
+ file=open(conf_filename,'w')
+ file.write('MACADDR=%s\n'%mac)
+ file.write('NODE_ISO=%s.iso\n'%self.name())
+ file.write('HOSTNAME=%s\n'%hostname)
+ file.write('IP=%s\n'%ip)
+ file.write('TARGET_ARCH=%s\n'%target_arch)
+ file.close()
+ return True
+
+ def qemu_export (self):
+ # if relevant, push the qemu area onto the host box
+ if self.test_box().is_local():
+ return True
+ utils.header ("Cleaning any former sequel of %s on %s"%(self.name(),self.host_box()))
+ self.test_box().run_in_buildname("rm -rf %s"%self.nodedir())
+ utils.header ("Transferring configuration files for node %s onto %s"%(self.name(),self.host_box()))
+ return self.test_box().copy(self.nodedir(),recursive=True)==0