Ejemplo n.º 1
0
def do_backend_tier_create(cs, args):
    """Create a new storage tier."""
    keypair = None
    if args.metadata is not None:
        keypair = _extract_metadata(args)
    backend_tier = cs.storage_tiers.create(args.backend, args.tier_name, keypair)
    utils.print_list([backend_tier], ['id', 'name', 'storage_backend_id'])
Ejemplo n.º 2
0
def do_list_extensions(client, _args):
    """
    Lists all available os-api extensions.
    """
    extensions = client.list_extensions.show_all()
    fields = ["Name", "Summary", "Alias", "Updated"]
    utils.print_list(extensions, fields)
Ejemplo n.º 3
0
def do_service_list(cs, args):
    """Lists all services. Filter by host and service binary."""
    result = cs.services.list(host=args.host, binary=args.binary)
    columns = ["Binary", "Host", "Zone", "Status", "State", "Updated_at"]
    # NOTE(jay-lau-513): we check if the response has disabled_reason
    # so as not to add the column when the extended ext is not enabled.
    if result and hasattr(result[0], 'disabled_reason'):
        columns.append("Disabled Reason")
    utils.print_list(result, columns)
Ejemplo n.º 4
0
def do_service_disable(cs, args):
    """Disables the service."""
    columns = ["Host", "Binary", "Status"]
    if args.reason:
        columns.append('Disabled Reason')
        result = cs.services.disable_log_reason(args.host, args.binary,
                                                args.reason)
    else:
        result = cs.services.disable(args.host, args.binary)
    utils.print_list([result], columns)
Ejemplo n.º 5
0
def _print_storage_backend_list(backends, detailed = False):
    if detailed:
        for backend in backends:
            print("============== storage system info ================")
            utils.print_list([backend], ['id', 'name', 'config_specs_id', 'config_specs', 'capability_specs_id', 'capability_specs'])
            tiers = backend.tiers
            if tiers:
                print("============== tier info ================")
                for row in tiers:
                    utils.print_dict(row)
    else:
        utils.print_list(backends, ['id', 'Name', 'config_specs_id', 'capability_specs_id'])
Ejemplo n.º 6
0
    def test_print_list_with_list(self):
        Row = collections.namedtuple('Row', ['a', 'b'])
        to_print = [Row(a=1, b=2), Row(a=3, b=4)]
        with CaptureStdout() as cso:
            utils.print_list(to_print, ['a', 'b'])
        self.assertEqual(
            """\
+---+---+
| a | b |
+---+---+
| 1 | 2 |
| 3 | 4 |
+---+---+
""", cso.read())
Ejemplo n.º 7
0
    def test_print_list_with_generator(self):
        Row = collections.namedtuple('Row', ['a', 'b'])

        def gen_rows():
            for row in [Row(a=1, b=2), Row(a=3, b=4)]:
                yield row

        with CaptureStdout() as cso:
            utils.print_list(gen_rows(), ['a', 'b'])
        self.assertEqual(
            """\
+---+---+
| a | b |
+---+---+
| 1 | 2 |
| 3 | 4 |
+---+---+
""", cso.read())
Ejemplo n.º 8
0
def do_pool_list(cs, args):
    """Print a list of storage pools."""
    detailed = True if args.detail else False
    pools = cs.storage_pools.list(detailed = detailed, search_opts = _extract_search_opts(args))
    utils.print_list(pools, ['id', 'pool', 'backend_name', 'services', 'storage_backend_id', 'storage_system_name', 'storage_tier_id', 'storage_tier_name', 'section', 'host'])
Ejemplo n.º 9
0
def do_pool_create(cs, args):
    """Create a new storage backend."""
    backends = json.loads(args.backends)
    pool = cs.storage_pools.create(args.pool, args.backend_name, args.services, backends)
    utils.print_list([pool], ['pool', 'backend_name'])
Ejemplo n.º 10
0
def do_backend_tier_capability_show(cs, args):
    """Get storage tier capabilities."""
    vtype = _find_tier(cs, args.vtype)
    _specs = vtype.get_capability_keys()
    utils.print_list([_specs], ['id', 'name', 'storage_backend_id', 'capability_specs_id', 'capability_specs'])
Ejemplo n.º 11
0
def do_backend_tier_list(cs, args):
    """List storage tiers."""
    detailed = True if args.detail else False
    tiers = cs.storage_tiers.list(detailed = detailed, search_opts = _extract_search_opts(args))
    utils.print_list(tiers, ['id', 'name', 'storage_backend_id', 'capability_specs_id', 'capability_specs'])
Ejemplo n.º 12
0
def do_backend_tier_show(cs, args):
    """Get a storage backend."""
    vtype = _find_tier(cs, args.vtype)
    tier = cs.storage_tiers.get(vtype.id)
    utils.print_list([tier], ['id', 'name', 'storage_backend_id', 'capability_specs_id', 'capability_specs'])
Ejemplo n.º 13
0
def do_backend_config_show(cs, args):
    """Get storage config."""
    vtype = _find_backend(cs, args.vtype)
    _specs = vtype.get_config_keys()
    utils.print_list([_specs], ['id', 'name', 'config_specs'])
Ejemplo n.º 14
0
def _print_backend_and_extra_specs_list(backends):
    formatters = {'extra_specs': _print_type_extra_specs}
    utils.print_list(backends, ['id', 'Name', 'extra_specs'], formatters)
Ejemplo n.º 15
0
def do_service_enable(cs, args):
    """Enables the service."""
    result = cs.services.enable(args.host, args.binary)
    columns = ["Host", "Binary", "Status"]
    utils.print_list([result], columns)