コード例 #1
0
def _get_nm_address(task):
    """Get Intel Node Manager target channel and address.

    :param task: a TaskManager instance.
    :raises: IPMIFailure if Intel Node Manager is not detected on a node or if
             an error happens during detection.
    :returns: a tuple with IPMI channel and address of Intel Node Manager.
    """
    node = task.node
    driver_internal_info = node.driver_internal_info

    def _save_to_node(channel, address):
        driver_internal_info['intel_nm_channel'] = channel
        driver_internal_info['intel_nm_address'] = address
        node.driver_internal_info = driver_internal_info
        node.save()

    channel = driver_internal_info.get('intel_nm_channel')
    address = driver_internal_info.get('intel_nm_address')
    if channel and address:
        return channel, address
    if channel is False and address is False:
        raise exception.IPMIFailure(
            _('Driver data indicates that Intel '
              'Node Manager detection failed.'))
    LOG.info(_LI('Start detection of Intel Node Manager on node %s'),
             node.uuid)
    sdr_filename = os.path.join(CONF.tempdir, node.uuid + '.sdr')
    res = None
    try:
        ipmitool.dump_sdr(task, sdr_filename)
        res = nm_commands.parse_slave_and_channel(sdr_filename)
    finally:
        ironic_utils.unlink_without_raise(sdr_filename)
    if res is None:
        _save_to_node(False, False)
        raise exception.IPMIFailure(_('Intel Node Manager is not detected.'))
    address, channel = res
    LOG.debug(
        'Intel Node Manager sensors present in SDR on node %(node)s, '
        'channel %(channel)s address %(address)s.', {
            'node': node.uuid,
            'channel': channel,
            'address': address
        })
    # SDR can contain wrong info, try simple command
    node.driver_info['ipmi_bridging'] = 'single'
    node.driver_info['ipmi_target_channel'] = channel
    node.driver_info['ipmi_target_address'] = address
    try:
        ipmitool.send_raw(task,
                          _command_to_string(nm_commands.get_version(None)))
        _save_to_node(channel, address)
        return channel, address
    except exception.IPMIFailure:
        _save_to_node(False, False)
        raise exception.IPMIFailure(
            _('Intel Node Manager sensors record '
              'present in SDR but Node Manager is not '
              'responding.'))
コード例 #2
0
    def _issue_bmc_reset(self, driver_info, task):
        """ Issues a bmc reset and waits till the BMC is ready for servicing
        """
        cmd = 'bmc reset cold'
        node_uuid = task.node.uuid
        self.log.debug("Issuing bmc cold reset to node %s" %(task.node.name))
        try:
            out, err = ipmitool._exec_ipmitool(driver_info, cmd)
            self.log.debug('bmc reset returned stdout: %(stdout)s, stderr:'
                           ' %(stderr)s', {'stdout': out, 'stderr': err})
        except processutils.ProcessExecutionError as err:
            self.log.exception(_translators.log_error('IPMI "bmc reset" failed for node %(node_id)s '
                                                      'with error: %(error)s.'),
                               {'node_id': node_uuid, 'error': err})
            raise exception.IPMIFailure(cmd=cmd)

        sleep_count = 10
        cmd = 'bmc info'
        while sleep_count:
            try:
                out, err = ipmitool._exec_ipmitool(driver_info, cmd)
                self.log.debug('bmc reset returned stdout: %(stdout)s, stderr:'
                               ' %(stderr)s', {'stdout': out, 'stderr': err})
                break
            except processutils.ProcessExecutionError as err:
                self.log.debug(_translators.log_error('IPMI "bmc info" failed for node %(node_id)s '
                                                      'with error: %(error)s. Sleeping and retrying later.'
                                                      'sleep_count: %(sleep_count)s'),
                               {'node_id': node_uuid, 'error': err, 'sleep_count': sleep_count})
                time.sleep(10)
                sleep_count -= 1

        if not sleep_count:
            self.log.exception('After bmc reset, connection to bmc is lost!')
            raise exception.IPMIFailure(cmd='bmc reset')
コード例 #3
0
    def wrapper(raw_data):
        msg = _('Data from Intel Node Manager %s')

        try:
            return func(raw_data)
        except (IndexError, struct.error):
            raise ironic_exception.IPMIFailure(msg % _('has wrong length.'))
        except KeyError:
            raise ironic_exception.IPMIFailure(msg % _('is corrupted.'))
        except ValueError:
            raise ironic_exception.IPMIFailure(msg % _('cannot be converted.'))
