Ejemplo n.º 1
0
    def run(self):
        org_name = self.get_option('org')
        filter_name = self.get_option('name')
        filter_id = self.get_option('id')
        definition_label = self.get_option('definition_label')
        definition_name = self.get_option('definition_name')
        definition_id = self.get_option('definition_id')

        definition = get_cv_definition(org_name, definition_label,
                                       definition_name, definition_id)

        # this'll check that filter_id exists and if not, display a user-friendly message
        filter_id = get_filter(org_name, definition["id"], filter_name, filter_id)["id"]

        cvd_filter = self.api.get_filter_info(filter_id, definition["id"], org_name)

        self.printer.add_column('id', _("ID"))
        self.printer.add_column('name', _("Name"))
        self.printer.add_column('content_view_definition_label', _("Content View Definition"))
        self.printer.add_column('organization', _('Org'))
        self.printer.add_column('products', _("Products"), multiline=True)
        self.printer.add_column('repos', _("Repos"), multiline=True)
        self.printer.add_column('rules', _("Rules"), multiline=True, value_formatter = Info.rules_formatter)
        self.printer.set_header(_("Content View Definition Filter Info"))
        self.printer.print_item(cvd_filter)
        return os.EX_OK
Ejemplo n.º 2
0
    def run(self):
        org_name    = self.get_option('org')
        label       = self.get_option('label')
        name        = self.get_option('name')
        def_id      = self.get_option('id')
        view_label  = self.get_option('view_label')
        view_name   = self.get_option('view_name')
        description = self.get_option('description')
        async       = self.get_option('async')
        cvd         = get_cv_definition(org_name, label, name, def_id)


        task = self.api.publish(org_name, cvd["id"], view_name, view_label, description)

        if not async:
            task = AsyncTask(task)
            run_spinner_in_bg(wait_for_async_task, [task],
                              message=_("Publishing content view, please wait..."))

            return evaluate_task_status(task,
                ok =     _("Content view [ %s ] published successfully.") % view_name,
                failed = _("Content view [ %s ] failed to be promoted") % view_name
            )

        else:
            print _("Publish task [ %s ] was successfully created.") % task['uuid']
            return os.EX_OK
Ejemplo n.º 3
0
    def run(self):
        org_name = self.get_option('org')
        filter_name = self.get_option('name')
        filter_id = self.get_option('id')
        rule = self.get_option('rule')
        definition_label = self.get_option('definition_label')
        definition_name = self.get_option('definition_name')
        definition_id = self.get_option('definition_id')
        content = self.get_option('content')
        inclusion_type = self.get_option('inclusion')

        if not inclusion_type in self.inclusion_types:
            print _("Invalid inclusion type '%(input)s'. Valid inclusion types: %(types)s") % \
                {'input': inclusion_type, 'types': (", ".join(self.inclusion_types))}
            return os.EX_DATAERR

        inclusion = (inclusion_type == "includes")

        definition = get_cv_definition(org_name, definition_label,
                                       definition_name, definition_id)
        cvd_filter = get_filter(org_name, definition["id"], filter_name, filter_id)

        self.api.create_rule(cvd_filter["id"], definition["id"], org_name, rule, content, inclusion)
        print _("Successfully created rule [ %s ]") % rule
        return os.EX_OK
    def run(self):
        org_name    = self.get_option('org')
        label       = self.get_option('label')
        name        = self.get_option('name')
        def_id      = self.get_option('id')
        view_label  = self.get_option('view_label')
        view_name   = self.get_option('view_name')
        description = self.get_option('description')
        async       = self.get_option('async')
        cvd         = get_cv_definition(org_name, label, name, def_id)


        task = self.api.publish(org_name, cvd["id"], view_name, view_label, description)

        if not async:
            task = AsyncTask(task)
            run_spinner_in_bg(wait_for_async_task, [task],
                              message=_("Publishing content view, please wait..."))

            return evaluate_task_status(task,
                ok =     _("Content view [ %s ] published successfully.") % view_name,
                failed = _("Content view [ %s ] failed to be promoted") % view_name
            )

        else:
            print _("Publish task [ %s ] was successfully created.") % task['uuid']
            return os.EX_OK
