Пример #1
0
def do_environment_list(mc, args={}):
    """List the environments."""
    all_tenants = getattr(args, 'all_tenants', False)
    environments = mc.environments.list(all_tenants)
    field_labels = ['ID', 'Name', 'Created', 'Updated']
    fields = ['id', 'name', 'created', 'updated']
    utils.print_list(environments, fields, field_labels, sortby=0)
Пример #2
0
def do_app_show(mc, args):
    """List applications, added to specified environment.
    """
    if args.path == '/':
        apps = mc.services.list(args.id)
        formatters = {
            'id': lambda x: getattr(x, '?')['id'],
            'type': lambda x: getattr(x, '?')['type']
        }
        field_labels = ['Id', 'Name', 'Type']
        fields = ['id', 'name', 'type']
        utils.print_list(apps, fields, field_labels, formatters=formatters)
    else:
        if not args.path.startswith('/'):
            args.path = '/' + args.path
        app = mc.services.get(args.id, args.path)

        # If app with specified path is not found, it is empty.
        if hasattr(app, '?'):
            formatters = {}
            for key in app.to_dict().keys():
                formatters[key] = utils.json_formatter
            utils.print_dict(app.to_dict(), formatters)
        else:
            raise exceptions.CommandError("Could not find application at path"
                                          " %s" % args.path)
Пример #3
0
def do_deployment_list(mc, args):
    """List deployments for an environment or multiple environments."""
    all_environments = getattr(args, 'all_environments', False)
    env_id = getattr(args, 'id', None)
    if env_id and all_environments:
        raise exceptions.CommandError(
            'Environment ID and all-environments flag cannot both be set.')
    elif not env_id and not all_environments:
        raise exceptions.CommandError(
            'Either environment ID or all-environments flag must be set.')
    try:
        if all_environments:
            deployments = mc.deployments.list(None, all_environments)
        else:
            environment = utils.find_resource(mc.environments, env_id)
            deployments = mc.deployments.list(environment.id)
    except exceptions.NotFound:
        if env_id:
            msg = "Environment %s not found" % env_id
        else:
            msg = "Environments not found"
        raise exceptions.CommandError(msg)
    else:
        field_labels = ["ID", "State", "Created", "Updated", "Finished"]
        fields = ["id", "state", "created", "updated", "finished"]
        utils.print_list(deployments, fields, field_labels, sortby=0)
Пример #4
0
def do_deployment_list(mc, args):
    """List deployments for an environment or multiple environments."""
    all_environments = getattr(args, 'all_environments', False)
    env_id = getattr(args, 'id', None)
    if env_id and all_environments:
        raise exceptions.CommandError(
            'Environment ID and all-environments flag cannot both be set.')
    elif not env_id and not all_environments:
        raise exceptions.CommandError(
            'Either environment ID or all-environments flag must be set.')
    try:
        if all_environments:
            deployments = mc.deployments.list(None, all_environments)
        else:
            environment = utils.find_resource(mc.environments, env_id)
            deployments = mc.deployments.list(environment.id)
    except exceptions.NotFound:
        if env_id:
            msg = "Environment %s not found" % env_id
        else:
            msg = "Environments not found"
        raise exceptions.CommandError(msg)
    else:
        field_labels = ["ID", "State", "Created", "Updated", "Finished"]
        fields = ["id", "state", "created", "updated", "finished"]
        utils.print_list(deployments, fields, field_labels, sortby=0)
Пример #5
0
def do_environment_list(mc, args={}):
    """List the environments."""
    all_tenants = getattr(args, 'all_tenants', False)
    environments = mc.environments.list(all_tenants)
    field_labels = ['ID', 'Name', 'Created', 'Updated']
    fields = ['id', 'name', 'created', 'updated']
    utils.print_list(environments, fields, field_labels, sortby=0)
Пример #6
0
def _print_package_list(packages):
    field_labels = [
        "ID", "Name", "FQN", "Author", "Active", "Is Public", "Type"
    ]
    fields = [
        "id", "name", "fully_qualified_name", "author", "enabled", "is_public",
        "type"
    ]
    utils.print_list(packages, fields, field_labels, sortby=0)
Пример #7
0
def do_package_list(mc, args={}):
    """List available packages."""
    filter_args = {
        "include_disabled": getattr(args, 'include_disabled', False),
    }
    packages = mc.packages.filter(**filter_args)
    field_labels = ["ID", "Name", "FQN", "Author", "Is Public"]
    fields = ["id", "name", "fully_qualified_name", "author", "is_public"]
    utils.print_list(packages, fields, field_labels, sortby=0)
Пример #8
0
def do_deployment_list(mc, args):
    """List deployments for an environment."""
    try:
        environment = utils.find_resource(mc.environments, args.id)
        deployments = mc.deployments.list(environment.id)
    except exceptions.NotFound:
        raise exceptions.CommandError("Environment %s not found" % args.id)
    else:
        field_labels = ["ID", "State", "Created", "Updated", "Finished"]
        fields = ["id", "state", "created", "updated", "finished"]
        utils.print_list(deployments, fields, field_labels, sortby=0)
Пример #9
0
def do_deployment_list(mc, args):
    """List deployments for an environment."""
    try:
        environment = utils.find_resource(mc.environments, args.id)
        deployments = mc.deployments.list(environment.id)
    except exceptions.NotFound:
        raise exceptions.CommandError("Environment %s not found" % args.id)
    else:
        field_labels = ["ID", "State", "Created", "Updated", "Finished"]
        fields = ["id", "state", "created", "updated", "finished"]
        utils.print_list(deployments, fields, field_labels, sortby=0)
