コード例 #1
0
ファイル: fw.py プロジェクト: Cynerva/cxmanage
def fwinfo_command(args):
    """print firmware info"""
    tftp = get_tftp(args)
    nodes = get_nodes(args, tftp)

    if not args.quiet:
        print "Getting firmware info..."

    results, errors = run_command(args, nodes, "get_firmware_info")

    node_strings = get_node_strings(args, results, justify=False)
    for node in nodes:
        if node in results:
            print "[ Firmware info for %s ]" % node_strings[node]

            for partition in results[node]:
                print "Partition : %s" % partition.partition
                print "Type      : %s" % partition.type
                print "Offset    : %s" % partition.offset
                print "Size      : %s" % partition.size
                print "Priority  : %s" % partition.priority
                print "Daddr     : %s" % partition.daddr
                print "Flags     : %s" % partition.flags
                print "Version   : %s" % partition.version
                print "In Use    : %s" % partition.in_use
                print

    if not args.quiet and errors:
        print "Some errors occured during the command.\n"

    return len(errors) > 0
コード例 #2
0
ファイル: ipmitool.py プロジェクト: Cynerva/cxmanage
def ipmitool_command(args):
    """run arbitrary ipmitool command"""
    if args.lanplus:
        ipmitool_args = ['-I', 'lanplus'] + args.ipmitool_args
    else:
        ipmitool_args = args.ipmitool_args

    tftp = get_tftp(args)
    nodes = get_nodes(args, tftp)

    if not args.quiet:
        print "Running IPMItool command..."
    results, errors = run_command(args, nodes, "ipmitool_command",
            ipmitool_args)

    # Print results
    node_strings = get_node_strings(args, results, justify=False)
    for node in nodes:
        if node in results and results[node] != "":
            print "[ IPMItool output from %s ]" % node_strings[node]
            print results[node]
            print

    if not args.quiet and errors:
        print "Some errors occured during the command.\n"

    return len(errors) > 0
コード例 #3
0
def fwinfo_command(args):
    """print firmware info"""
    tftp = get_tftp(args)
    nodes = get_nodes(args, tftp)

    if not args.quiet:
        print "Getting firmware info..."

    results, errors = run_command(args, nodes, "get_firmware_info")

    node_strings = get_node_strings(args, results, justify=False)
    for node in nodes:
        if node in results:
            print "[ Firmware info for %s ]" % node_strings[node]

            for partition in results[node]:
                print "Partition : %s" % partition.partition
                print "Type      : %s" % partition.type
                print "Offset    : %s" % partition.offset
                print "Size      : %s" % partition.size
                print "Priority  : %s" % partition.priority
                print "Daddr     : %s" % partition.daddr
                print "Flags     : %s" % partition.flags
                print "Version   : %s" % partition.version
                print "In Use    : %s" % partition.in_use
                print

    if not args.quiet and errors:
        print "Some errors occured during the command.\n"

    return len(errors) > 0
コード例 #4
0
ファイル: ipmitool.py プロジェクト: SLS-Dev/cxmanage
def ipmitool_command(args):
    """run arbitrary ipmitool command"""
    if args.lanplus:
        ipmitool_args = ['-I', 'lanplus'] + args.ipmitool_args
    else:
        ipmitool_args = args.ipmitool_args

    tftp = get_tftp(args)
    nodes = get_nodes(args, tftp)

    if not args.quiet:
        print "Running IPMItool command..."
    results, errors = run_command(args, nodes, "ipmitool_command",
                                  ipmitool_args)

    # Print results
    node_strings = get_node_strings(args, results, justify=False)
    for node in nodes:
        if node in results and results[node] != "":
            print "[ IPMItool output from %s ]" % node_strings[node]
            print results[node]
            print

    if not args.quiet and errors:
        print "Some errors occured during the command.\n"

    return len(errors) > 0
コード例 #5
0
ファイル: info.py プロジェクト: Cynerva/cxmanage
def info_basic_command(args):
    """Print basic info"""

    tftp = get_tftp(args)
    nodes = get_nodes(args, tftp)

    if not args.quiet:
        print "Getting info..."
    results, errors = run_command(args, nodes, "get_versions")

    # Print results
    node_strings = get_node_strings(args, results, justify=False)
    for node in nodes:
        if node in results:
            result = results[node]
            # Get mappings between attributes and formatted strings
            components = COMPONENTS

            print "[ Info from %s ]" % node_strings[node]
            print "Hardware version    : %s" % result.hardware_version
            print "Firmware version    : %s" % result.firmware_version
            # var is the variable, string is the printable string of var
            for var, string in components:
                if hasattr(result, var):
                    version = getattr(result, var)
                    print "%s: %s" % (string.ljust(20), version)
            print

    if not args.quiet and errors:
        print "Some errors occured during the command.\n"

    return len(errors) > 0
