Exemplo n.º 1
0
def donot_host_node_show(cc, args):
    """Show a node. DEBUG only"""
    host = host_utils._find_host(cc, args.hostnameorid)
    # API actually doesnt need hostid once it has node uuid

    i = _find_node(cc, host, args.nodeuuid)

    _print_node_show(i)
Exemplo n.º 2
0
def donot_host_node_list(cc, args):
    """List nodes.  DEBUG only"""
    host = host_utils._find_host(cc, args.hostnameorid)

    nodes = cc.node.list(host.uuid)

    field_labels = ['uuid', 'numa_node', 'capabilities']
    fields = ['uuid', 'numa_node', 'capabilities']
    utils.print_list(nodes, fields, field_labels, sortby=0)
Exemplo n.º 3
0
def do_host_update(cc, args):
    """Update host attributes."""
    patch = utils.args_array_to_patch("replace", args.attributes[0])
    host = host_utils._find_host(cc, args.hostnameorid)
    try:
        host = cc.host.update(host.id, patch)
    except exc.HTTPNotFound:
        raise exc.CommandError('host not found: %s' % args.hostnameorid)
    _print_host_show(host)
Exemplo n.º 4
0
def do_host_power_off(cc, args):
    """Power off a host."""
    attributes = []
    attributes.append('action=power-off')
    patch = utils.args_array_to_patch("replace", attributes)
    host = host_utils._find_host(cc, args.hostnameorid)
    try:
        host = cc.host.update(host.id, patch)
    except exc.HTTPNotFound:
        raise exc.CommandError('host not found: %s' % args.hostnameorid)
    _print_host_show(host)
Exemplo n.º 5
0
def do_host_cpu_list(cc, args):
    """List cpu cores."""

    host = host_utils._find_host(cc, args.hostnameorid)

    cpus = cc.cpu.list(host.uuid)

    field_labels = ['uuid', 'log_core', 'processor', 'phy_core', 'thread',
                    'processor_model']
    fields = ['uuid', 'cpu', 'numa_node', 'core', 'thread',
              'cpu_model']

    utils.print_list(cpus, fields, field_labels, sortby=1)
Exemplo n.º 6
0
def do_host_swact(cc, args):
    """Switch activity away from this active host."""
    attributes = []

    if args.force is True:
        # Forced swact operation
        attributes.append('action=force-swact')
    else:
        # Normal swact operation
        attributes.append('action=swact')

    patch = utils.args_array_to_patch("replace", attributes)
    host = host_utils._find_host(cc, args.hostnameorid)
    try:
        host = cc.host.update(host.id, patch)
    except exc.HTTPNotFound:
        raise exc.CommandError('host not found: %s' % args.hostnameorid)
    _print_host_show(host)
Exemplo n.º 7
0
def do_host_unlock(cc, args):
    """Unlock a host."""
    attributes = []

    if args.force is True:
        # Forced unlock operation
        attributes.append('action=force-unlock')
    else:
        # Normal unlock operation
        attributes.append('action=unlock')

    patch = utils.args_array_to_patch("replace", attributes)
    host = host_utils._find_host(cc, args.hostnameorid)
    try:
        host = cc.host.update(host.id, patch)
    except exc.HTTPNotFound:
        raise exc.CommandError('host not found: %s' % args.hostnameorid)
    _print_host_show(host)
Exemplo n.º 8
0
def do_host_port_list(cc, args):
    """List host ports."""

    from inventoryclient.common import wrapping_formatters

    terminal_width = utils.get_terminal_size()[0]

    host = host_utils._find_host(cc, args.hostnameorid)

    ports = cc.port.list(host.uuid)

    field_labels = ['uuid', 'name', 'type', 'pci address', 'device',
                    'processor', 'accelerated', 'device type']
    fields = ['uuid', 'name', 'type', 'pciaddr', 'dev_id', 'numa_node',
              'dpdksupport', 'pdevice']

    format_spec = \
        wrapping_formatters.build_best_guess_formatters_using_average_widths(
            ports, fields, field_labels, no_wrap_fields=['pciaddr'])
    # best-guess formatter does not make a good guess for
    # proper width of pdevice until terminal is > 155
    # We override that width here.
    pdevice_width = None
    if terminal_width <= 130:
        pdevice_width = .1
    elif 131 >= terminal_width <= 150:
        pdevice_width = .13
    elif 151 >= terminal_width <= 155:
        pdevice_width = .14

    if pdevice_width and format_spec["pdevice"] > pdevice_width:
        format_spec["pdevice"] = pdevice_width

    formatters = wrapping_formatters.build_wrapping_formatters(
        ports, fields, field_labels, format_spec)

    utils.print_list(
        ports, fields, field_labels, formatters=formatters, sortby=1)
Exemplo n.º 9
0
def do_host_lldp_agent_list(cc, args):
    """List host lldp agents."""
    host = host_utils._find_host(cc, args.hostnameorid)
    agents = cc.lldp_agent.list(host.uuid)

    field_labels = [
        'uuid', 'local_port', 'status', 'chassis_id', 'port_id', 'system_name',
        'system_description'
    ]
    fields = [
        'uuid', 'port_name', 'status', 'chassis_id', 'port_identifier',
        'system_name', 'system_description'
    ]
    formatters = {
        'system_name': _lldp_system_name_formatter,
        'system_description': _lldp_system_description_formatter,
        'port_description': _lldp_port_description_formatter
    }

    utils.print_list(agents,
                     fields,
                     field_labels,
                     sortby=1,
                     formatters=formatters)
Exemplo n.º 10
0
def do_host_lldp_neighbor_list(cc, args):
    """List host lldp neighbors."""
    host = host_utils._find_host(cc, args.hostnameorid)
    neighbours = cc.lldp_neighbour.list(host.uuid)

    field_labels = [
        'uuid', 'local_port', 'remote_port', 'chassis_id', 'system_name',
        'system_description', 'management_address'
    ]
    fields = [
        'uuid', 'port_name', 'port_identifier', 'chassis_id', 'system_name',
        'system_description', 'management_address'
    ]
    formatters = {
        'system_name': _lldp_system_name_formatter,
        'system_description': _lldp_system_description_formatter,
        'port_description': _lldp_port_description_formatter
    }

    utils.print_list(neighbours,
                     fields,
                     field_labels,
                     sortby=1,
                     formatters=formatters)
Exemplo n.º 11
0
def do_host_port_show(cc, args):
    """Show host port details."""
    host = host_utils._find_host(cc, args.hostnameorid)
    port = _find_port(cc, host, args.pnameoruuid)
    _print_port_show(port)
Exemplo n.º 12
0
def do_host_cpu_show(cc, args):
    """Show cpu core attributes."""
    host = host_utils._find_host(cc, args.hostnameorid)
    cpu = _find_cpu(cc, host, args.cpulcoreoruuid)
    _print_cpu_show(cpu)
Exemplo n.º 13
0
def do_host_show(cc, args):
    """Show host attributes."""
    host = host_utils._find_host(cc, args.hostnameorid)
    _print_host_show(host)