Пример #1
0
def do_cell_update(cc, args):
    """Update a cell that is registered with the Craton service."""
    fields = {
        k: v
        for (k, v) in vars(args).items() if k in c_fields and not (v is None)
    }
    cell = cc.inventory(args.region).cells.update(**fields)
    data = {f: getattr(cell, f, '') for f in c_fields}
    cliutils.print_dict(data, wrap=72)
Пример #2
0
def do_host_create(cc, args):
    """Register a new host with the Craton service."""
    fields = {
        k: v
        for (k, v) in vars(args).items() if k in h_fields and not (v is None)
    }
    host = cc.inventory(args.region_id).hosts.create(**fields)
    data = {f: getattr(host, f, '') for f in h_fields}
    cliutils.print_dict(data, wrap=72)
Пример #3
0
def do_region_create(cc, args):
    """Register a new region with the Craton service."""
    fields = {
        k: v
        for (k, v) in vars(args).items() if k in r_fields and not (v is None)
    }

    region = cc.regions.create(**fields)
    data = {f: getattr(region, f, '') for f in r_fields}
    cliutils.print_dict(data, wrap=72)
Пример #4
0
def do_host_update(cc, args):
    """Update a host that is registered with the Craton service."""
    fields = {
        k: v
        for (k, v) in vars(args).items() if k in h_fields and not (v is None)
    }
    host = cc.inventory(args.region).hosts.update(**fields)
    print("Host {0} has been successfully update.".format(host.id))
    data = {f: getattr(host, f, '') for f in h_fields}
    cliutils.print_dict(data, wrap=72)
Пример #5
0
def do_cell_show(cc, args):
    """Show detailed information about a cell."""
    cell = cc.inventory(args.region).cells.get(args.id)
    data = {f: getattr(cell, f, '') for f in c_fields}
    cliutils.print_dict(data, wrap=72)
Пример #6
0
def do_host_show(cc, args):
    """Show detailed information about a host."""
    host = cc.inventory(args.region).hosts.get(args.id)
    data = {f: getattr(host, f, '') for f in h_fields}
    cliutils.print_dict(data, wrap=72)