#coding:utf-8

import sunhpc.commands
from sunhpc.db.mappings.base import *
class command(sunhpc.commands.HostArgumentProcessor,
    sunhpc.commands.list.command):
    pass
    
class Command(command):
    """
    List the CPU count and physical position info for
    a list of hosts.

    <arg optional='1' type='string' name='host' repeat='1'>
    Zero, one or more host names. If no host names are supplied, info about
    all the known hosts is listed.
    </arg>
    
    <example cmd='list host compute-0-0'>
    List info for compute-0-0.
    </example>

    <example cmd='list host'>
    List info for all known hosts.
    </example>
    """

    def run(self, params, args):
        self.beginOutput()

        for host in self.newdb.getNodesfromNames(args):
            self.addOutput(host.name, [host.cpus, host.rack, 
                host.rank, host.os, host.arch, host.alias, host.status])
            
        self.endOutput(header=['host', 'cpus', 'rack', 
                    'rank', 'os', 'arch', 'alias', 'status'])

RollName = "base"