コード例 #4
0
    def set_boot_device(self, task, device, persistent=False):
        """Set the boot device for the task's node.

        Set the boot device to use on next reboot of the node.

        :param task: a task from TaskManager.
        :param device: the boot device, one of
                       :mod:`ironic.common.boot_devices`.
        :param persistent: Boolean value. True if the boot device will
                           persist to all future boots, False if not.
                           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 self.get_supported_boot_devices():
            raise exception.InvalidParameterValue(
                _("Invalid boot device %s specified.") % device)
        cmd = "chassis bootdev %s" % device
        if persistent:
            cmd = cmd + " options=persistent"
        driver_info = _parse_driver_info(task.node)
        try:
            out, err = _exec_ipmitool(driver_info, cmd)
        except processutils.ProcessExecutionError as e:
            LOG.warning(
                _LW('IPMI set boot device failed for node %(node)s '
                    'when executing "ipmitool %(cmd)s". '
                    'Error: %(error)s'), {
                        'node': driver_info['uuid'],
                        'cmd': cmd,
                        'error': str(e)
                    })
            raise exception.IPMIFailure(cmd=cmd)
コード例 #5
0
ファイル: ipmitool.py プロジェクト: sanakhanlibre/ironic
def dump_sdr(task, file_path):
    """Dump SDR data to a file.

    :param task: a TaskManager instance.
    :param file_path: the path to SDR dump file.
    :raises: IPMIFailure on an error from ipmitool.
    :raises: MissingParameterValue if a required parameter is missing.
    :raises: InvalidParameterValue when an invalid value is specified.

    """
    node_uuid = task.node.uuid
    LOG.debug('Dump SDR data for node %(node)s to file %(name)s', {
        'name': file_path,
        'node': node_uuid
    })
    driver_info = _parse_driver_info(task.node)
    cmd = 'sdr dump %s' % file_path

    try:
        out, err = _exec_ipmitool(driver_info, cmd)
        LOG.debug(
            'dump SDR returned stdout: %(stdout)s, stderr:'
            ' %(stderr)s', {
                'stdout': out,
                'stderr': err
            })
    except (exception.PasswordFileFailedToCreate,
            processutils.ProcessExecutionError) as e:
        LOG.exception(
            _LE('IPMI "sdr dump" failed for node %(node_id)s '
                'with error: %(error)s.'), {
                    'node_id': node_uuid,
                    'error': e
                })
        raise exception.IPMIFailure(cmd=cmd)
コード例 #6
0
    def _send_raw_bytes(self, task, raw_bytes):
        """Send raw bytes to the BMC. Bytes should be a string of bytes.

        :param task: a TaskManager instance.
        :param raw_bytes: a string of raw bytes to send, e.g. '0x00 0x01'
        :raises: IPMIFailure on an error from ipmitool.

        """
        node_uuid = task.node.uuid
        LOG.debug('Sending node %(node)s raw bytes %(bytes)s', {
            'bytes': raw_bytes,
            'node': node_uuid
        })
        driver_info = _parse_driver_info(task.node)
        cmd = 'raw %s' % raw_bytes

        try:
            out, err = _exec_ipmitool(driver_info, cmd)
            LOG.debug(
                'send raw bytes returned stdout: %(stdout)s, stderr:'
                ' %(stderr)s', {
                    'stdout': out,
                    'stderr': err
                })
        except Exception as e:
            LOG.exception(
                _('IPMI "raw bytes" failed for node %(node_id)s '
                  'with error: %(error)s.'), {
                      'node_id': node_uuid,
                      'error': e
                  })
            raise exception.IPMIFailure(cmd=cmd)
コード例 #7
0
ファイル: ipmitool.py プロジェクト: nkaul/ironic
    def _set_boot_device(self, task, node, device, persistent=False):
        """Set the boot device for a node.

        :param task: a TaskManager instance.
        :param node: The Node.
        :param device: Boot device. One of [pxe, disk, cdrom, safe, bios].
        :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 = "chassis bootdev %s" % device
        if persistent:
            cmd = cmd + " options=persistent"
        driver_info = _parse_driver_info(node)
        try:
            out, err = _exec_ipmitool(driver_info, cmd)
            # TODO(deva): validate (out, err) and add unit test for failure
        except Exception:
            raise exception.IPMIFailure(cmd=cmd)
