def reboot_node(self, nodename): """Reboot the node.""" out, err = self._exec_xcat_command("rpower %s boot" % nodename) if err: errstr = _("Error returned when calling xCAT rpower boot" " for node %s:%s") % (nodename, err) LOG.warning(errstr) raise exception.xCATCommandError(errstr) self._wait_for_node_reboot(nodename) return power_states.ON
def get_xcat_node_name(self, macs): """Get the xcat node name given mac addressed. It uses the mac address to search for the node name in xCAT. """ for mac in macs: out, err = self._exec_xcat_command("lsdef -w mac=%s" % mac) if out: return out.split(" ")[0] errstr='No node found in xCAT with the following mac address: ' \ + ','.join(macs) LOG.warning(errstr) raise exception.xCATCommandError(errstr)
def power_off_node(self, nodename): """Power off the node.""" state = self.get_node_power_state(nodename) if state == power_states.OFF: LOG.warning(_("Powring off node called, but the node %s " "is already off") % nodename) out, err = self._exec_xcat_command("rpower %s off" % nodename) if err: errstr = _("Error returned when calling xCAT rpower off" " for node %s:%s") % (nodename, err) LOG.warning(errstr) raise exception.xCATCommandError(errstr) else: return power_states.OFF
def power_on_node(self, nodename): """Power on the node.""" state = self.get_node_power_state(nodename) if state == power_states.ON: LOG.warning(_("Powring on node called, but the node %s " "is already on") % nodename) out, err = self._exec_xcat_command("rpower %s on" % nodename) if err: errstr = _("Error returned when calling xCAT rpower on" " for node %s:%s") % (nodename, err) LOG.warning(errstr) raise exception.xCATCommandError(errstr) else: self._wait_for_node_reboot(nodename) return power_states.ON
def get_node_power_state(self, nodename): out, err = self._exec_xcat_command("rpower %s stat" % nodename) if err: errstr = _("Error returned when calling xCAT rpower stat" " for node %s:%s") % (nodename, err) LOG.warning(errstr) raise exception.xCATCommandError(errstr) else: state = out.split(":")[1] if state: state = state.strip() if state == 'on': return power_states.ON elif state == 'off': return power_states.OFF return power_states.ERROR
def cleanup_node(self, nodename, fixed_ip=None): """ Undo all the changes made to the node by deploy_node function. It calls xCAT command cleanup_ops_bm_node which removes the config_ops_bm_node postbootscript from the postscript table for the node, removes the alias ip and then power the node off. """ cmd = "cleanup_ops_bm_node %s" % nodename if fixed_ip: cmd += " --ip %s" % fixed_ip out, err = self._exec_xcat_command(cmd) if err: errstr = _("Error returned when calling xCAT cleanup_ops_bm_node" " command for node %s:%s") % (nodename, err) LOG.warning(errstr) raise exception.xCATCommandError(errstr)
def deploy_node(self, nodename, imagename, hostname, fixed_ip, netmask, gateway): """ Install the node. It calls xCAT command deploy_ops_bmnode which prepares the node by adding the config_ops_bm_node postbootscript to the postscript table for the node, then call nodeset and then boot the node up. """ out, err = self._exec_xcat_command( "deploy_ops_bm_node %(node)s --image %(image)s" " --host %(host)s --ip %(ip)s --mask %(mask)s" % {'node': nodename, 'image': imagename, 'host': hostname, 'ip': fixed_ip, 'mask': netmask, }) if err: errstr = _("Error returned when calling xCAT deploy_ops_bm_node" " command for node %s:%s") % (nodename, err) LOG.warning(errstr) raise exception.xCATCommandError(errstr) self._wait_for_node_deploy(nodename)