コード例 #1
0
def chdef_node(driver_info):
    """Run the chdef command in xcat, config the node
    :param driver_info: driver_info for the xcat node
    """
    cmd = 'chdef'
    args = 'mgt=ipmi' + \
           ' bmc=' + driver_info['address'] + \
           ' bmcusername='******'username'] + \
           ' bmcpassword='******'password'] + \
           ' xcatmaster='  + driver_info['xcatmaster']+ \
           ' netboot=' + driver_info['netboot']+ \
           ' primarynic=mac'+ \
           ' installnic=mac'+ \
           ' monserver=' + driver_info['xcatmaster'] + \
           ' nfsserver=' + driver_info['xcatmaster'] + \
           ' serialflow=hard'+ \
           ' serialspeed=115200' + \
           ' serialport=' + str(driver_info['port']);

    try:
        xcat_util.exec_xcatcmd(driver_info, cmd, args)
    except xcat_exception.xCATCmdFailure as e:
        LOG.warning(_("xcat chdef failed for node %(node_id)s with "
                    "error: %(error)s.")
                    % {'node_id': driver_info['uuid'], 'error': e})
コード例 #2
0
    def _wait(mutable):
        try:
            # Only issue power change command once
            if mutable['iter'] < 0:
                xcat_util.exec_xcatcmd(driver_info,'rpower',state_name)
            else:
                mutable['power'] = _power_status(driver_info)
        except Exception:
            # Log failures but keep trying
            LOG.warning(_("xcat rpower %(state)s failed for node %(node)s."),
                         {'state': state_name, 'node': driver_info['uuid']})
        finally:
            mutable['iter'] += 1

        if mutable['power'] == target_state:
            raise loopingcall.LoopingCallDone()

        sleep_time = _sleep_time(mutable['iter'])
        if (sleep_time + mutable['total_time']) > CONF.ipmi.retry_timeout:
            # Stop if the next loop would exceed maximum retry_timeout
            LOG.error(_('xcat rpower %(state)s timed out after '
                        '%(tries)s retries on node %(node_id)s.'),
                        {'state': state_name, 'tries': mutable['iter'],
                        'node_id': driver_info['uuid']})
            mutable['power'] = states.ERROR
            raise loopingcall.LoopingCallDone()
        else:
            mutable['total_time'] += sleep_time
            return sleep_time
コード例 #3
0
ファイル: xcat_rpower.py プロジェクト: chenglch/ironic_xcat
    def _set_boot_device(self, task, device, persistent=False):
        """Set the boot device for a node.

        :param task: a TaskManager instance.
        :param device: Boot device. One of [net, hd, cd, floppy, def, stat].
        :param persistent: Whether to set next-boot, or make the change
            permanent. Default: False.
        :raises: InvalidParameterValue if an invalid boot device is specified
            or if required ipmi parameters are missing.
        :raises: IPMIFailure on an error from ipmitool.

        """
        if device not in VALID_BOOT_DEVICES:
            raise exception.InvalidParameterValue(_(
                "Invalid boot device %s specified.") % device)
        cmd = "rsetboot"
        if persistent:
            cmd = cmd + " options=persistent"
        driver_info = _parse_driver_info(task.node)
        try:
            xcat_util.exec_xcatcmd(driver_info, cmd, device)
            # TODO(deva): validate (out, err) and add unit test for failure
        except xcat_exception.xCATCmdFailure:
            LOG.error(_("rsetboot %(node)s %(device)s"),{'node':driver_info['xcat_node]'],
                                                         'device':device})
コード例 #4
0
ファイル: xcat_pxe.py プロジェクト: andreas-h/xcat-core
 def _nodeset_osimage(self, driver_info, image_name):
     """run nodeset command to config the image for the xcat node
     :param driver_info: xcat node deploy info
     :param image_name: image for the xcat deployment
     """
     cmd = 'nodeset'
     args = 'osimage='+ image_name
     try:
         xcat_util.exec_xcatcmd(driver_info, cmd, args)
     except xcat_exception.xCATCmdFailure as e:
         LOG.warning(_("xcat nodeset failed for node %(xcat_node)s with "
                     "error: %(error)s.")
                     % {'xcat_node': driver_info['xcat_node'], 'error': e})