Ejemplo n.º 5
0
    def run(self):
        org_name = self.get_option('org')
        filter_name = self.get_option('name')
        filter_id = self.get_option('id')
        definition_label = self.get_option('definition_label')
        definition_name = self.get_option('definition_name')
        definition_id = self.get_option('definition_id')

        definition = get_cv_definition(org_name, definition_label,
                                       definition_name, definition_id)

        # this'll check that filter_id exists and if not, display a user-friendly message
        filter_id = get_filter(org_name, definition["id"], filter_name, filter_id)["id"]

        cvd_filter = self.api.get_filter_info(filter_id, definition["id"], org_name)

        self.printer.add_column('id', _("ID"))
        self.printer.add_column('name', _("Name"))
        self.printer.add_column('content_view_definition_label', _("Content View Definition"))
        self.printer.add_column('organization', _('Org'))
        self.printer.add_column('products', _("Products"), multiline=True)
        self.printer.add_column('repos', _("Repos"), multiline=True)
        self.printer.add_column('rules', _("Rules"), multiline=True, value_formatter = Info.rules_formatter)
        self.printer.set_header(_("Content View Definition Filter Info"))
        self.printer.print_item(cvd_filter)
        return os.EX_OK
    def run(self):
        org_name   = self.get_option('org')
        def_label  = self.get_option('label')
        def_name   = self.get_option('name')
        def_id     = self.get_option('id')

        cvd = get_cv_definition(org_name, def_label, def_name, def_id)

        self.api.delete(cvd["id"])
        print _("Successfully deleted definition [ %s ]") % cvd["name"]
        return os.EX_OK
Ejemplo n.º 7
0
    def run(self):
        name         = self.get_option('name')
        description  = self.get_option('description')
        org_name     = self.get_option('org')
        def_label    = self.get_option('view')

        cvd = get_cv_definition(org_name, def_label)

        cvd = self.def_api.update(org_name, cvd["id"], name, description)
        print _("Successfully updated content_view [ %s ]") % cvd['name']
        return os.EX_OK
Ejemplo n.º 8
0
    def run(self):
        org_name   = self.get_option('org')
        def_label  = self.get_option('label')
        def_name   = self.get_option('name')
        def_id     = self.get_option('id')

        cvd = get_cv_definition(org_name, def_label, def_name, def_id)

        self.api.delete(cvd["id"])
        print _("Successfully deleted definition [ %s ]") % cvd["name"]
        return os.EX_OK
Ejemplo n.º 9
0
    def run(self):
        org_name = self.get_option('org')
        filter_name = self.get_option('name')
        definition_label = self.get_option('definition_label')
        definition_name = self.get_option('definition_name')
        definition_id = self.get_option('definition_id')

        definition = get_cv_definition(org_name, definition_label,
                                       definition_name, definition_id)

        self.api.create(filter_name, definition["id"], org_name)
        print _("Successfully created filter [ %s ]") % filter_name
        return os.EX_OK
Ejemplo n.º 10
0
    def run(self):
        new_name     = self.get_option('new_name')
        description  = self.get_option('description')
        org_name     = self.get_option('org')
        def_label    = self.get_option('label')
        def_name     = self.get_option('name')
        def_id       = self.get_option('id')

        cvd = get_cv_definition(org_name, def_label, def_name, def_id)

        cvd = self.api.update(org_name, cvd["id"], new_name, description)
        print _("Successfully updated definition [ %s ]") % cvd['name']
        return os.EX_OK
Ejemplo n.º 11
0
    def run(self):
        new_name     = self.get_option('new_name')
        description  = self.get_option('description')
        org_name     = self.get_option('org')
        def_label    = self.get_option('label')
        def_name     = self.get_option('name')
        def_id       = self.get_option('id')

        cvd = get_cv_definition(org_name, def_label, def_name, def_id)

        cvd = self.api.update(org_name, cvd["id"], new_name, description)
        print _("Successfully updated definition [ %s ]") % cvd['name']
        return os.EX_OK
Ejemplo n.º 12
0
    def run(self):
        org_name = self.get_option('org')
        filter_name = self.get_option('name')
        definition_label = self.get_option('definition_label')
        definition_name = self.get_option('definition_name')
        definition_id = self.get_option('definition_id')

        definition = get_cv_definition(org_name, definition_label,
                                       definition_name, definition_id)

        self.api.create(filter_name, definition["id"], org_name)
        print _("Successfully created filter [ %s ]") % filter_name
        return os.EX_OK
