Exemple #1
0
def vm_details(s, opt):
    vm = vm_get(s, opt['<name>'])
    if not vm:
        return

    d = vm.details()
    details = {
        'Name': d.name,
        'Instance UUID': d.instance_uuid[0],
        'Bios UUID': d.bios_uuid,
        'Path to VM': d.path,
        'Guest OS id': d.guest_id[0],
        'Guest OS name': d.guest_name,
        'Host': d.host[0],
        'Last booted timestamp': d.ts
    }

    for name, value in details.items():
        print("  {0:{width}{base}}: {1}".format(name,
                                                value,
                                                width=25,
                                                base='s'))

    print("  Devices:")
    print("  --------")
    for dev in d.devices:
        dev_details = {'summary': dev.summary, 'device type': dev.type}

        print("  label: {0}".format(dev.label))
        print("  ------------------")
        for name, value in dev_details.items():
            print("    {0:{width}{base}}: {1}".format(name,
                                                      value,
                                                      width=15,
                                                      base='s'))

            ds = dev.ds
            if ds is None:
                continue

            print("    datastore")
            print("        name: {0}".format(ds.ds_name))
            print("        summary")
            summary = {
                'capacity': sizeof_fmt(ds.ds_capacity),
                'freeSpace': sizeof_fmt(ds.ds_freespace),
                'file system': ds.ds_fs,
                'url': ds.ds_url
            }
            for key, val in summary.items():
                print("            {0}: {1}".format(key, val))
            print("    fileName: {0}".format(ds.filename))
            print("  ------------------")
Exemple #2
0
def vm_details(s, opt):
    vm = vm_get(s, opt['<name>'])
    if not vm:
        return

    d = vm.details()
    details = {
        'Name': d.name,
        'Instance UUID': d.instance_uuid[0],
        'Bios UUID': d.bios_uuid,
        'Path to VM': d.path,
        'Guest OS id': d.guest_id[0],
        'Guest OS name': d.guest_name,
        'Host': d.host[0],
        'Last booted timestamp': d.ts
    }

    for name, value in details.items():
        print("  {0:{width}{base}}: {1}".format(name, value, width=25, base='s'))

    print("  Devices:")
    print("  --------")
    for dev in d.devices:
        dev_details = {
            'summary': dev.summary,
            'device type': dev.type
        }

        print("  label: {0}".format(dev.label))
        print("  ------------------")
        for name, value in dev_details.items():
            print("    {0:{width}{base}}: {1}".format(name, value, width=15, base='s'))

            ds = dev.ds
            if ds is None:
                continue

            print("    datastore")
            print("        name: {0}".format(ds.ds_name))
            print("        summary")
            summary = {
                'capacity': sizeof_fmt(ds.ds_capacity),
                'freeSpace': sizeof_fmt(ds.ds_freespace),
                'file system': ds.ds_fs,
                'url': ds.ds_url
            }
            for key, val in summary.items():
                print("            {0}: {1}".format(key, val))
            print("    fileName: {0}".format(ds.filename))
            print("  ------------------")
Exemple #3
0
def host_print_details(hosts):
    headers = [
        "Key", "Name", "Version", "IP", "Status", "Mem", "Mem Usage",
        "Mem Fairness", "CPUs", "Cores", "Threads", "CPU Usage",
        "CPU Fairness", "NICs", "VMs", "Uptime"
    ]
    tabs = []
    for host in hosts:
        info = host.info()

        mem = sizeof_fmt(info.mem_size)
        mem_usage = "{0} %".format(
            round(info.mem_usage * 100 / float(info.mem_size), 2))
        cpu_usage = "{0} %".format(
            round(info.mean_core_usage_mhz * 100 / float(info.cpu_mhz), 2))

        vals = [
            host.key, info.name, info.version, info.ip, info.status, mem,
            mem_usage, info.mem_fairness, info.cpu, info.cores, info.threads,
            cpu_usage, info.cpu_fairness, info.nics, info.vms,
            humanize_time(info.uptime)
        ]
        tabs.append(vals)

    print tabulate(tabs, headers)
