Example #1
0
def delete(repo_id, dist_id):
    """
    Removes a distributor from a repository and unbinds any bound consumers.

    :param distributor: distributor to be deleted
    :type  distributor: pulp.server.db.model.Distributor

    :return: result containing any errors and tasks spawned
    :rtype pulp.server.async.tasks.TaskResult
    """

    distributor = model.Distributor.objects.get_or_404(repo_id=repo_id, distributor_id=dist_id)
    managers.repo_publish_schedule_manager().delete_by_distributor_id(repo_id, dist_id)

    # Call the distributor's cleanup method
    dist_instance, plugin_config = plugin_api.get_distributor_by_id(distributor.distributor_type_id)

    call_config = PluginCallConfiguration(plugin_config, distributor.config)
    repo = model.Repository.objects.get_repo_or_missing_resource(repo_id)
    dist_instance.distributor_removed(repo.to_transfer_repo(), call_config)
    distributor.delete()

    unbind_errors = []
    additional_tasks = []
    options = {}

    bind_manager = managers.consumer_bind_manager()
    for bind in bind_manager.find_by_distributor(repo_id, dist_id):
        try:
            report = bind_manager.unbind(bind['consumer_id'], bind['repo_id'],
                                         bind['distributor_id'], options)
            if report:
                additional_tasks.extend(report.spawned_tasks)
        except Exception, e:
            unbind_errors.append(e)
Example #2
0
    def post(self, request, repo_id, distributor_id):
        """
        Create a new scheduled publish.

        :param request: WSGI request object
        :type  request: django.core.handlers.wsgi.WSGIRequest
        :param repo_id: id of the repository
        :type  repo_id: str
        :param distributor_id: id of the distributor
        :type  distributor_id: str

        :return: Response containing a dict for the new scheduled publish
        :rtype : django.http.HttpResponse
        :raises exceptions.UnsupportedValue: if unsupported fields are included in body
        """

        manager = manager_factory.repo_publish_schedule_manager()
        publish_options = {'override_config': request.body_as_json.pop('override_config', {})}
        schedule = request.body_as_json.pop('schedule', None)
        failure_threshold = request.body_as_json.pop('failure_threshold', None)
        enabled = request.body_as_json.pop('enabled', True)
        if request.body_as_json:
            raise exceptions.UnsupportedValue(request.body_as_json.keys())

        schedule = manager.create(repo_id, distributor_id, publish_options,
                                  schedule, failure_threshold, enabled)
        ret = schedule.for_display()
        ret['_href'] = reverse('repo_publish_schedule_resource', kwargs={
            'repo_id': repo_id, 'distributor_id': distributor_id, 'schedule_id': schedule.id
        })
        response = generate_json_response_with_pulp_encoder(ret)
        return generate_redirect_response(response, ret['_href'])
Example #3
0
    def __init__(self):
        """
        Initialize RepoPublishScheduleResourceView.
        """

        super(RepoPublishScheduleResourceView, self).__init__()
        self.manager = manager_factory.repo_publish_schedule_manager()
Example #4
0
    def __init__(self):
        """
        Initialize RepoPublishScheduleResourceView.
        """

        super(RepoPublishScheduleResourceView, self).__init__()
        self.manager = manager_factory.repo_publish_schedule_manager()
Example #5
0
    def post(self, request, repo_id, distributor_id):
        """
        Create a new scheduled publish.

        :param request: WSGI request object
        :type  request: django.core.handlers.wsgi.WSGIRequest
        :param repo_id: id of the repository
        :type  repo_id: str
        :param distributor_id: id of the distributor
        :type  distributor_id: str

        :return: Response containing a dict for the new scheduled publish
        :rtype : django.http.HttpResponse
        :raises exceptions.UnsupportedValue: if unsupported fields are included in body
        """

        manager = manager_factory.repo_publish_schedule_manager()
        publish_options = {'override_config': request.body_as_json.pop('override_config', {})}
        schedule = request.body_as_json.pop('schedule', None)
        failure_threshold = request.body_as_json.pop('failure_threshold', None)
        enabled = request.body_as_json.pop('enabled', True)
        if request.body_as_json:
            raise exceptions.UnsupportedValue(request.body_as_json.keys())

        schedule = manager.create(repo_id, distributor_id, publish_options,
                                  schedule, failure_threshold, enabled)
        ret = schedule.for_display()
        ret['_href'] = reverse('repo_publish_schedule_resource', kwargs={
            'repo_id': repo_id, 'distributor_id': distributor_id, 'schedule_id': schedule.id
        })
        response = generate_json_response_with_pulp_encoder(ret)
        return generate_redirect_response(response, ret['_href'])