Ejemplo n.º 13
0
    def run(self):
        org_name           = self.get_option('org')
        def_label          = self.get_option('label')
        def_name           = self.get_option('name')
        def_id             = self.get_option('id')
        content_view_label = self.get_option('view')

        cvd = get_cv_definition(org_name, def_label, def_name, def_id)
        content_view = get_content_view(org_name, content_view_label)

        content_views = self.def_api.content_views(cvd['id'])
        content_views = [f['id'] for f in content_views]
        self.update_content_views(cvd, content_views, content_view)
        return os.EX_OK
Ejemplo n.º 14
0
    def run(self):
        org_name = self.get_option('org')
        filter_name = self.get_option('name')
        filter_id = self.get_option('id')
        rule = self.get_option('rule')
        definition_label = self.get_option('definition_label')
        definition_name = self.get_option('definition_name')
        definition_id = self.get_option('definition_id')

        definition = get_cv_definition(org_name, definition_label,
                                       definition_name, definition_id)
        cvd_filter = get_filter(org_name, definition["id"], filter_name, filter_id)
        self.api.remove_rule(cvd_filter["id"], definition["id"], org_name, rule)

        return os.EX_OK
Ejemplo n.º 15
0
    def run(self):
        org_name = self.get_option('org')
        filter_name = self.get_option('name')
        filter_id = self.get_option('id')
        rule = self.get_option('rule')
        definition_label = self.get_option('definition_label')
        definition_name = self.get_option('definition_name')
        definition_id = self.get_option('definition_id')
        content = self.get_option('content')
        inclusion = ("includes" == self.get_option('inclusion'))
        definition = get_cv_definition(org_name, definition_label,
                                       definition_name, definition_id)
        cvd_filter = get_filter(org_name, definition["id"], filter_name, filter_id)

        self.api.create_rule(cvd_filter["id"], definition["id"], org_name, rule, content, inclusion)
        return os.EX_OK
Ejemplo n.º 16
0
    def run(self):
        org_name = self.get_option('org')
        filter_name = self.get_option('name')
        filter_id = self.get_option('id')
        rule = self.get_option('rule')
        definition_label = self.get_option('definition_label')
        definition_name = self.get_option('definition_name')
        definition_id = self.get_option('definition_id')

        definition = get_cv_definition(org_name, definition_label,
                                       definition_name, definition_id)
        cvd_filter = get_filter(org_name, definition["id"], filter_name, filter_id)
        self.api.remove_rule(cvd_filter["id"], definition["id"], org_name, rule)

        print _("Successfully removed rule [ %s ]") % rule
        return os.EX_OK
Ejemplo n.º 17
0
    def run(self):
        org_name      = self.get_option('org')
        def_label     = self.get_option('label')
        def_name      = self.get_option('name')
        def_id        = self.get_option('id')
        product_name  = self.get_option('product')
        product_id    = self.get_option('product_id')
        product_label = self.get_option('product_label')

        view    = get_cv_definition(org_name, def_label, def_name, def_id)
        product = get_product(org_name, product_name, product_label, product_id)

        products = self.api.products(org_name, view['id'])
        products = [f['id'] for f in products]
        self.update_products(org_name, view, products, product)
        return os.EX_OK
Ejemplo n.º 18
0
    def run(self):
        org_name      = self.get_option('org')
        def_label     = self.get_option('label')
        def_name      = self.get_option('name')
        def_id        = self.get_option('id')
        product_name  = self.get_option('product')
        product_id    = self.get_option('product_id')
        product_label = self.get_option('product_label')

        view    = get_cv_definition(org_name, def_label, def_name, def_id)
        product = get_product(org_name, product_name, product_label, product_id)

        products = self.api.products(org_name, view['id'])
        products = [f['id'] for f in products]
        self.update_products(org_name, view, products, product)
        return os.EX_OK
Ejemplo n.º 19
0
    def run(self):
        org_name = self.get_option('org')
        filter_name = self.get_option('name')
        filter_id = self.get_option('id')
        rule = self.get_option('rule')
        definition_label = self.get_option('definition_label')
        definition_name = self.get_option('definition_name')
        definition_id = self.get_option('definition_id')
        content = self.get_option('content')
        inclusion = ("includes" == self.get_option('inclusion'))
        definition = get_cv_definition(org_name, definition_label,
                                       definition_name, definition_id)
        cvd_filter = get_filter(org_name, definition["id"], filter_name, filter_id)

        self.api.create_rule(cvd_filter["id"], definition["id"], org_name, rule, content, inclusion)
        print _("Successfully created rule [ %s ]") % rule 
        return os.EX_OK
