예제 #1
0
def do_list(cs, args):
    """List of all Migrations"""
    search_opts = {
        'name': args.name,
        'resource': args.resource,
        'destination': args.destination,
        'status': args.status
    }
    field_titles = []
    if args.fields:
        for field_title in args.fields.split(','):
            field_titles.append(field_title)

    migrations = cs.migrations.list(search_opts=search_opts,
                                    marker=args.marker,
                                    limit=args.limit,
                                    sort=args.sort)
    if field_titles:
        key_list = ['ID'] + field_titles
    else:
        key_list = ['ID', 'Name', 'Resource', 'Destination', 'Status', 'Event']
    if args.sort:
        sortby_index = None
    else:
        sortby_index = 0

    utils.print_list(migrations, key_list, exclude_unavailable=True,
                     sortby_index=sortby_index)
예제 #2
0
def do_resource_list(cs, args):
    """Get resources list"""
    source_id = None
    if args.source:
        source_ref = utils.find_cloud(cs, args.source, type='source')
        source_id = source_ref.id

    search_opts = {
        'name': args.name,
        'type': args.type,
        'cloud_id': source_id,
        'type': args.type
    }
    field_titles = []
    if args.fields:
        for field_title in args.fields.split(','):
            field_titles.append(field_title)

    resources = cs.resources.list(search_opts=search_opts,
                                  marker=args.marker,
                                  limit=args.limit,
                                  sort=args.sort)
    if field_titles:
        key_list = ['ID'] + field_titles
    else:
        key_list = ['ID', 'Name', 'Type', 'cloud']
    if args.sort:
        sortby_index = None
    else:
        sortby_index = 0
    utils.print_list(resources, key_list, exclude_unavailable=True,
                     sortby_index=sortby_index)
예제 #3
0
def _cloud_list(cs, args, type=None):
    search_opts = {
        'name': args.name,
        'enabled': args.enabled,
        'driver': args.driver,
        'type': type or args.type
    }
    field_titles = []
    if args.fields:
        for field_title in args.fields.split(','):
            field_titles.append(field_title)

    clouds = cs.clouds.list(search_opts=search_opts,
                            marker=args.marker,
                            limit=args.limit,
                            sort=args.sort)
    if field_titles:
        key_list = ['ID'] + field_titles
    else:
        key_list = ['ID', 'Name', 'Capabilities', 'Driver', 'Enabled']
    if args.sort:
        sortby_index = None
    else:
        sortby_index = 0
    if not type:
        key_list = key_list + ['Type']
    for cloud in clouds:
        cloud.driver = cloud.driver.split('.')[-1]
        cloud.capabilities = _list_to_string(cloud.capabilities)
    utils.print_list(clouds, key_list, exclude_unavailable=True,
                     sortby_index=sortby_index)
예제 #4
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)
예제 #5
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", "Status", "State", "Updated_at"]

    if result and hasattr(result[0], 'disabled_reason'):
        columns.append("Disabled Reason")
    utils.print_list(result, columns)
예제 #6
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)
예제 #7
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)