예제 #1
0
    def run(self):
        orgName     = self.get_option('org')
        prodName    = self.get_option('name')
        prodLabel   = self.get_option('label')
        prodId      = self.get_option('id')
        envName     = self.get_option('environment')

        env = get_environment(orgName, envName)
        prod = get_product(orgName, prodName, prodLabel, prodId)


        if not self.repoapi.repos_by_product(orgName, prod['id']):
            print _("Product [ %(prod_name)s ] has no repository") % {'prod_name':prod['name']}
            return os.EX_DATAERR

        cset = self.csapi.create(orgName, env["id"], self.create_cs_name(), constants.PROMOTION)

        self.csapi.add_content(cset["id"], "products", {'product_id': prod['id']})
        task = self.csapi.apply(cset["id"])
        task = AsyncTask(task)

        run_spinner_in_bg(wait_for_async_task, [task], message=_("Promoting the product, please wait... "))

        return evaluate_task_status(task,
            failed = _("Product [ %s ] promotion failed") % prod["name"],
            ok =     _("Product [ %(prod)s ] promoted to environment [ %(env)s ]") %
                {'prod':prod["name"], 'env':envName}
        )
    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
예제 #3
0
    def run(self):
        org_name = self.get_option('org')
        env_name = self.get_option('environment')
        async = self.get_option('async')
        view_label = self.get_option('label')
        view_id = self.get_option('id')
        view_name = self.get_option('name')

        view = get_content_view(org_name, view_label, view_name, view_id)

        environment = get_environment(org_name, env_name)
        env_id = environment["id"]

        task = self.api.promote(view["id"], env_id)

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

            return evaluate_task_status(task,
                failed = _("View [ %s ] promotion failed") % view["name"],
                ok =     _("Content view [ %(view)s ] promoted to environment [ %(env)s ]") %
                    {"view": view["name"], "env": environment["name"]},
            )

        else:
            print _("Promotion task [ %s ] was successfully created.") % (task["uuid"])
            return os.EX_OK
예제 #4
0
    def run(self):
        org_name = self.get_option('org')
        env_name = self.get_option('environment')
        async = self.get_option('async')
        view_label = self.get_option('label')
        view_id = self.get_option('id')
        view_name = self.get_option('name')

        view = get_content_view(org_name, view_label, view_name, view_id)

        environment = get_environment(org_name, env_name)
        env_id = environment["id"]

        task = self.api.promote(view["id"], env_id)

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

            return evaluate_task_status(task,
                failed = _("View [ %s ] promotion failed") % view["name"],
                ok =     _("Content view [ %(view)s ] promoted to environment [ %(env)s ]") %
                    {"view": view["name"], "env": environment["name"]},
            )

        else:
            print _("Promotion task [ %s ] was successfully created.") % (task["uuid"])
            return os.EX_OK
예제 #5
0
    def run(self):
        orgName     = self.get_option('org')
        prodName    = self.get_option('name')
        prodLabel   = self.get_option('label')
        prodId      = self.get_option('id')
        envName     = self.get_option('environment')

        env = get_environment(orgName, envName)
        prod = get_product(orgName, prodName, prodLabel, prodId)


        if not self.repoapi.repos_by_product(orgName, prod['id']):
            print _("Product [ %(prod_name)s ] has no repository") % {'prod_name':prod['name']}
            return os.EX_DATAERR

        cset = self.csapi.create(orgName, env["id"], self.create_cs_name(), constants.PROMOTION)

        self.csapi.add_content(cset["id"], "products", {'product_id': prod['id']})
        task = self.csapi.apply(cset["id"])
        task = AsyncTask(task)

        run_spinner_in_bg(wait_for_async_task, [task], message=_("Promoting the product, please wait... "))

        return evaluate_task_status(task,
            failed = _("Product [ %s ] promotion failed") % prod["name"],
            ok =     _("Product [ %(prod)s ] promoted to environment [ %(env)s ]") %
                {'prod':prod["name"], 'env':envName}
        )
    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
예제 #7
0
    def run(self):
        repo = self.get_repo()

        task = AsyncTask(self.api.sync(repo['id']))
        run_async_task_with_status(task, ProgressBar())

        return evaluate_task_status(task,
            failed =   _("Repo [ %s ] failed to sync") % repo["name"],
            canceled = _("Repo [ %s ] synchronization canceled") % repo["name"],
            ok =       _("Repo [ %s ] synchronized") % repo["name"]
        )
예제 #8
0
    def sync_provider(self, providerName, orgName):
        prov = get_provider(orgName, providerName)

        task = AsyncTask(self.api.sync(prov["id"]))
        run_async_task_with_status(task, ProgressBar())

        return evaluate_task_status(task,
            failed =   _("Provider [ %s ] failed to sync") % providerName,
            canceled = _("Provider [ %s ] synchronization canceled") % providerName,
            ok =       _("Provider [ %s ] synchronized") % providerName
        )