Ejemplo n.º 20
0
    def run(self):
        org_name       = self.get_option('org')
        def_label      = self.get_option('label')
        def_name       = self.get_option('name')
        def_id         = self.get_option('id')
        repo_name      = self.get_option('repo')
        product        = self.get_option('product')
        product_label  = self.get_option('product_label')
        product_id     = self.get_option('product_id')

        view = get_cv_definition(org_name, def_label, def_name, def_id)
        repo = get_repo(org_name, repo_name, product, product_label, product_id)

        repos = self.api.repos(org_name, view['id'])
        repos = [f['id'] for f in repos]
        self.update_repos(org_name, view, repos, repo)
        return os.EX_OK
Ejemplo n.º 21
0
    def run(self):
        org_name       = self.get_option('org')
        def_label      = self.get_option('label')
        def_name       = self.get_option('name')
        def_id         = self.get_option('id')
        repo_name      = self.get_option('repo')
        product        = self.get_option('product')
        product_label  = self.get_option('product_label')
        product_id     = self.get_option('product_id')

        view = get_cv_definition(org_name, def_label, def_name, def_id)
        repo = get_repo(org_name, repo_name, product, product_label, product_id)

        repos = self.api.repos(org_name, view['id'])
        repos = [f['id'] for f in repos]
        self.update_repos(org_name, view, repos, repo)
        return os.EX_OK
Ejemplo n.º 22
0
    def run(self):
        org_name           = self.get_option('org')
        def_label          = self.get_option('label')
        def_name           = self.get_option('name')
        def_id             = self.get_option('id')
        content_view_label = self.get_option('view_label')
        content_view_name  = self.get_option('view_name')
        content_view_id    = self.get_option('view_id')

        cvd = get_cv_definition(org_name, def_label, def_name, def_id)
        content_view = get_content_view(org_name, content_view_label, content_view_name,
                                        content_view_id)

        content_views = self.api.content_views(cvd['id'])
        content_views = [f['id'] for f in content_views]
        self.update_content_views(cvd, content_views, content_view)
        return os.EX_OK
Ejemplo n.º 23
0
    def run(self):
        org_name = self.get_option('org')
        definition_label = self.get_option('definition_label')
        definition_name = self.get_option('definition_name')
        definition_id = self.get_option('definition_id')

        definition = get_cv_definition(org_name, definition_label,
                                       definition_name, definition_id)
        defs = self.api.filters_by_cvd_and_org(definition["id"], org_name)

        self.printer.add_column('id', _("ID"))
        self.printer.add_column('name', _("Name"))
        self.printer.add_column('content_view_definition_label', _("Content View Definition"))
        self.printer.add_column('organization', _('Org'))

        self.printer.set_header(_("Content View Definition Filters"))
        self.printer.print_items(defs)
        return os.EX_OK
Ejemplo n.º 24
0
    def run(self):
        org_name = self.get_option('org')
        definition_label = self.get_option('definition_label')
        definition_name = self.get_option('definition_name')
        definition_id = self.get_option('definition_id')

        definition = get_cv_definition(org_name, definition_label,
                                       definition_name, definition_id)
        defs = self.api.filters_by_cvd_and_org(definition["id"], org_name)

        self.printer.add_column('id', _("ID"))
        self.printer.add_column('name', _("Name"))
        self.printer.add_column('content_view_definition_label', _("Content View Definition"))
        self.printer.add_column('organization', _('Org'))

        self.printer.set_header(_("Content View Definition Filters"))
        self.printer.print_items(defs)
        return os.EX_OK
Ejemplo n.º 25
0
    def run(self):
        org_name = self.get_option('org')
        filter_name = self.get_option('name')
        filter_id = self.get_option('id')
        product_name = self.get_option('product')
        product_id = self.get_option('product_id')
        product_label = self.get_option('product_label')
        definition_label = self.get_option('definition_label')
        definition_name = self.get_option('definition_name')
        definition_id = self.get_option('definition_id')
        cvd = get_cv_definition(org_name, definition_label,
                                definition_name, definition_id)

        product = self.identify_product(cvd, product_name, product_label, product_id)

        cvd_filter = get_filter(org_name, cvd["id"], filter_name, filter_id)
        products = self.api.products(cvd_filter["id"], cvd["id"], org_name)
        products = [f['id'] for f in products]

        self.update_products(org_name, cvd["id"], cvd_filter, products, product)
        return os.EX_OK
