Ejemplo n.º 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)

        returnCode = os.EX_OK

        cset = self.csapi.create(orgName, env["id"], self.create_cs_name(), constants.PROMOTION)
        try:
            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... "))

            if task.succeeded():
                print _("Product [ %(prod_name)s ] promoted to environment [ %(envName)s ] " \
                    % {'prod_name':prod["name"], 'envName':envName})
                returnCode = os.EX_OK
            else:
                print _("Product [ %(prod_name)s ] promotion failed: %(task_errors)s" \
                    % {'prod_name':prod["name"], 'task_errors':format_task_errors(task.errors())} )
                returnCode = os.EX_DATAERR

        except Exception:
            #exception message is printed from action's main method
            raise

        return returnCode
Ejemplo n.º 2
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... "))

        if task.succeeded():
            print _("Successfully deleted org [ %s ]") % name
            return os.EX_OK
        else:
            print _("Organization [ %(name)s ] deletion failed: %(format_task_errors)s" \
                % {'name':name, 'format_task_errors':format_task_errors(task.errors())} )
            return os.EX_DATAERR
Ejemplo n.º 3
0
    def run(self):
        repo = self.get_repo()

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

        if task.succeeded():
            print _("Repo [ %s ] synced" % repo['name'])
            return os.EX_OK
        elif task.cancelled():
            print _("Repo [ %s ] synchronization canceled" % repo['name'])
            return os.EX_OK
        else:
            print _("Repo [ %(repo_name)s ] failed to sync: %(sync_errors)s") \
                % {'repo_name':repo['name'], 'sync_errors':format_sync_errors(task)}
            return os.EX_DATAERR
Ejemplo n.º 4
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... "))

        if task.succeeded():
            print _("Changeset [ %s ] applied" % csName)
            return os.EX_OK
        else:
            print _("Changeset [ %(csName)s ] promotion failed: %(task_errors)s" \
                % {'csName':csName, 'task_errors':format_task_errors(task.errors())})
            return os.EX_DATAERR