Пример #10
0
def do_package_list(mc, args={}):
    """List available packages."""
    filter_args = {
        "include_disabled": getattr(args, 'include_disabled', False),
        "limit": getattr(args, 'limit', DEFAULT_PAGE_SIZE),
    }
    packages = mc.packages.filter(**filter_args)
    field_labels = ["ID", "Name", "FQN", "Author", "Active", "Is Public"]
    fields = [
        "id", "name", "fully_qualified_name", "author", "enabled", "is_public"
    ]
    utils.print_list(packages, fields, field_labels, sortby=0)
Пример #11
0
def do_app_show(mc, args):
    """List applications, added to specified environment.
    """
    if args.path == '/':
        apps = mc.services.list(args.id)
    else:
        if not args.path.startswith('/'):
            args.path = '/' + args.path
            apps = [mc.services.get(args.id, args.path)]

    field_labels = ['Id', 'Name', 'Type']
    fields = ['id', 'name', 'type']
    formatters = {}

    # If app list is empty, first element exists and it's None
    if hasattr(apps[0], '?'):
        formatters = {'id': lambda x: getattr(x, '?')['id'],
                      'type': lambda x: getattr(x, '?')['type']}

    utils.print_list(apps, fields, field_labels, formatters=formatters)
Пример #12
0
def do_app_show(mc, args):
    """List applications, added to specified environment."""
    if args.path == '/':
        apps = mc.services.list(args.id)
        formatters = {'id': lambda x: getattr(x, '?')['id'],
                      'type': lambda x: getattr(x, '?')['type']}
        field_labels = ['Id', 'Name', 'Type']
        fields = ['id', 'name', 'type']
        utils.print_list(apps, fields, field_labels, formatters=formatters)
    else:
        if not args.path.startswith('/'):
            args.path = '/' + args.path
        app = mc.services.get(args.id, args.path)

        # If app with specified path is not found, it is empty.
        if hasattr(app, '?'):
            formatters = {}
            for key in app.to_dict().keys():
                formatters[key] = utils.json_formatter
            utils.print_dict(app.to_dict(), formatters)
        else:
            raise exceptions.CommandError("Could not find application at path"
                                          " %s" % args.path)
Пример #13
0
def _print_category_list(categories):
    field_labels = ["ID", "Name"]
    fields = ["id", "name"]
    utils.print_list(categories, fields, field_labels)
Пример #14
0
def _print_env_template_list(env_templates):
    field_labels = ['ID', 'Name', 'Created', 'Updated', 'Is public']
    fields = ['id', 'name', 'created', 'updated', 'is_public']
    utils.print_list(env_templates, fields, field_labels, sortby=0)
Пример #15
0
def _print_category_list(categories):
    field_labels = ["ID", "Name"]
    fields = ["id", "name"]
    utils.print_list(categories, fields, field_labels)
Пример #16
0
def _print_environment_list(environments):
    field_labels = ['ID', 'Name', 'Status', 'Created', 'Updated']
    fields = ['id', 'name', 'status', 'created', 'updated']
    utils.print_list(environments, fields, field_labels, sortby=0)
Пример #17
0
def do_category_list(mc, args={}):
    """List all available categories."""
    categories = mc.categories.list()
    field_labels = ["ID", "Name"]
    fields = ["id", "name"]
    utils.print_list(categories, fields, field_labels)
Пример #18
0
def do_environment_list(mc, args={}):
    """List the environments"""
    environments = mc.environments.list()
    field_labels = ['ID', 'Name', 'Created', 'Updated']
    fields = ['id', 'name', 'created', 'updated']
    utils.print_list(environments, fields, field_labels, sortby=0)
Пример #19
0
def do_environment_list(cc, args={}):
    """List the environments"""
    environments = cc.environments.list()
    field_labels = ['ID', 'Name', 'Created', 'Updated']
    fields = ['id', 'name', 'created', 'updated']
    utils.print_list(environments, fields, field_labels, sortby=0)
Пример #20
0
def _print_env_template_list(env_templates):
    field_labels = ['ID', 'Name', 'Created', 'Updated', 'Is public']
    fields = ['id', 'name', 'created', 'updated', 'is_public']
    utils.print_list(env_templates, fields, field_labels, sortby=0)
Пример #21
0
def do_category_list(mc, args={}):
    """List all available categories."""
    categories = mc.categories.list()
    field_labels = ["ID", "Name"]
    fields = ["id", "name"]
    utils.print_list(categories, fields, field_labels)
Пример #22
0
def _print_environment_list(environments):
    field_labels = ['ID', 'Name', 'Status', 'Created', 'Updated']
    fields = ['id', 'name', 'status', 'created', 'updated']
    utils.print_list(environments, fields, field_labels, sortby=0)
Пример #23
0
def _print_package_list(packages):
    field_labels = ["ID", "Name", "FQN", "Author", "Active",
                    "Is Public", "Type", "Version"]
    fields = ["id", "name", "fully_qualified_name", "author",
              "enabled", "is_public", "type", "version"]
    utils.print_list(packages, fields, field_labels, sortby=0)
Пример #24
0
def do_env_template_list(mc, args={}):
    """List the environments templates."""
    env_templates = mc.env_templates.list()
    field_labels = ['ID', 'Name', 'Created', 'Updated']
    fields = ['id', 'name', 'created', 'updated']
    utils.print_list(env_templates, fields, field_labels, sortby=0)