Ejemplo n.º 1
0
def do_instance_action_list(cs, args):
    """List actions on a server."""
    server = utils.find_resource(cs.servers, args.server)
    actions = cs.instance_action.list(server)
    utils.print_list(actions,
                     ['Action', 'Request_ID', 'Message', 'Start_Time'],
                     sortby_index=3)
Ejemplo n.º 2
0
def do_list_extensions(client, _args):
    """
    List all the os-api extensions that are available.
    """
    extensions = client.list_extensions.show_all()
    fields = ["Name", "Summary", "Alias", "Updated"]
    utils.print_list(extensions, fields)
Ejemplo n.º 3
0
def _print_baremetal_nodes_list(nodes):
    """Print the list of baremetal nodes."""

    def _parse_address(fields):
        macs = []
        for interface in fields.interfaces:
            macs.append(interface['address'])
        return ', '.join("%s" % i for i in macs)

    formatters = {
        'MAC Address': _parse_address
    }

    _translate_baremetal_node_keys(nodes)
    utils.print_list(nodes, [
        'ID',
        'Host',
        'Task State',
        'CPUs',
        'Memory_MB',
        'Disk_GB',
        'MAC Address',
        'PM Address',
        'PM Username',
        'PM Password',
        'Terminal Port',
    ], formatters=formatters)
Ejemplo n.º 4
0
def do_instance_action_list(cs, args):
    """List actions on a server."""
    server = utils.find_resource(cs.servers, args.server)
    actions = cs.instance_action.list(server)
    utils.print_list(actions,
                     ['Action', 'Request_ID', 'Message', 'Start_Time'],
                     sortby_index=3)
Ejemplo n.º 5
0
def _print_baremetal_node_interfaces(interfaces):
    """Print interfaces of a baremetal node."""
    utils.print_list(interfaces, [
        'ID',
        'Datapath_ID',
        'Port_No',
        'Address',
    ])
Ejemplo n.º 6
0
def do_host_servers_migrate(cs, args):
    """Migrate all instances of the specified host to other available hosts."""
    hypervisors = cs.hypervisors.search(args.host, servers=True)
    response = []
    for hyper in hypervisors:
        if hasattr(hyper, 'servers'):
            for server in hyper.servers:
                response.append(_server_migrate(cs, server))

    utils.print_list(response,
                     ["Server UUID", "Migration Accepted", "Error Message"])
Ejemplo n.º 7
0
def do_host_evacuate(cs, args):
    """Evacuate all instances from failed host."""
    hypervisors = cs.hypervisors.search(args.host, servers=True)
    response = []
    for hyper in hypervisors:
        if hasattr(hyper, 'servers'):
            for server in hyper.servers:
                response.append(_server_evacuate(cs, server, args))

    utils.print_list(response,
                     ["Server UUID", "Evacuate Accepted", "Error Message"])
Ejemplo n.º 8
0
 def _dump_timings(self, timings):
     class Tyme(object):
         def __init__(self, url, seconds):
             self.url = url
             self.seconds = seconds
     results = [Tyme(url, end - start) for url, start, end in timings]
     total = 0.0
     for tyme in results:
         total += tyme.seconds
     results.append(Tyme("Total", total))
     utils.print_list(results, ["url", "seconds"], sortby_index=None)
Ejemplo n.º 9
0
def do_host_evacuate(cs, args):
    """Evacuate all instances from failed host."""
    hypervisors = cs.hypervisors.search(args.host, servers=True)
    response = []
    for hyper in hypervisors:
        if hasattr(hyper, 'servers'):
            for server in hyper.servers:
                response.append(_server_evacuate(cs, server, args))

    utils.print_list(response,
                     ["Server UUID", "Evacuate Accepted", "Error Message"])
Ejemplo n.º 10
0
    def _dump_timings(self, timings):
        class Tyme(object):
            def __init__(self, url, seconds):
                self.url = url
                self.seconds = seconds

        results = [Tyme(url, end - start) for url, start, end in timings]
        total = 0.0
        for tyme in results:
            total += tyme.seconds
        results.append(Tyme("Total", total))
        utils.print_list(results, ["url", "seconds"], sortby_index=None)
Ejemplo n.º 11
0
def do_host_evacuate_live(cs, args):
    """Live migrate all instances of the specified host
    to other available hosts.
    """
    hypervisors = cs.hypervisors.search(args.host, servers=True)
    response = []
    for hyper in hypervisors:
        for server in getattr(hyper, 'servers', []):
            response.append(_server_live_migrate(cs, server, args))

    utils.print_list(response, ["Server UUID", "Live Migration Accepted",
                                "Error Message"])
Ejemplo n.º 12
0
def do_host_evacuate_live(cs, args):
    """Live migrate all instances of the specified host
    to other available hosts.
    """
    hypervisors = cs.hypervisors.search(args.host, servers=True)
    response = []
    for hyper in hypervisors:
        for server in getattr(hyper, 'servers', []):
            response.append(_server_live_migrate(cs, server, args))

    utils.print_list(
        response, ["Server UUID", "Live Migration Accepted", "Error Message"])
Ejemplo n.º 13
0
def _print_migrations(migrations):
    fields = ['Source Node', 'Dest Node', 'Source Compute', 'Dest Compute',
              'Dest Host', 'Status', 'Instance UUID', 'Old Flavor',
              'New Flavor', 'Created At', 'Updated At']

    def old_flavor(migration):
        return migration.old_instance_type_id

    def new_flavor(migration):
        return migration.new_instance_type_id

    formatters = {'Old Flavor': old_flavor, 'New Flavor': new_flavor}

    utils.print_list(migrations, fields, formatters)
Ejemplo n.º 14
0
    def test_print_list_sort_by_none(self):
        objs = [_FakeResult("k1", 1),
                _FakeResult("k3", 3),
                _FakeResult("k2", 2)]

        utils.print_list(objs, ["Name", "Value"], sortby_index=None)

        self.assertEqual('+------+-------+\n'
                         '| Name | Value |\n'
                         '+------+-------+\n'
                         '| k1   | 1     |\n'
                         '| k3   | 3     |\n'
                         '| k2   | 2     |\n'
                         '+------+-------+\n',
                         sys.stdout.getvalue())
Ejemplo n.º 15
0
def do_tenant_network_list(cs, args):
    """
    List tenant networks.
    """
    networks = cs.tenant_networks.list()
    utils.print_list(networks, ['ID', 'Label', 'CIDR'])
Ejemplo n.º 16
0
def do_tenant_network_list(cs, args):
    """
    List tenant networks.
    """
    networks = cs.tenant_networks.list()
    utils.print_list(networks, ["ID", "Label", "CIDR"])