コード例 #6
0
def info_basic_command(args):
    """Print basic info"""

    tftp = get_tftp(args)
    nodes = get_nodes(args, tftp)

    if not args.quiet:
        print "Getting info..."
    results, errors = run_command(args, nodes, "get_versions")

    # Print results
    node_strings = get_node_strings(args, results, justify=False)
    for node in nodes:
        if node in results:
            result = results[node]
            # Get mappings between attributes and formatted strings
            components = COMPONENTS

            print "[ Info from %s ]" % node_strings[node]
            print "Hardware version    : %s" % result.hardware_version
            print "Firmware version    : %s" % result.firmware_version
            # var is the variable, string is the printable string of var
            for var, string in components:
                if hasattr(result, var):
                    version = getattr(result, var)
                    print "%s: %s" % (string.ljust(20), version)
            print

    if not args.quiet and errors:
        print "Some errors occured during the command.\n"

    return len(errors) > 0
コード例 #7
0
ファイル: sensor.py プロジェクト: Cynerva/cxmanage
def sensor_command(args):
    """read sensor values from a cluster or host"""
    tftp = get_tftp(args)
    nodes = get_nodes(args, tftp)

    if not args.quiet:
        print "Getting sensor readings..."
    results, errors = run_command(args, nodes, "get_sensors",
            args.sensor_name)

    sensors = {}
    for node in nodes:
        if node in results:
            for sensor_name, sensor in results[node].iteritems():
                if not sensor_name in sensors:
                    sensors[sensor_name] = []

                reading = sensor.sensor_reading.replace("(+/- 0) ", "")
                try:
                    value = float(reading.split()[0])
                    suffix = reading.lstrip("%f " % value)
                    sensors[sensor_name].append((node, value, suffix))
                except ValueError:
                    sensors[sensor_name].append((node, reading, ""))

    node_strings = get_node_strings(args, results, justify=True)
    if node_strings:
        jsize = len(node_strings.itervalues().next())
    for sensor_name, readings in sensors.iteritems():
        print sensor_name

        for node, reading, suffix in readings:
            try:
                print "%s: %.2f %s" % (node_strings[node], reading, suffix)
            except TypeError:
                print "%s: %s" % (node_strings[node], reading)

        try:
            if all(suffix == x[2] for x in readings):
                minimum = min(x[1] for x in readings)
                maximum = max(x[1] for x in readings)
                average = sum(x[1] for x in readings) / len(readings)
                print "%s: %.2f %s" % ("Minimum".ljust(jsize), minimum, suffix)
                print "%s: %.2f %s" % ("Maximum".ljust(jsize), maximum, suffix)
                print "%s: %.2f %s" % ("Average".ljust(jsize), average, suffix)
        except TypeError:
            pass

        print

    if not args.quiet and errors:
        print "Some errors occured during the command.\n"

    return len(errors) > 0
コード例 #8
0
ファイル: sensor.py プロジェクト: SLS-Dev/cxmanage
def sensor_command(args):
    """read sensor values from a cluster or host"""
    tftp = get_tftp(args)
    nodes = get_nodes(args, tftp)

    if not args.quiet:
        print "Getting sensor readings..."
    results, errors = run_command(args, nodes, "get_sensors", args.sensor_name)

    sensors = {}
    for node in nodes:
        if node in results:
            for sensor_name, sensor in results[node].iteritems():
                if not sensor_name in sensors:
                    sensors[sensor_name] = []

                reading = sensor.sensor_reading.replace("(+/- 0) ", "")
                try:
                    value = float(reading.split()[0])
                    suffix = reading.lstrip("%f " % value)
                    sensors[sensor_name].append((node, value, suffix))
                except ValueError:
                    sensors[sensor_name].append((node, reading, ""))

    node_strings = get_node_strings(args, results, justify=True)
    if node_strings:
        jsize = len(node_strings.itervalues().next())
    for sensor_name, readings in sensors.iteritems():
        print sensor_name

        for node, reading, suffix in readings:
            try:
                print "%s: %.2f %s" % (node_strings[node], reading, suffix)
            except TypeError:
                print "%s: %s" % (node_strings[node], reading)

        try:
            if all(suffix == x[2] for x in readings):
                minimum = min(x[1] for x in readings)
                maximum = max(x[1] for x in readings)
                average = sum(x[1] for x in readings) / len(readings)
                print "%s: %.2f %s" % ("Minimum".ljust(jsize), minimum, suffix)
                print "%s: %.2f %s" % ("Maximum".ljust(jsize), maximum, suffix)
                print "%s: %.2f %s" % ("Average".ljust(jsize), average, suffix)
        except TypeError:
            pass

        print

    if not args.quiet and errors:
        print "Some errors occured during the command.\n"

    return len(errors) > 0
コード例 #9
0
ファイル: power.py プロジェクト: Cynerva/cxmanage
def power_policy_status_command(args):
    """Executes the power policy status command with args."""
    tftp = get_tftp(args)
    nodes = get_nodes(args, tftp)

    if not args.quiet:
        print 'Getting power policy status...'
    results, errors = run_command(args, nodes, 'get_power_policy')

    # Print results
    if results:
        node_strings = get_node_strings(args, results, justify=True)
        print 'Power policy status'
        for node in nodes:
            if node in results:
                print '%s: %s' % (node_strings[node], results[node])
        print

    if not args.quiet and errors:
        print 'Some errors occured during the command.\n'

    return len(errors) > 0
