def _handle_host(self, host):
     cmd = [
      'ssh', host, 'service', 'openstack-nova-compute', 'stop']
     LOG.info('StopComputeServiceHandler: handle host %s' % host)
     if exceed_retry(host) or action_too_soon(host, 'stop_service', SERVICE_DELAY):
         return
     set_action_record(host, 'stop_service')
     result = utils.execute(*cmd)
     LOG.info('handle host %s result: %s' % (host, result))
 def _handle_host(self, host):
     cmd = [
      'ssh', host, 'reboot']
     LOG.info('RebootComputeNodeHandler: handle host %s' % host)
     if exceed_retry(host) or action_too_soon(host, 'reboot_node', NODE_DELAY):
         return
     set_action_record(host, 'reboot_node')
     result = utils.execute(*cmd)
     LOG.info('handle host %s result: %s' % (host, result))
Beispiel #3
0
def _exec_ipmitool(node_info, command, use_timing=False):
    """Execute the ipmitool command.
    
    This uses the lanplus interface to communicate with the BMC device driver.
    
    :param node_info: the ipmitool parameters for accessing a node.
    :param command: the ipmitool command to be executed.
    :returns: (stdout, stderr) from executing the command.
    :raises: PasswordFileFailedToCreate from creating or writing to the
             temporary file.
    :raises: processutils.ProcessExecutionError from executing the command.
    
    """
    args = [
        'ipmitool', '-I', 'lanplus', '-H', node_info['address'], '-L',
        node_info.get('priv_level', VALID_PRIV_LEVELS[0])
    ]
    if node_info['username']:
        args.append('-U')
        args.append(node_info['username'])
    if use_timing and _is_option_supported('timing'):
        num_tries = max(
            CONF.ipmi.retry_timeout // CONF.ipmi.min_command_interval, 1)
        args.append('-R')
        args.append(str(num_tries))
        args.append('-N')
        args.append(str(CONF.ipmi.min_command_interval))
    with _make_password_file(node_info['password'] or '\x00') as pw_file:
        args.append('-f')
        args.append(pw_file)
        args.extend(command.split(' '))
        time_till_next_poll = CONF.ipmi.min_command_interval - (
            time.time() - LAST_CMD_TIME.get(node_info['address'], 0))
        if time_till_next_poll > 0:
            time.sleep(time_till_next_poll)
        try:
            try:
                out, err = utils.execute(*args)
            except processutils.ProcessExecutionError as e:
                LOG.error('IPMI Error: %s', e)
                return ('', str(e))

        finally:
            LAST_CMD_TIME[node_info['address']] = time.time()

        return (out, err)
Beispiel #4
0
def _check_option_support(options):
    """Checks if the specific ipmitool options are supported on host.
    
    This method updates the module-level variables indicating whether
    an option is supported so that it is accessible by any driver
    interface class in this module. It is intended to be called from
    the __init__ method of such classes only.
    
    :param options: list of ipmitool options to be checked
    :raises: OSError
    """
    for opt in options:
        if _is_option_supported(opt) is None:
            try:
                cmd = ipmitool_command_options[opt]
                out, err = utils.execute(*cmd)
            except processutils.ProcessExecutionError:
                _is_option_supported(opt, False)
            else:
                _is_option_supported(opt, True)

    return
 def _handle_host(self, host):
     cmd = [
      'ceph', 'osd', 'set', 'noout']
     LOG.info('CephNoOutHandler: handle host %s' % host)
     result = utils.execute(*cmd)
     LOG.info('handle host %s result: %s' % (host, result))