Ejemplo n.º 26
0
    def run(self):
        org_name = self.get_option('org')
        filter_name = self.get_option('name')
        filter_id = self.get_option('id')
        product_name = self.get_option('product')
        product_id = self.get_option('product_id')
        product_label = self.get_option('product_label')
        definition_label = self.get_option('definition_label')
        definition_name = self.get_option('definition_name')
        definition_id = self.get_option('definition_id')
        cvd = get_cv_definition(org_name, definition_label,
                                definition_name, definition_id)

        product = self.identify_product(cvd, product_name, product_label, product_id)

        cvd_filter = get_filter(org_name, cvd["id"], filter_name, filter_id)
        products = self.api.products(cvd_filter["id"], cvd["id"], org_name)
        products = [f['id'] for f in products]

        self.update_products(org_name, cvd["id"], cvd_filter, products, product)
        return os.EX_OK
Ejemplo n.º 27
0
    def run(self):
        org_name = self.get_option('org')
        def_label = self.get_option('label')
        def_name = self.get_option('name')
        def_id = self.get_option('id')

        cvd = get_cv_definition(org_name, def_label, def_name, def_id)

        self.printer.add_column('id', _("ID"))
        self.printer.add_column('name', _("Name"))
        self.printer.add_column('label', _("Label"))
        self.printer.add_column('description', _("Description"), multiline=True)
        self.printer.add_column('organization', _('Org'))
        self.printer.add_column('content_views', _('Published Views'), multiline=True)
        self.printer.add_column('components', _('Component Views'), multiline=True)
        self.printer.add_column('products', _("Products"), multiline=True)
        self.printer.add_column('repos', _("Repos"), multiline=True)

        self.printer.set_header(_("Content View Definition Info"))
        self.printer.print_item(cvd)
        return os.EX_OK
Ejemplo n.º 28
0
    def run(self):
        org_name = self.get_option('org')
        def_label = self.get_option('label')
        def_name = self.get_option('name')
        def_id = self.get_option('id')

        cvd = get_cv_definition(org_name, def_label, def_name, def_id)

        self.printer.add_column('id', _("ID"))
        self.printer.add_column('name', _("Name"))
        self.printer.add_column('label', _("Label"))
        self.printer.add_column('composite', _("Composite"))
        self.printer.add_column('description', _("Description"), multiline=True)
        self.printer.add_column('organization', _('Org'))
        self.printer.add_column('content_views', _('Published Views'), multiline=True)
        self.printer.add_column('components', _('Component Views'), multiline=True)
        self.printer.add_column('products', _("Products"), multiline=True)
        self.printer.add_column('repos', _("Repos"), multiline=True)

        self.printer.set_header(_("Content View Definition Info"))
        self.printer.print_item(cvd)
        return os.EX_OK
Ejemplo n.º 29
0
    def run(self):
        org_name = self.get_option('org')
        filter_name = self.get_option('name')
        filter_id = self.get_option('id')
        repo_name = self.get_option('repo')
        product = self.get_option('product')
        product_label = self.get_option('product_label')
        product_id = self.get_option('product_id')
        definition_label = self.get_option('definition_label')
        definition_name = self.get_option('definition_name')
        definition_id = self.get_option('definition_id')

        definition = get_cv_definition(org_name, definition_label,
                                       definition_name, definition_id)

        cvd_filter = get_filter(org_name, definition["id"], filter_name, filter_id)

        repo = get_repo(org_name, repo_name, product, product_label, product_id)
        repos = self.api.repos(cvd_filter["id"], definition["id"], org_name)
        repos = [f['id'] for f in repos]

        self.update_repos(org_name, definition["id"], cvd_filter, repos, repo)

        return os.EX_OK
Ejemplo n.º 30
0
    def run(self):
        org_name = self.get_option('org')
        filter_name = self.get_option('name')
        filter_id = self.get_option('id')
        repo_name = self.get_option('repo')
        product = self.get_option('product')
        product_label = self.get_option('product_label')
        product_id = self.get_option('product_id')
        definition_label = self.get_option('definition_label')
        definition_name = self.get_option('definition_name')
        definition_id = self.get_option('definition_id')

        definition = get_cv_definition(org_name, definition_label,
                                       definition_name, definition_id)

        cvd_filter = get_filter(org_name, definition["id"], filter_name, filter_id)

        repo = get_repo(org_name, repo_name, product, product_label, product_id)
        repos = self.api.repos(cvd_filter["id"], definition["id"], org_name)
        repos = [f['id'] for f in repos]

        self.update_repos(org_name, definition["id"], cvd_filter, repos, repo)

        return os.EX_OK