Example #6
0
    def GET(self, repo_id, distributor_id):
        manager = manager_factory.repo_publish_schedule_manager()
        schedules = manager.list(repo_id, distributor_id)
        for_display = [schedule.for_display() for schedule in schedules]
        for entry in for_display:
            entry.update(serialization.link.child_link_obj(entry['_id']))

        return self.ok(for_display)
Example #7
0
    def GET(self, repo_id, distributor_id):
        manager = manager_factory.repo_publish_schedule_manager()
        schedules = manager.list(repo_id, distributor_id)
        for_display = [schedule.for_display() for schedule in schedules]
        for entry in for_display:
            entry.update(serialization.link.child_link_obj(entry['_id']))

        return self.ok(for_display)
Example #8
0
    def POST(self, repo_id, distributor_id):
        manager = manager_factory.repo_publish_schedule_manager()

        params = self.params()
        publish_options = {"override_config": params.pop("override_config", {})}
        schedule = params.pop("schedule", None)
        failure_threshold = params.pop("failure_threshold", None)
        enabled = params.pop("enabled", True)
        if params:
            raise exceptions.UnsupportedValue(params.keys())

        schedule = manager.create(repo_id, distributor_id, publish_options, schedule, failure_threshold, enabled)

        ret = schedule.for_display()
        ret.update(serialization.link.child_link_obj(schedule.id))
        return self.created(ret["_href"], ret)
Example #9
0
    def POST(self, repo_id, distributor_id):
        manager = manager_factory.repo_publish_schedule_manager()

        params = self.params()
        publish_options = {
            'override_config': params.pop('override_config', {})
        }
        schedule = params.pop('schedule', None)
        failure_threshold = params.pop('failure_threshold', None)
        enabled = params.pop('enabled', True)
        if params:
            raise exceptions.UnsupportedValue(params.keys())

        schedule = manager.create(repo_id, distributor_id, publish_options,
                                  schedule, failure_threshold, enabled)

        ret = schedule.for_display()
        ret.update(serialization.link.child_link_obj(schedule.id))
        return self.created(ret['_href'], ret)
Example #10
0
    def get(self, request, repo_id, distributor_id):
        """
        Retrieve information about all scheduled publishes.

        :param request: WSGI request object
        :type  request: django.core.handlers.wsgi.WSGIRequest
        :param repo_id: id of the repository
        :type  repo_id: str
        :param distributor_id: id of the distributor
        :type  distributor_id: str

        :return: Response containing serialized list of dicts, one for each scheduled publish
        :rtype : django.http.HttpResponse
        """

        manager = manager_factory.repo_publish_schedule_manager()
        schedules = manager.list(repo_id, distributor_id)
        for_display = [schedule.for_display() for schedule in schedules]
        for entry in for_display:
            entry['_href'] = reverse('repo_publish_schedule_resource', kwargs={
                'repo_id': repo_id, 'distributor_id': distributor_id, 'schedule_id': entry['_id']
            })
        return generate_json_response(for_display)
Example #11
0
    def get(self, request, repo_id, distributor_id):
        """
        Retrieve information about all scheduled publishes.

        :param request: WSGI request object
        :type  request: django.core.handlers.wsgi.WSGIRequest
        :param repo_id: id of the repository
        :type  repo_id: str
        :param distributor_id: id of the distributor
        :type  distributor_id: str

        :return: Response containing serialized list of dicts, one for each scheduled publish
        :rtype : django.http.HttpResponse
        """

        manager = manager_factory.repo_publish_schedule_manager()
        schedules = manager.list(repo_id, distributor_id)
        for_display = [schedule.for_display() for schedule in schedules]
        for entry in for_display:
            entry['_href'] = reverse('repo_publish_schedule_resource', kwargs={
                'repo_id': repo_id, 'distributor_id': distributor_id, 'schedule_id': entry['_id']
            })
        return generate_json_response(for_display)
Example #12
0
 def __init__(self):
     super(PublishScheduleResource, self).__init__()
     self.manager = manager_factory.repo_publish_schedule_manager()
Example #13
0
 def __init__(self):
     super(PublishScheduleResource, self).__init__()
     self.manager = manager_factory.repo_publish_schedule_manager()