- nodepath="%s/real-%s"%(path,hostname)
- utils.system("rm -rf %s"%nodepath)
- utils.system("mkdir %s"%nodepath)
- file=open("%s/%s"%(nodepath,"/boot_file.iso"),'w')
-
- file.write(base64.b64decode(encoded))
- file.close()
- utils.header('boot cd created for %s'%hostname)
- self.conffile('boot_file.iso',hostname, path)
-
- def start_node (self,options):
- model=self.node_spec['node_fields']['model']
- if model.find("vmware") >= 0:
- self.start_vmware(options)
- elif model.find("qemu") >= 0:
- self.start_qemu(options)
+ file(filename,'w').write(base64.b64decode(encoded))
+ return True
+
+ def nodestate_reinstall (self):
+ "all nodes: mark PLCAPI boot_state as reinstall"
+ self.test_plc.apiserver.UpdateNode(self.test_plc.auth_root(),
+ self.name(),{'boot_state':'reinstall'})
+ return True
+
+ def nodestate_safeboot (self):
+ "all nodes: mark PLCAPI boot_state as safeboot"
+ self.test_plc.apiserver.UpdateNode(self.test_plc.auth_root(),
+ self.name(),{'boot_state':'safeboot'})
+ return True
+
+ def nodestate_boot (self):
+ "all nodes: mark PLCAPI boot_state as boot"
+ self.test_plc.apiserver.UpdateNode(self.test_plc.auth_root(),
+ self.name(),{'boot_state':'boot'})
+ return True
+
+ def nodestate_show (self):
+ "all nodes: show PLCAPI boot_state"
+ if self.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):
+ "all nodes: compute qemu config qemu.conf and store it locally"
+ 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 = "{}/qemu.conf".format(self.nodedir())
+ if self.dry_run():
+ print "dry_run: skipped actual storage of qemu.conf"
+ return True
+ utils.header('Storing qemu config for {} in {}'.format(self.name(), conf_filename))
+ with open(conf_filename,'w') as f:
+ file.write('MACADDR={}\n'.format(mac))
+ file.write('NODE_ISO={}.iso\n'.format(self.name()))
+ file.write('HOSTNAME={}\n'.format(hostname))
+ file.write('IP={}\n'.format(ip))
+ file.write('TARGET_ARCH={}\n'.format(target_arch))
+ return True
+
+ def qemu_clean (self):
+ utils.header("Cleaning up qemu for host {} on box {}"\
+ .format(self.name(),self.test_box().hostname()))
+ dry_run = self.dry_run()
+ self.test_box().rmdir(self.nodedir(), dry_run=dry_run)
+ return True
+
+ def qemu_export (self):
+ "all nodes: push local node-dep directory on the qemu box"
+ # if relevant, push the qemu area onto the host box
+ if self.test_box().is_local():
+ return True
+ dry_run = self.dry_run()
+ utils.header ("Cleaning any former sequel of {} on {}"\
+ .format(self.name(), self.host_box()))
+ utils.header ("Transferring configuration files for node {} onto {}"\
+ .format(self.name(), self.host_box()))
+ return self.test_box().copy(self.nodedir(), recursive=True, dry_run=dry_run) == 0
+
+ def qemu_start (self):
+ "all nodes: start the qemu instance (also runs qemu-bridge-init start)"
+ model = self.node_spec['node_fields']['model']
+ #starting the Qemu nodes before
+ if self.is_qemu():
+ self.start_qemu()