コード例 #5
0
ファイル: xcat_pxe.py プロジェクト: zjqac/xcat-core
        def _wait_for_deploy():
            out, err = xcat_util.exec_xcatcmd(driver_info, 'nodels',
                                              'nodelist.status')
            if err:
                locals['errstr'] = _(
                    "Error returned when quering node status"
                    " for node %s:%s") % (driver_info['xcat_node'], err)
                LOG.warning(locals['errstr'])
                raise loopingcall.LoopingCallDone()

            if out:
                node, status = out.split(": ")
                status = status.strip()
                if status == "booted":
                    LOG.info(
                        _("Deployment for node %s completed.") %
                        driver_info['xcat_node'])
                    raise loopingcall.LoopingCallDone()

            if (CONF.xcat.deploy_timeout and timeutils.utcnow() > expiration):
                locals['errstr'] = _(
                    "Timeout while waiting for"
                    " deployment of node %s.") % driver_info['xcat_node']
                LOG.warning(locals['errstr'])
                raise loopingcall.LoopingCallDone()
コード例 #6
0
ファイル: xcat_pxe.py プロジェクト: zjqac/xcat-core
 def _nodeset_osimage(self, driver_info, image_name):
     """run nodeset command to config the image for the xcat node
     :param driver_info: xcat node deploy info
     :param image_name: image for the xcat deployment
     """
     cmd = 'nodeset'
     args = 'osimage=' + image_name
     try:
         xcat_util.exec_xcatcmd(driver_info, cmd, args)
     except xcat_exception.xCATCmdFailure as e:
         LOG.warning(
             _("xcat nodeset failed for node %(xcat_node)s with "
               "error: %(error)s.") % {
                   'xcat_node': driver_info['xcat_node'],
                   'error': e
               })
コード例 #7
0
ファイル: xcat_pxe.py プロジェクト: andreas-h/xcat-core
 def _chdef_node_mac_address(self, driver_info, deploy_mac):
     """ run chdef command to set mac address"""
     cmd = 'chdef'
     args = 'mac='+ deploy_mac
     try:
         out_err = xcat_util.exec_xcatcmd(driver_info, cmd, args)
         LOG.info(_("xcat chdef cmd exetute output: %(out_err)s") % {'out_err':out_err})
     except xcat_exception.xCATCmdFailure as e:
         LOG.warning(_("xcat chdef failed for node %(xcat_node)s with "
                     "error: %(error)s.")
                     % {'xcat_node': driver_info['xcat_node'], 'error': e})
         raise exception.IPMIFailure(cmd=cmd)
コード例 #8
0
ファイル: xcat_pxe.py プロジェクト: zjqac/xcat-core
 def _chdef_node_mac_address(self, driver_info, deploy_mac):
     """ run chdef command to set mac address"""
     cmd = 'chdef'
     args = 'mac=' + deploy_mac
     try:
         out_err = xcat_util.exec_xcatcmd(driver_info, cmd, args)
         LOG.info(
             _("xcat chdef cmd exetute output: %(out_err)s") %
             {'out_err': out_err})
     except xcat_exception.xCATCmdFailure as e:
         LOG.warning(
             _("xcat chdef failed for node %(xcat_node)s with "
               "error: %(error)s.") % {
                   'xcat_node': driver_info['xcat_node'],
                   'error': e
               })
         raise exception.IPMIFailure(cmd=cmd)
コード例 #9
0
def _power_status(driver_info):
    """Get the power status for a node.

    :param driver_info: the xcat access parameters for a node.
    :returns: one of ironic.common.states POWER_OFF, POWER_ON or ERROR.
    :raises: IPMIFailure on an error from ipmitool.

    """
    cmd = "rpower"
    try:
        out_err = xcat_util.exec_xcatcmd(driver_info,cmd,'status')
    except Exception as e:
        LOG.warning(_("xcat rpower status failed for node %(node_id)s with "
                      "error: %(error)s.")
                    % {'node_id': driver_info['uuid'], 'error': e})

    if out_err[0].split(' ')[1].strip() == "on":
        return states.POWER_ON
    elif out_err[0].split(' ')[1].strip() == "off":
        return states.POWER_OFF
    else:
        return states.ERROR
コード例 #10
0
ファイル: xcat_pxe.py プロジェクト: andreas-h/xcat-core
        def _wait_for_deploy():
            out,err = xcat_util.exec_xcatcmd(driver_info,'nodels','nodelist.status')
            if err:
                locals['errstr'] = _("Error returned when quering node status"
                           " for node %s:%s") % (driver_info['xcat_node'], err)
                LOG.warning(locals['errstr'])
                raise loopingcall.LoopingCallDone()

            if out:
                node,status = out.split(": ")
                status = status.strip()
                if status == "booted":
                    LOG.info(_("Deployment for node %s completed.")
                             % driver_info['xcat_node'])
                    raise loopingcall.LoopingCallDone()

            if (CONF.xcat.deploy_timeout and
                    timeutils.utcnow() > expiration):
                locals['errstr'] = _("Timeout while waiting for"
                           " deployment of node %s.") % driver_info['xcat_node']
                LOG.warning(locals['errstr'])
                raise loopingcall.LoopingCallDone()