コード例 #8
0
ファイル: ipmitool.py プロジェクト: skw0rm/ironic
    def bmc_reset(self, task, http_method, warm=True):
        """Reset BMC with IPMI command 'bmc reset (warm|cold)'.

        :param task: a TaskManager instance.
        :param http_method: the HTTP method used on the request.
        :param warm: boolean parameter to decide on warm or cold reset.
        :raises: IPMIFailure on an error from ipmitool.
        :raises: MissingParameterValue if a required parameter is missing.
        :raises: InvalidParameterValue when an invalid value is specified

        """
        node_uuid = task.node.uuid

        if warm:
            warm_param = 'warm'
        else:
            warm_param = 'cold'

        LOG.debug('Doing %(warm)s BMC reset on node %(node)s',
                  {'warm': warm_param, 'node': node_uuid})
        driver_info = _parse_driver_info(task.node)
        cmd = 'bmc reset %s' % warm_param

        try:
            out, err = _exec_ipmitool(driver_info, cmd)
            LOG.debug('bmc reset returned stdout: %(stdout)s, stderr:'
                      ' %(stderr)s', {'stdout': out, 'stderr': err})
        except (exception.PasswordFileFailedToCreate,
                processutils.ProcessExecutionError) as e:
            LOG.exception(_LE('IPMI "bmc reset" failed for node %(node_id)s '
                          'with error: %(error)s.'),
                          {'node_id': node_uuid, 'error': e})
            raise exception.IPMIFailure(cmd=cmd)
コード例 #9
0
def _power_status(driver_info):
    """Get the power status for this node.

    :param driver_info: the bmc access info for a node.
    :returns: power state POWER_ON, POWER_OFF or ERROR defined in
             :class:`ironic.common.states`.
    :raises: IPMIFailure when the native ipmi call fails.
    """

    try:
        ipmicmd = ipmi_command.Command(bmc=driver_info['address'],
                           userid=driver_info['username'],
                           password=driver_info['password'])
        ret = ipmicmd.get_power()
    except pyghmi_exception.IpmiException as e:
        LOG.warning(_LW("IPMI get power state failed for node %(node_id)s "
                        "with the following error: %(error)s"),
                    {'node_id': driver_info['uuid'], 'error': str(e)})
        raise exception.IPMIFailure(cmd=str(e))

    state = ret.get('powerstate')
    if state == 'on':
        return states.POWER_ON
    elif state == 'off':
        return states.POWER_OFF
    else:
        # NOTE(linggao): Do not throw an exception here because it might
        # return other valid values. It is up to the caller to decide
        # what to do.
        LOG.warning(_LW("IPMI get power state for node %(node_id)s returns the"
                        " following details: %(detail)s"),
                    {'node_id': driver_info['uuid'], 'detail': ret})
        return states.ERROR
コード例 #10
0
    def set_boot_device(self, task, device, persistent=False):
        """Set the boot device for the task's node.

        Set the boot device to use on next reboot of the node.

        :param task: a task from TaskManager.
        :param device: the boot device, one of
                       :mod:`ironic.common.boot_devices`.
        :param persistent: Boolean value. True if the boot device will
                           persist to all future boots, False if not.
                           Default: False.
        :raises: InvalidParameterValue if an invalid boot device is specified
                 or required ipmi credentials are missing.
        :raises: MissingParameterValue when required ipmi credentials
                 are missing.
        :raises: IPMIFailure on an error from pyghmi.
        """
        if device not in self.get_supported_boot_devices():
            raise exception.InvalidParameterValue(_(
                "Invalid boot device %s specified.") % device)
        driver_info = _parse_driver_info(task.node)
        try:
            ipmicmd = ipmi_command.Command(bmc=driver_info['address'],
                               userid=driver_info['username'],
                               password=driver_info['password'])
            bootdev = _BOOT_DEVICES_MAP[device]
            ipmicmd.set_bootdev(bootdev, persist=persistent)
        except pyghmi_exception.IpmiException as e:
            LOG.error(_LE("IPMI set boot device failed for node %(node_id)s "
                          "with the following error: %(error)s"),
                      {'node_id': driver_info['uuid'], 'error': e})
            raise exception.IPMIFailure(cmd=e)