コード例 #10
0
ファイル: config.py プロジェクト: Cynerva/cxmanage
def config_boot_status_command(args):
    """Get boot status command."""
    tftp = get_tftp(args)
    nodes = get_nodes(args, tftp)

    if not args.quiet:
        print "Getting boot order..."
    results, errors = run_command(args, nodes, "get_boot_order")

    # Print results
    if results:
        node_strings = get_node_strings(args, results, justify=True)
        print "Boot order"
        for node in nodes:
            if node in results:
                print "%s: %s" % (node_strings[node], ",".join(results[node]))
        print

    if not args.quiet and errors:
        print "Some errors occured during the command.\n"

    return len(errors) > 0
コード例 #11
0
ファイル: config.py プロジェクト: Cynerva/cxmanage
def config_pxe_status_command(args):
    """Gets pxe status."""
    tftp = get_tftp(args)
    nodes = get_nodes(args, tftp)

    if not args.quiet:
        print "Getting pxe interface..."
    results, errors = run_command(args, nodes, "get_pxe_interface")

    # Print results
    if results:
        node_strings = get_node_strings(args, results, justify=True)
        print "PXE interface"
        for node in nodes:
            if node in results:
                print "%s: %s" % (node_strings[node], results[node])
        print

    if not args.quiet and errors:
        print "Some errors occured during the command.\n"

    return len(errors) > 0
コード例 #12
0
def power_policy_status_command(args):
    """Executes the power policy status command with args."""
    tftp = get_tftp(args)
    nodes = get_nodes(args, tftp)

    if not args.quiet:
        print 'Getting power policy status...'
    results, errors = run_command(args, nodes, 'get_power_policy')

    # Print results
    if results:
        node_strings = get_node_strings(args, results, justify=True)
        print 'Power policy status'
        for node in nodes:
            if node in results:
                print '%s: %s' % (node_strings[node], results[node])
        print

    if not args.quiet and errors:
        print 'Some errors occured during the command.\n'

    return len(errors) > 0
コード例 #13
0
ファイル: ipdiscover.py プロジェクト: Cynerva/cxmanage
def ipdiscover_command(args):
    """discover server IP addresses"""
    tftp = get_tftp(args)
    nodes = get_nodes(args, tftp)

    if not args.quiet:
        print "Getting server-side IP addresses..."

    results, errors = run_command(args, nodes, "get_server_ip", args.interface, args.ipv6, args.aggressive)

    if results:
        node_strings = get_node_strings(args, results, justify=True)
        print "IP addresses (ECME, Server)"
        for node in nodes:
            if node in results:
                print "%s: %s" % (node_strings[node], results[node])
        print

    if not args.quiet and errors:
        print "Some errors occurred during the command."

    return len(errors) > 0
コード例 #14
0
def info_ubootenv_command(args):
    """Print uboot info"""
    tftp = get_tftp(args)
    nodes = get_nodes(args, tftp)

    if not args.quiet:
        print "Getting u-boot environment..."
    results, errors = run_command(args, nodes, "get_ubootenv")

    # Print results
    node_strings = get_node_strings(args, results, justify=False)
    for node in nodes:
        if node in results:
            ubootenv = results[node]
            print "[ U-Boot Environment from %s ]" % node_strings[node]
            for variable in ubootenv.variables:
                print "%s=%s" % (variable, ubootenv.variables[variable])
            print

    if not args.quiet and errors:
        print "Some errors occured during the command.\n"

    return len(errors) > 0
コード例 #15
0
ファイル: info.py プロジェクト: Cynerva/cxmanage
def info_ubootenv_command(args):
    """Print uboot info"""
    tftp = get_tftp(args)
    nodes = get_nodes(args, tftp)

    if not args.quiet:
        print "Getting u-boot environment..."
    results, errors = run_command(args, nodes, "get_ubootenv")

    # Print results
    node_strings = get_node_strings(args, results, justify=False)
    for node in nodes:
        if node in results:
            ubootenv = results[node]
            print "[ U-Boot Environment from %s ]" % node_strings[node]
            for variable in ubootenv.variables:
                print "%s=%s" % (variable, ubootenv.variables[variable])
            print

    if not args.quiet and errors:
        print "Some errors occured during the command.\n"

    return len(errors) > 0
コード例 #16
0
ファイル: ipdiscover.py プロジェクト: SLS-Dev/cxmanage
def ipdiscover_command(args):
    """discover server IP addresses"""
    tftp = get_tftp(args)
    nodes = get_nodes(args, tftp)

    if not args.quiet:
        print 'Getting server-side IP addresses...'

    results, errors = run_command(args, nodes, 'get_server_ip', args.interface,
                                  args.ipv6, args.aggressive)

    if results:
        node_strings = get_node_strings(args, results, justify=True)
        print 'IP addresses (ECME, Server)'
        for node in nodes:
            if node in results:
                print '%s: %s' % (node_strings[node], results[node])
        print

    if not args.quiet and errors:
        print 'Some errors occurred during the command.'

    return len(errors) > 0