Esempio n. 1
0
def _get_publish_task_id(resource_type, resource_id, context):
    """
    :param resource_type:   The resource type to get. See pulp.common.tags for examples. Note - the repo
                            group is 'repository_group', but is not yet in pulp.common.tags
    :type  resource_type:   str
    :param resource_id:     The id of the resource to retrieve the task id for. This should be a repo or
                            group id
    :type  resource_id:     str
    :param context:         The client context is used when fetching existing task ids
    :type  context:         pulp.client.extensions.core.ClientContext

    :return: The task id, if it exists. If it does not, this will return None
    :rtype:  str
    """
    tags = [tag_utils.resource_tag(resource_type, resource_id), tag_utils.action_tag(tag_utils.ACTION_PUBLISH_TYPE)]
    existing_tasks = context.server.tasks.get_all_tasks(tags)
    return tasks.relevant_existing_task_id(existing_tasks.response_body)
Esempio n. 2
0
    def run(self, **kwargs):
        repo_id = kwargs[options.OPTION_REPO_ID.keyword]
        background = kwargs[NAME_BACKGROUND]
        override_config = {}

        # Generate override_config if any of the override options are passed.
        if self.override_config_keywords:
            override_config = self.generate_override_config(**kwargs)

        self.prompt.render_title(
            _('Publishing Repository [%(r)s]') % {'r': repo_id})

        # Display override configuration used
        if override_config:
            self.prompt.render_paragraph(
                _('The following publish configuration options will be used:'))
            self.prompt.render_document(override_config)

        # See if an existing publish is running for the repo. If it is, resume
        # progress tracking.
        existing_publish_tasks = self.context.server.tasks.get_repo_publish_tasks(
            repo_id).response_body
        task_id = tasks.relevant_existing_task_id(existing_publish_tasks)

        if task_id is not None:
            msg = _(
                'A publish task is already in progress for this repository. ')
            if not background:
                msg += _('Its progress will be tracked below.')
            self.context.prompt.render_paragraph(msg, tag='in-progress')

        else:
            if not override_config:
                override_config = None
            response = self.context.server.repo_actions.publish(
                repo_id, self.distributor_id, override_config)
            task_id = response.response_body.task_id

        if not background:
            status.display_task_status(self.context, self.renderer, task_id)
        else:
            msg = _(
                'The status of this publish can be displayed using the status command.'
            )
            self.context.prompt.render_paragraph(msg, 'background')
Esempio n. 3
0
    def run(self, **kwargs):
        repo_id = kwargs[options.OPTION_REPO_ID.keyword]
        background = kwargs[NAME_BACKGROUND]
        override_config = {}
        
        # Generate override_config if any of the override options are passed.
        if self.override_config_keywords:
            override_config = self.generate_override_config(**kwargs)

        self.prompt.render_title(_('Publishing Repository [%(r)s]') % {'r' : repo_id})

        # Display override configuration used
        if override_config:
            self.prompt.render_paragraph(_('The following publish configuration options will be used:'))
            self.prompt.render_document(override_config)

        # See if an existing publish is running for the repo. If it is, resume
        # progress tracking.
        existing_publish_tasks = self.context.server.tasks.get_repo_publish_tasks(repo_id).response_body
        task_id = tasks.relevant_existing_task_id(existing_publish_tasks)

        if task_id is not None:
            msg = _('A publish task is already in progress for this repository. ')
            if not background:
                msg += _('Its progress will be tracked below.')
            self.context.prompt.render_paragraph(msg, tag='in-progress')

        else:
            if not override_config:
                override_config = None
            response = self.context.server.repo_actions.publish(repo_id, self.distributor_id, override_config)
            task_id = response.response_body.task_id

        if not background:
            status.display_task_status(self.context, self.renderer, task_id)
        else:
            msg = _('The status of this publish can be displayed using the status command.')
            self.context.prompt.render_paragraph(msg, 'background')