コード例 #11
0
ファイル: ipminative.py プロジェクト: nkaul/ironic
    def _set_boot_device(self, task, node, device, persistent=False):
        """Set the boot device for a node.

        :param task: a TaskManager instance.
        :param node: The Node.
        :param device: Boot device. One of [net, network, pxe, hd, cd,
            cdrom, dvd, floppy, default, setup, f1]
        :param persistent: Whether to set next-boot, or make the change
            permanent. Default: False.
        :raises: InvalidParameterValue if an invalid boot device is specified
                 or required ipmi credentials are missing.
        :raises: IPMIFailure when the native ipmi call fails.
        """

        if device not in ipmi_command.boot_devices:
            raise exception.InvalidParameterValue(
                _("Invalid boot device %s specified.") % device)
        driver_info = _parse_driver_info(node)
        try:
            ipmicmd = ipmi_command.Command(bmc=driver_info['address'],
                                           userid=driver_info['username'],
                                           password=driver_info['password'])
            ipmicmd.set_bootdev(device)
        except pyghmi_exception.IpmiException as e:
            LOG.warning(
                _("IPMI set boot device failed for node %(node_id)s "
                  "with the following error: %(error)s") % {
                      'node_id': driver_info['uuid'],
                      'error': str(e)
                  })
            raise exception.IPMIFailure(cmd=str(e))
コード例 #12
0
def _reboot(driver_info):
    """Reboot this node.

    If the power is off, turn it on. If the power is on, reset it.

    :param driver_info: the bmc access info for a node.
    :returns: power state POWER_ON, one of :class:`ironic.common.states`.
    :raises: IPMIFailure when the native ipmi call fails.
    :raises: PowerStateFailure when invalid power state is returned
             from ipmi.
    """

    msg = _LW("IPMI power reboot failed for node %(node_id)s with the "
              "following error: %(error)s")
    try:
        ipmicmd = ipmi_command.Command(bmc=driver_info['address'],
                           userid=driver_info['username'],
                           password=driver_info['password'])
        wait = CONF.ipmi.retry_timeout
        ret = ipmicmd.set_power('boot', wait)
    except pyghmi_exception.IpmiException as e:
        LOG.warning(msg % {'node_id': driver_info['uuid'], 'error': str(e)})
        raise exception.IPMIFailure(cmd=str(e))

    state = ret.get('powerstate')
    if state == 'on':
        return states.POWER_ON
    else:
        LOG.warning(msg % {'node_id': driver_info['uuid'], 'error': ret})
        raise exception.PowerStateFailure(pstate=state)
コード例 #13
0
def _power_off(driver_info):
    """Turn the power off for this node.

    :param driver_info: the bmc access info for a node.
    :returns: power state POWER_OFF, one of :class:`ironic.common.states`.
    :raises: IPMIFailure when the native ipmi call fails.
    :raises: PowerStateFailure when invalid power state is returned
             from ipmi.
    """

    msg = _("IPMI power off failed for node %(node_id)s with the "
            "following error: %(error)s")
    try:
        ipmicmd = ipmi_command.Command(bmc=driver_info['address'],
                                       userid=driver_info['username'],
                                       password=driver_info['password'])
        wait = CONF.ipmi.retry_timeout
        ret = ipmicmd.set_power('off', wait)
    except pyghmi_exception.IpmiException as e:
        error = msg % {'node_id': driver_info['uuid'], 'error': e}
        LOG.error(error)
        raise exception.IPMIFailure(error)

    state = ret.get('powerstate')
    if state == 'off':
        return states.POWER_OFF
    else:
        error = _("bad response: %s") % ret
        LOG.error(msg, {'node_id': driver_info['uuid'], 'error': error})
        raise exception.PowerStateFailure(pstate=states.POWER_OFF)