예제 #9
0
파일: repo.py 프로젝트: guymatz/katello
    def run(self):
        repo = self.get_repo()

        task = AsyncTask(self.api.sync(repo['id']))
        run_async_task_with_status(task, ProgressBar())

        return evaluate_task_status(task,
            failed =   _("Repo [ %s ] failed to sync") % repo["name"],
            canceled = _("Repo [ %s ] synchronization canceled") % repo["name"],
            ok =       _("Repo [ %s ] synchronized") % repo["name"]
        )
예제 #10
0
    def run(self):
        org_name = self.get_option("name")

        task = AsyncTask(self.api.attach_all_systems(org_name))
        run_spinner_in_bg(wait_for_async_task, [task],
            message=_("Attaching available subscriptions to all systems, please wait... "))

        return evaluate_task_status(task,
            failed = _("Organization [ %s ] failed to attach subscriptions to all systems") % org_name,
            canceled = _("Organization [ %s ] canceled attachment of subscriptions to all systems") % org_name,
            ok = _("Organzation [ %s ] completed attachment of subscriptions to all systems") % org_name
        )
예제 #11
0
    def run(self):
        name = self.get_option('name')

        task = self.api.delete(name)
        task = AsyncTask(task)

        run_spinner_in_bg(wait_for_async_task, [task], message=_("Deleting the organization, please wait... "))

        return evaluate_task_status(task,
            failed = _("Organization [ %s ] deletion failed:") % name,
            ok =     _("Successfully deleted org [ %s ]") % name
        )
예제 #12
0
    def sync_provider(self, providerName, orgName):
        prov = get_provider(orgName, providerName)

        task = AsyncTask(self.api.sync(prov["id"]))
        run_async_task_with_status(task, ProgressBar())

        return evaluate_task_status(
            task,
            failed=_("Provider [ %s ] failed to sync") % providerName,
            canceled=_("Provider [ %s ] synchronization canceled") %
            providerName,
            ok=_("Provider [ %s ] synchronized") % providerName)
예제 #13
0
    def run(self):
        name = self.get_option('name')

        task = self.api.delete(name)
        task = AsyncTask(task)

        run_spinner_in_bg(wait_for_async_task, [task], message=_("Deleting the organization, please wait... "))

        return evaluate_task_status(task,
            failed = _("Organization [ %s ] deletion failed:") % name,
            ok =     _("Successfully deleted org [ %s ]") % name
        )
예제 #14
0
    def run(self):
        csName = self.get_option('name')
        orgName = self.get_option('org')
        envName = self.get_option('environment')

        cset = get_changeset(orgName, envName, csName)

        task = self.api.apply(cset["id"])
        task = AsyncTask(task)

        run_spinner_in_bg(wait_for_async_task, [task], message=_("Applying the changeset, please wait... "))

        return evaluate_task_status(task,
            failed = _("Changeset [ %s ] promotion failed") % csName,
            ok =     _("Changeset [ %s ] applied") % csName
        )
예제 #15
0
    def run(self):
        orgName     = self.get_option('org')
        prodName    = self.get_option('name')
        prodLabel   = self.get_option('label')
        prodId      = self.get_option('id')

        prod = get_product(orgName, prodName, prodLabel, prodId)

        task = AsyncTask(self.api.sync(orgName, prod["id"]))
        run_async_task_with_status(task, ProgressBar())

        return evaluate_task_status(task,
            failed =   _("Product [ %s ] failed to sync") % prod["name"],
            canceled = _("Product [ %s ] synchronization canceled") % prod["name"],
            ok =       _("Product [ %s ] synchronized") % prod["name"]
        )
예제 #16
0
    def run(self):
        orgName     = self.get_option('org')
        prodName    = self.get_option('name')
        prodLabel   = self.get_option('label')
        prodId      = self.get_option('id')

        prod = get_product(orgName, prodName, prodLabel, prodId)

        task = AsyncTask(self.api.sync(orgName, prod["id"]))
        run_async_task_with_status(task, ProgressBar())

        return evaluate_task_status(task,
            failed =   _("Product [ %s ] failed to sync") % prod["name"],
            canceled = _("Product [ %s ] synchronization canceled") % prod["name"],
            ok =       _("Product [ %s ] synchronized") % prod["name"]
        )
예제 #17
0
    def run(self):
        orgName     = self.get_option('org')
        prodName    = self.get_option('name')
        prodLabel   = self.get_option('label')
        prodId      = self.get_option('id')
        prod = get_product(orgName, prodName, prodLabel, prodId)
        set_name      = self.get_option('set_name')

        task = AsyncTask(self.api.disable_repository_set(orgName, prod['id'], set_name))
        task = run_spinner_in_bg(wait_for_async_task, [task],
                message=_("Disabling Repository Set..."))
        task = AsyncTask(task)
        return evaluate_task_status(task,
            failed = _("Repository disable [ %(set_name)s ] failed.") % 
                        {'set_name':set_name},
            ok = _("Repository Set [ %(set_name)s ] disabled.") % {'set_name':set_name}
        )