Exemple #4
0
def ds_print_details(ds):
    tabs = []
    headers = [ "Key", "Name", "Type", "Capacity", "Free Space", "Local", "SSD", "Remote Host", "Remote Path" ]

    for d in ds:
        d.info()
        local = "False"
        if d.local: local = "True"
        ssd = "False"
        if d.ssd: ssd = "True"

        vals = [ d.key, d.name, d.type, sizeof_fmt(d.capacity), sizeof_fmt(d.free_space),
                 local, ssd, d.host, d.path ]
        tabs.append(vals)

    print tabulate(tabs, headers)
Exemple #5
0
def ds_print_content(files):
    tabs = []
    headers = [ "Name", "Size", "Owner", "Modification Time" ]

    for f in files:
        vals = [ f.fullpath, sizeof_fmt(f.size), f.owner, f.modification ]
        tabs.append(vals)

    print tabulate(tabs, headers)
Exemple #6
0
def cluster_print_details(clusters):
    headers = [ "Key", "Name", "Status", "Hosts", "Cores", "Threads", "Memory" ]
    tabs = []
    for cl in clusters:
        info = cl.info()
        vals = [ cl.key, cl.name, cl.status,
                 info.hosts, info.cores, info.threads, sizeof_fmt(info.mem) ]
        tabs.append(vals)

    print tabulate(tabs, headers)
Exemple #7
0
def cluster_print_details(clusters):
    headers = ["Key", "Name", "Status", "Hosts", "Cores", "Threads", "Memory"]
    tabs = []
    for cl in clusters:
        info = cl.info()
        vals = [
            cl.key, cl.name, cl.status, info.hosts, info.cores, info.threads,
            sizeof_fmt(info.mem)
        ]
        tabs.append(vals)

    print tabulate(tabs, headers)
Exemple #8
0
def host_hw(s, opt):
    host = host_get(s, opt['<name>'])
    if not host:
        return

    hw = host.hw()
    print "Model: {0} {1}".format(hw.vendor, hw.model)
    print " - CPUs: {0}".format(hw.cpu)
    for p in hw.desc:
        print "  + {0}".format(p)
    print " - Cores: {0}".format(hw.cores)
    print " - Threads: {0}".format(hw.threads)
    print " - Memory: {0}".format(sizeof_fmt(hw.mem))
    print " - Devices:"
    for d in hw.devices:
        print "  + {0} {1}".format(d[0], d[1])
Exemple #9
0
def host_hw(s, opt):
    host = host_get(s, opt['<name>'])
    if not host:
        return

    hw = host.hw()
    print "Model: {0} {1}".format(hw.vendor, hw.model)
    print " - CPUs: {0}".format(hw.cpu)
    for p in hw.desc:
        print "  + {0}".format(p)
    print " - Cores: {0}".format(hw.cores)
    print " - Threads: {0}".format(hw.threads)
    print " - Memory: {0}".format(sizeof_fmt(hw.mem))
    print " - Devices:"
    for d in hw.devices:
        print "  + {0} {1}".format(d[0], d[1])
Exemple #10
0
def host_print_details(hosts):
    headers = [ "Key", "Name", "Version", "IP", "Status", "Mem", "Mem Usage", "Mem Fairness",
                "CPUs", "Cores", "Threads", "CPU Usage", "CPU Fairness",
                "NICs", "VMs", "Uptime" ]
    tabs = []
    for host in hosts:
        info = host.info()

        mem = sizeof_fmt(info.mem_size)
        mem_usage = "{0} %".format(round(info.mem_usage * 100 / float(info.mem_size), 2))
        cpu_usage = "{0} %".format(round(info.mean_core_usage_mhz * 100 / float(info.cpu_mhz), 2))

        vals = [ host.key, info.name, info.version, info.ip, info.status, mem, mem_usage, info.mem_fairness,
                 info.cpu, info.cores, info.threads, cpu_usage, info.cpu_fairness,
                 info.nics, info.vms, humanize_time(info.uptime) ]
        tabs.append(vals)

    print tabulate(tabs, headers)