- def create_boot_cd(self):
- utils.header("Calling GetBootMedium for %s"%self.name())
- options = []
- if self.is_qemu():
- options=['serial']
- encoded=self.test_plc.server.GetBootMedium(self.test_plc.auth_root(), self.name(), 'node-iso', '', options)
- if (encoded == ''):
- raise Exception, 'GetBootmedium failed'
-
- filename="%s/%s.iso"%(self.areaname(),self.name())
- utils.header('Storing boot medium into %s'%filename)
- file(filename,'w').write(base64.b64decode(encoded))
+ def bootcd(self):
+ "all nodes: invoke GetBootMedium and store result locally"
+ utils.header("Calling GetBootMedium for {}".format(self.name()))
+ # this would clearly belong in the config but, well ..
+ options = self.node_spec['bootmedium_options'] if 'bootmedium_options' in self.node_spec else []
+ encoded = self.test_plc.apiserver.GetBootMedium(
+ self.test_plc.auth_root(), self.name(), 'node-iso', '', options)
+ if encoded == '':
+ raise Exception('GetBootmedium failed')
+
+ filename = "{}/{}.iso".format(self.nodedir(), self.name())
+ utils.header('Storing boot medium into {}'.format(filename))
+
+ # xxx discovered with python3, but a long stading issue:
+ # encoded at this point is a str instead of a bytes
+ # Quick & dirty : we convert this explicitly to a bytearray
+ # Longer run : clearly it seems like the plcapi server side should
+ # tag its result with <base64></base64> rather than as a string
+ bencoded = str.encode(encoded)
+ if self.dry_run():
+ print("Dry_run: skipped writing of iso image")
+ return True
+ else:
+ # with python3 we need to call decodestring here
+ with open(filename,'wb') as storage:
+ storage.write(base64.decodestring(bencoded))
+ 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