예제 #18
0
    def run(self):
        orgName     = self.get_option('org')
        prodName    = self.get_option('name')
        prodLabel   = self.get_option('label')
        prodId      = self.get_option('id')
        prod = get_product(orgName, prodName, prodLabel, prodId)
        set_name      = self.get_option('set_name')

        task = AsyncTask(self.api.disable_repository_set(orgName, prod['id'], set_name))
        task = run_spinner_in_bg(wait_for_async_task, [task],
                message=_("Disabling Repository Set..."))
        task = AsyncTask(task)
        return evaluate_task_status(task,
            failed = _("Repository disable [ %(set_name)s ] failed.") % 
                        {'set_name':set_name},
            ok = _("Repository Set [ %(set_name)s ] disabled.") % {'set_name':set_name}
        )
예제 #19
0
    def run(self):
        csName = self.get_option('name')
        orgName = self.get_option('org')
        envName = self.get_option('environment')

        cset = get_changeset(orgName, envName, csName)

        task = self.api.apply(cset["id"])
        task = AsyncTask(task)

        run_spinner_in_bg(wait_for_async_task, [task],
                          message=_("Applying the changeset, please wait... "))

        return evaluate_task_status(
            task,
            failed=_("Changeset [ %s ] promotion failed") % csName,
            ok=_("Changeset [ %s ] applied") % csName)
예제 #20
0
    def run(self):
        org_name = self.get_option('name')
        informable_type = self.get_option('type').lower()
        async = not self.get_option('no_async')

        if async:
            task = AsyncTask(self.default_info_api.apply(org_name, informable_type, async)['task'])
            run_spinner_in_bg(wait_for_async_task, [task], message=_("Applying default info, please wait... "))

            return evaluate_task_status(task,
                failed   = _("Organization [ %s ] failed to apply default info") % org_name,
                canceled = _("Organization [ %s ] canceled applying default info") % org_name,
                ok       = _("Organization [ %s ] completed applying default info") % org_name
            )
        else:
            self.default_info_api.apply(org_name, informable_type, async)

            print _("Organization [ %s ] completed applying default info") % org_name
            return os.EX_OK
예제 #21
0
    def run(self):
        org_name = self.get_option('name')
        informable_type = self.get_option('type').lower()
        async = not self.get_option('no_async')

        if async:
            task = AsyncTask(self.default_info_api.apply(org_name, informable_type, async)['task'])
            run_spinner_in_bg(wait_for_async_task, [task], message=_("Applying default info, please wait... "))

            return evaluate_task_status(task,
                failed   = _("Organization [ %s ] failed to apply default info") % org_name,
                canceled = _("Organization [ %s ] canceled applying default info") % org_name,
                ok       = _("Organization [ %s ] completed applying default info") % org_name
            )
        else:
            self.default_info_api.apply(org_name, informable_type, async)

            print _("Organization [ %s ] completed applying default info") % org_name
            return os.EX_OK
예제 #22
0
파일: node.py 프로젝트: Katello/katello-cli
    def run(self):
        node_id = self.get_option("id")
        node_name = self.get_option("name")

        org_name = self.get_option('org')
        env_name = self.get_option('env_name')
        env_id = None
        message = _("Syncing node, please wait... ")
        if env_name is not None:
            env = get_environment(org_name, env_name)
            env_id = env['id']
            message = _("Syncing environment %s to node, please wait...") % env['name']

        node_id = get_node(node_name, node_id)['id']
        sync_tasks = self.api.sync(node_id, env_id)
        task = AsyncTask(sync_tasks)
        run_spinner_in_bg(wait_for_async_task, [task], message=message)

        return evaluate_task_status(task,
            ok =     _("Sync of environment [ %s ] completed successfully.") % env_name,
            failed = _("Sync of environment [ %s ] failed") % env_name,
            error_formatter = format_node_sync_errors
        )
예제 #23
0
    def run(self):
        org_name = self.get_option('org')
        view_label = self.get_option('label')
        view_id = self.get_option('id')
        view_name = self.get_option('name')
        async = self.get_option('async')

        view = get_content_view(org_name, view_label, view_name, view_id)

        task = self.api.refresh(view["id"])

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

            return evaluate_task_status(task,
                ok =     _("Content view [ %s ] was successfully refreshed.") % view["name"],
                failed = _("View [ %s ] refresh failed") % view["name"]
            )

        else:
            print _("Refresh task [ %s ] was successfully created.") % (task["uuid"])
            return os.EX_OK
예제 #24
0
    def run(self):
        org_name = self.get_option('org')
        view_label = self.get_option('label')
        view_id = self.get_option('id')
        view_name = self.get_option('name')
        async = self.get_option('async')

        view = get_content_view(org_name, view_label, view_name, view_id)

        task = self.api.refresh(view["id"])

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

            return evaluate_task_status(task,
                ok =     _("Content view [ %s ] was successfully refreshed.") % view["name"],
                failed = _("View [ %s ] refresh failed") % view["name"]
            )

        else:
            print _("Refresh task [ %s ] was successfully created.") % (task["uuid"])
            return os.EX_OK