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)
def do_datastore_list(cs, args): """List a pool of datastores.""" datastores = cs.datastores.list() utils.print_list(datastores, [ 'id', 'identifier', 'id_storage_types', 'endpoint', 'store', 'status', 'resource_type' ])
def do_service_list(cs, args): """List all the services by zone, role and component.""" zone = _find_zone(cs, args.zone) role = _find_role(cs, args.zone, args.role) component = _find_component(cs, args.component) services = cs.services.list_zone_role_component(zone, role, component) utils.print_list(services, ['Name', 'description'])
def do_datastore_discovery(cs, args): """Discovery endpoints from NFS.""" options = { 'storage_type': 'NFS', 'endpoint': args.endpoint } datastores = cs.datastores.discovery(**options) utils.print_list(datastores, ['store', 'allowed'])
def do_role_deploy(cs, args): """Associate a role to a node.""" zone = _find_zone(cs, args.zone) role = _find_role(cs, args.zone, args.role) node = _find_node(cs, args.zone, args.node) tasks = cs.tasks.deploy(zone, role, node, args.bypass, args.hostname, not args.no_dhcp_reload) utils.print_list(tasks, ['id', 'name', 'uuid', 'state', 'result'])
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(cso.read(), """\ +---+---+ | a | b | +---+---+ | 1 | 2 | | 3 | 4 | +---+---+ """)
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( cso.read(), """\ +---+---+ | a | b | +---+---+ | 1 | 2 | | 3 | 4 | +---+---+ """)
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(cso.read(), """\ +---+---+ | a | b | +---+---+ | 1 | 2 | | 3 | 4 | +---+---+ """)
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( cso.read(), """\ +---+---+ | a | b | +---+---+ | 1 | 2 | | 3 | 4 | +---+---+ """)
def do_zone_tasks_list(cs, args): """List all the tasks by zone.""" zone = _find_zone(cs, args.zone) tasks = cs.tasks.list(zone) utils.print_list(tasks, ['id', 'name', 'uuid', 'state'])
def do_profile_list(cs, args): """List all the profiles by architecture.""" architecture = _find_architecture(cs, args.architecture) profiles = cs.profiles.list(architecture) utils.print_list(profiles, ['id', 'name'])
def do_zone_list(cs, args): """List all the zones.""" zones = cs.zones.list() utils.print_list(zones, ['id', 'name'])
def do_datastore_discovery(cs, args): """Discovery endpoints from NFS.""" options = {'storage_type': 'NFS', 'endpoint': args.endpoint} datastores = cs.datastores.discovery(**options) utils.print_list(datastores, ['store', 'allowed'])
def do_role_list(cs, args): """List all the roles by zone.""" zone = _find_zone(cs, args.zone) roles = cs.roles.list(zone) utils.print_list(roles, ['id', 'name'])
def do_component_services(cs, args): """List all the services by a component.""" component = _find_component(cs, args.component) services = cs.services.list(component) utils.print_list(services, ['Name', 'description'])
def do_role_component_list(cs, args): """List all components by zone and role.""" zone = _find_zone(cs, args.zone) role = _find_role(cs, args.zone, args.role) components = cs.components.list_zone_role(zone, role) utils.print_list(components, ['id', 'name'])
def do_device_list(cs, args): """List all the devices in the pool.""" devices = cs.devices.list() utils.print_list(devices, ['id', 'name', 'mac', 'status'])
def do_node_list(cs, args): """List all activate devices in a zone.""" zone = _find_zone(cs, args.zone) nodes = cs.nodes.list(zone) utils.print_list(nodes, ['id', 'name', 'mac', 'status'])
def do_datastore_list(cs, args): """List a pool of datastores.""" datastores = cs.datastores.list() utils.print_list(datastores, ['id', 'identifier', 'id_storage_types', 'endpoint', 'store', 'status', 'resource_type'])
def do_node_tasks_list(cs, args): """List all tasks from a node in a zone.""" zone = _find_zone(cs, args.zone) node = _find_node(cs, args.zone, args.node) tasks = cs.tasks.list_node(zone, node) utils.print_list(tasks, ['id', 'name', 'uuid', 'state'])
def do_component_list(cs, args): """List all the components that are available on automation.""" components = cs.components.list() utils.print_list(components, ['name'])
def do_architecture_list(cs, args): """List all the architectures that are available on automation.""" architectures = cs.architectures.list() utils.print_list(architectures, ['id', 'name'])