コード例 #14
0
ファイル: ipmitool.py プロジェクト: hanlind/ironic
def _power_status(driver_info):
    """Get the power status for a node.

    :param driver_info: the ipmitool 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 = "power status"
    try:
        out_err = _exec_ipmitool(driver_info, cmd)
    except (exception.PasswordFileFailedToCreate,
            processutils.ProcessExecutionError) as e:
        LOG.warning(
            _LW("IPMI power status failed for node %(node_id)s with "
                "error: %(error)s."), {
                    'node_id': driver_info['uuid'],
                    'error': e
                })
        raise exception.IPMIFailure(cmd=cmd)

    if out_err[0] == "Chassis Power is on\n":
        return states.POWER_ON
    elif out_err[0] == "Chassis Power is off\n":
        return states.POWER_OFF
    else:
        return states.ERROR
コード例 #15
0
ファイル: ipmitool.py プロジェクト: skw0rm/ironic
def _send_raw(task, raw_bytes):
    """Send raw bytes to the BMC. Bytes should be a string of bytes.

    :param task: a TaskManager instance.
    :param raw_bytes: a string of raw bytes to send, e.g. '0x00 0x01'
    :raises: IPMIFailure on an error from ipmitool.
    :raises: MissingParameterValue if a required parameter is missing.
    :raises:  InvalidParameterValue when an invalid value is specified.

    """
    node_uuid = task.node.uuid
    LOG.debug('Sending node %(node)s raw bytes %(bytes)s',
              {'bytes': raw_bytes, 'node': node_uuid})
    driver_info = _parse_driver_info(task.node)
    cmd = 'raw %s' % raw_bytes

    try:
        out, err = _exec_ipmitool(driver_info, cmd)
        LOG.debug('send raw bytes returned stdout: %(stdout)s, stderr:'
                  ' %(stderr)s', {'stdout': out, 'stderr': err})
    except (exception.PasswordFileFailedToCreate,
            processutils.ProcessExecutionError) as e:
        LOG.exception(_LE('IPMI "raw bytes" failed for node %(node_id)s '
                      'with error: %(error)s.'),
                      {'node_id': node_uuid, 'error': e})
        raise exception.IPMIFailure(cmd=cmd)
コード例 #16
0
ファイル: test_management.py プロジェクト: ajya/ironic-fork
 def test_configure_intel_speedselect_error(self, send_raw_mock):
     send_raw_mock.side_effect = exception.IPMIFailure('err')
     config = {"intel_speedselect_config": "0x02", "socket_count": 1}
     with task_manager.acquire(self.context, self.node.uuid) as task:
         self.assertRaisesRegex(
             exception.IPMIFailure,
             "Failed to set Intel SST-PP configuration",
             task.driver.management.configure_intel_speedselect,
             task, **config)
コード例 #17
0
    def get_boot_device(self, task):
        """Get the current boot device for the task's node.

        Returns the current boot device of the node.

        :param task: a task from TaskManager.
        :raises: MissingParameterValue if required IPMI parameters
            are missing.
        :raises: IPMIFailure on an error from pyghmi.
        :returns: a dictionary containing:

            :boot_device: the boot device, one of
                :mod:`ironic.common.boot_devices` or None if it is unknown.
            :persistent: Whether the boot device will persist to all
                future boots or not, None if it is unknown.

        """
        driver_info = task.node.driver_info
        driver_internal_info = task.node.driver_internal_info
        if (driver_info.get('ipmi_force_boot_device', False)
                and driver_internal_info.get('persistent_boot_device')
                and driver_internal_info.get('is_next_boot_persistent', True)):
            return {
                'boot_device': driver_internal_info['persistent_boot_device'],
                'persistent': True
            }

        driver_info = _parse_driver_info(task.node)
        response = {'boot_device': None}

        try:
            ipmicmd = ipmi_command.Command(bmc=driver_info['address'],
                                           userid=driver_info['username'],
                                           password=driver_info['password'])
            ret = ipmicmd.get_bootdev()
            # FIXME(lucasagomes): pyghmi doesn't seem to handle errors
            # consistently, for some errors it raises an exception
            # others it just returns a dictionary with the error.
            if 'error' in ret:
                raise pyghmi_exception.IpmiException(ret['error'])
        except pyghmi_exception.IpmiException as e:
            LOG.error(
                _LE("IPMI get boot device failed for node %(node_id)s "
                    "with the following error: %(error)s"), {
                        'node_id': driver_info['uuid'],
                        'error': e
                    })
            raise exception.IPMIFailure(cmd=e)

        response['persistent'] = ret.get('persistent')
        bootdev = ret.get('bootdev')
        if bootdev:
            response['boot_device'] = next(
                (dev for dev, hdev in _BOOT_DEVICES_MAP.items()
                 if hdev == bootdev), None)
        return response
コード例 #18
0
ファイル: ipmitool.py プロジェクト: hanlind/ironic
    def get_boot_device(self, task):
        """Get the current boot device for the task's node.

        Returns the current boot device of the node.

        :param task: a task from TaskManager.
        :raises: InvalidParameterValue if required IPMI parameters
            are missing.
        :raises: IPMIFailure on an error from ipmitool.
        :raises: MissingParameterValue if a required parameter is missing.
        :returns: a dictionary containing:

            :boot_device: the boot device, one of
                :mod:`ironic.common.boot_devices` or None if it is unknown.
            :persistent: Whether the boot device will persist to all
                future boots or not, None if it is unknown.

        """
        cmd = "chassis bootparam get 5"
        driver_info = _parse_driver_info(task.node)
        response = {'boot_device': None, 'persistent': None}
        try:
            out, err = _exec_ipmitool(driver_info, cmd)
        except (exception.PasswordFileFailedToCreate,
                processutils.ProcessExecutionError) as e:
            LOG.warning(
                _LW('IPMI get boot device failed for node %(node)s '
                    'when executing "ipmitool %(cmd)s". '
                    'Error: %(error)s'), {
                        'node': driver_info['uuid'],
                        'cmd': cmd,
                        'error': e
                    })
            raise exception.IPMIFailure(cmd=cmd)

        re_obj = re.search('Boot Device Selector : (.+)?\n', out)
        if re_obj:
            boot_selector = re_obj.groups('')[0]
            if 'PXE' in boot_selector:
                response['boot_device'] = boot_devices.PXE
            elif 'Hard-Drive' in boot_selector:
                if 'Safe-Mode' in boot_selector:
                    response['boot_device'] = boot_devices.SAFE
                else:
                    response['boot_device'] = boot_devices.DISK
            elif 'BIOS' in boot_selector:
                response['boot_device'] = boot_devices.BIOS
            elif 'CD/DVD' in boot_selector:
                response['boot_device'] = boot_devices.CDROM

        response['persistent'] = 'Options apply to all future boots' in out
        return response
コード例 #19
0
def _call_httpmi(node, method, path, **kwargs):
    url = node.driver_info['httpmi_url']
    url += path
    payload = _get_httpmi_credentials(node)
    payload.update(kwargs)
    res = getattr(requests, method)(url, data=payload)
    if res.status_code != 200:
        # TODO log some stuff here
        # TODO add some retries
        raise ironic_exc.IPMIFailure(cmd='httpmi call to to %(url)s '
                                         'with args %(kwargs)s' % {
                                             'url': url, 'kwargs': kwargs})
    return res.json()
コード例 #20
0
    def set_boot_device(self, task, device, persistent=False):
        """Set the boot device for the task's node.

        Set the boot device to use on next reboot of the node.

        :param task: a task from TaskManager.
        :param device: the boot device, one of
                       :mod:`ironic.common.boot_devices`.
        :param persistent: Boolean value. True if the boot device will
                           persist to all future boots, False if not.
                           Default: False.
        :raises: InvalidParameterValue if an invalid boot device is specified
        :raises: MissingParameterValue if required ipmi parameters are missing.
        :raises: IPMIFailure on an error from ipmitool.

        """
        if device not in self.get_supported_boot_devices(task):
            raise exception.InvalidParameterValue(
                _("Invalid boot device %s specified.") % device)

        # note(JayF): IPMI spec indicates unless you send these raw bytes the
        # boot device setting times out after 60s. Since it's possible it
        # could be >60s before a node is rebooted, we should always send them.
        # This mimics pyghmi's current behavior, and the "option=timeout"
        # setting on newer ipmitool binaries.
        timeout_disable = "0x00 0x08 0x03 0x08"
        send_raw(task, timeout_disable)

        if task.node.driver_info.get('ipmi_force_boot_device', False):
            driver_utils.force_persistent_boot(task, device, persistent)
            # Reset persistent to False, in case of BMC does not support
            # persistent or we do not have admin rights.
            persistent = False

        cmd = "chassis bootdev %s" % device
        if persistent:
            cmd = cmd + " options=persistent"
        driver_info = _parse_driver_info(task.node)
        try:
            out, err = _exec_ipmitool(driver_info, cmd)
        except (exception.PasswordFileFailedToCreate,
                processutils.ProcessExecutionError) as e:
            LOG.warning(
                _LW('IPMI set boot device failed for node %(node)s '
                    'when executing "ipmitool %(cmd)s". '
                    'Error: %(error)s'), {
                        'node': driver_info['uuid'],
                        'cmd': cmd,
                        'error': e
                    })
            raise exception.IPMIFailure(cmd=cmd)
コード例 #21
0
 def test__get_nm_address_raw_fail(self, parse_mock, dump_mock, raw_mock,
                                   unlink_mock):
     parse_mock.return_value = ('0x0A', '0x0B')
     raw_mock.side_effect = exception.IPMIFailure('raw error')
     with task_manager.acquire(self.context, self.node.uuid,
                               shared=False) as task:
         self.assertRaises(exception.IPMIFailure, nm_vendor._get_nm_address,
                           task)
         self.node.refresh()
         internal_info = self.node.driver_internal_info
         self.assertEqual(False, internal_info['intel_nm_address'])
         self.assertEqual(False, internal_info['intel_nm_channel'])
         parse_mock.assert_called_once_with(self.temp_filename)
         dump_mock.assert_called_once_with(task, self.temp_filename)
         unlink_mock.assert_called_once_with(self.temp_filename)
         raw_mock.assert_called_once_with(task, mock.ANY)
コード例 #22
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)
コード例 #23
0
def _send_raw(driver_info, raw_bytes):
    """Send raw bytes to the BMC."""
    netfn, command, data = _parse_raw_bytes(raw_bytes)
    LOG.debug("Sending raw bytes %(bytes)s to node %(node_id)s",
              {'bytes': raw_bytes, 'node_id': driver_info['uuid']})
    try:
        ipmicmd = ipmi_command.Command(bmc=driver_info['address'],
                                       userid=driver_info['username'],
                                       password=driver_info['password'])
        ipmicmd.xraw_command(netfn, command, data=data)
    except pyghmi_exception.IpmiException as e:
        msg = (_("IPMI send raw bytes '%(bytes)s' failed for node %(node_id)s"
                 " with the following error: %(error)s") %
               {'bytes': raw_bytes, 'node_id': driver_info['uuid'],
                'error': e})
        LOG.error(msg)
        raise exception.IPMIFailure(msg)
コード例 #24
0
ファイル: management.py プロジェクト: ajya/ironic-fork
 def configure_intel_speedselect(self, task, **kwargs):
     config = kwargs.get('intel_speedselect_config')
     socket_count = kwargs.get('socket_count', 1)
     self._validate_input(config, socket_count)
     LOG.debug("Going to set Intel SST-PP configuration level %(config)s "
               "for node %(node)s with socket count %(socket)s",
               {"config": config, "node": task.node.uuid,
                "socket": socket_count})
     iss_conf = "0x2c 0x41 0x04 0x00 0x0%s %s"
     for socket in range(socket_count):
         hexa_code = iss_conf % (socket, config)
         try:
             ipmitool.send_raw(task, hexa_code)
         except exception.IPMIFailure as e:
             msg = (_("Failed to set Intel SST-PP configuration level "
                      "%(cfg)s on socket number %(skt)s due to "
                      "reason %(exc)s.") % {"cfg": config,
                                            "skt": socket, "exc": e})
             LOG.error(msg)
             raise exception.IPMIFailure(message=msg)
コード例 #25
0
    def _bmc_reset(self, task, warm=True):
        """Reset BMC with IPMI command 'bmc reset (warm|cold)'.

        :param task: a TaskManager instance.
        :param warm: boolean parameter to decide on warm or cold reset.
        :raises: IPMIFailure on an error from ipmitool.

        """
        node_uuid = task.node.uuid

        if warm:
            warm_param = 'warm'
        else:
            warm_param = 'cold'

        LOG.debug('Doing %(warm)s BMC reset on node %(node)s', {
            'warm': warm_param,
            'node': node_uuid
        })
        driver_info = _parse_driver_info(task.node)
        cmd = 'bmc reset %s' % warm_param

        try:
            out, err = _exec_ipmitool(driver_info, cmd)
            LOG.debug(
                'bmc reset returned stdout: %(stdout)s, stderr:'
                ' %(stderr)s', {
                    'stdout': out,
                    'stderr': err
                })
        except Exception as e:
            LOG.exception(
                _('IPMI "bmc reset" failed for node %(node_id)s '
                  'with error: %(error)s.'), {
                      'node_id': node_uuid,
                      'error': e
                  })
            raise exception.IPMIFailure(cmd=cmd)