当前位置: 首页>>代码示例>>Python>>正文


Python factory.consumer_group_manager函数代码示例

本文整理汇总了Python中pulp.server.managers.factory.consumer_group_manager函数的典型用法代码示例。如果您正苦于以下问题:Python consumer_group_manager函数的具体用法?Python consumer_group_manager怎么用?Python consumer_group_manager使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了consumer_group_manager函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: unregister

    def unregister(self, consumer_id):
        """
        Unregisters given consumer.

        @param consumer_id: identifies the consumer being unregistered
        @type  consumer_id: str

        @raises MissingResource: if the given consumer does not exist
        @raises OperationFailed: if any part of the unregister process fails;
                the exception will contain information on which sections failed
        @raises PulpExecutionException: if error during updating database collection
        """

        self.get_consumer(consumer_id)

        # Remove associate bind
        manager = factory.consumer_bind_manager()
        manager.consumer_deleted(consumer_id)

        # Remove associated profiles
        manager = factory.consumer_profile_manager()
        manager.consumer_deleted(consumer_id)

        # Notify agent
        agent_consumer = factory.consumer_agent_manager()
        agent_consumer.unregistered(consumer_id)

        # remove from consumer groups
        group_manager = factory.consumer_group_manager()
        group_manager.remove_consumer_from_groups(consumer_id)

        # delete any scheduled unit installs
        schedule_manager = factory.schedule_manager()
        schedule_manager.delete_all_unit_install_schedules(consumer_id)
        schedule_manager.delete_all_unit_update_schedules(consumer_id)
        schedule_manager.delete_all_unit_uninstall_schedules(consumer_id)

        # Database Updates
        try:
            Consumer.get_collection().remove({'id' : consumer_id}, safe=True)
        except Exception:
            _LOG.exception('Error updating database collection while removing '
                'consumer [%s]' % consumer_id)
            raise PulpExecutionException("database-error"), None, sys.exc_info()[2]

        # remove the consumer from any groups it was a member of
        group_manager = factory.consumer_group_manager()
        group_manager.remove_consumer_from_groups(consumer_id)

        factory.consumer_history_manager().record_event(consumer_id, 'consumer_unregistered')
开发者ID:bartwo,项目名称:pulp,代码行数:50,代码来源:cud.py

示例2: unregister

    def unregister(consumer_id):
        """
        Unregisters given consumer.

        :param  consumer_id:            identifies the consumer being unregistered
        :type   consumer_id:            str
        :raises MissingResource:        if the given consumer does not exist
        :raises OperationFailed:        if any part of the unregister process fails; the exception
                                        will contain information on which sections failed
        :raises PulpExecutionException: if error during updating database collection
        """

        ConsumerManager.get_consumer(consumer_id)

        # Remove associate bind
        manager = factory.consumer_bind_manager()
        manager.consumer_deleted(consumer_id)

        # Remove associated profiles
        manager = factory.consumer_profile_manager()
        manager.consumer_deleted(consumer_id)

        # Notify agent
        agent_consumer = factory.consumer_agent_manager()
        agent_consumer.unregister(consumer_id)

        # remove from consumer groups
        group_manager = factory.consumer_group_manager()
        group_manager.remove_consumer_from_groups(consumer_id)

        # delete any scheduled unit installs
        schedule_manager = factory.consumer_schedule_manager()
        for schedule in schedule_manager.get(consumer_id):
            # using "delete" on utils skips validation that the consumer exists.
            schedule_utils.delete(schedule.id)

        # Database Updates
        try:
            Consumer.get_collection().remove({'id': consumer_id})
        except Exception:
            _logger.exception(
                'Error updating database collection while removing consumer [%s]' % consumer_id)
            raise PulpExecutionException("database-error"), None, sys.exc_info()[2]

        # remove the consumer from any groups it was a member of
        group_manager = factory.consumer_group_manager()
        group_manager.remove_consumer_from_groups(consumer_id)

        factory.consumer_history_manager().record_event(consumer_id, 'consumer_unregistered')
开发者ID:BrnoPCmaniak,项目名称:pulp,代码行数:49,代码来源:cud.py

示例3: populate

 def populate(self):
     consumer_manager = factory.consumer_manager()
     consumer_manager.register(self.CONSUMER_ID1)
     consumer_manager.register(self.CONSUMER_ID2)
     consumer_group_manager = factory.consumer_group_manager()
     consumer_group_manager.create_consumer_group(group_id=self.GROUP_ID, 
                                                  consumer_ids = [self.CONSUMER_ID1, self.CONSUMER_ID2])
开发者ID:bartwo,项目名称:pulp,代码行数:7,代码来源:test_consumer_group_itineraries.py

示例4: post

    def post(self, request):
        """
        Create a consumer group and return a serialized object containing just created group.

        :param request: WSGI request object
        :type request: django.core.handlers.wsgi.WSGIRequest
        :return: Response containing the consumer group
        :rtype: django.http.HttpResponse
        :raises: MissingValue if group ID is not provided
        :raises: InvalidValue if some parameters are invalid
        """
        params = request.body_as_json
        group_id = params.pop('id', None)
        if group_id is None:
            raise pulp_exceptions.MissingValue(['id'])
        display_name = params.pop('display_name', None)
        description = params.pop('description', None)
        consumer_ids = params.pop('consumer_ids', None)
        notes = params.pop('notes', None)
        if params:
            raise pulp_exceptions.InvalidValue(params.keys())
        manager = factory.consumer_group_manager()
        group = manager.create_consumer_group(group_id, display_name, description, consumer_ids,
                                              notes)
        link = {"_href": reverse('consumer_group_resource',
                kwargs={'consumer_group_id': group['id']})}
        group.update(link)
        response = generate_json_response_with_pulp_encoder(group)
        response_redirect = generate_redirect_response(response, link['_href'])
        return response_redirect
开发者ID:credativ,项目名称:pulp,代码行数:30,代码来源:consumer_groups.py

示例5: POST

 def POST(self, consumer_group_id):
     criteria = Criteria.from_client_input(self.params().get('criteria', {}))
     manager = managers_factory.consumer_group_manager()
     manager.unassociate(consumer_group_id, criteria)
     query_manager = managers_factory.consumer_group_query_manager()
     group = query_manager.get_group(consumer_group_id)
     return self.ok(group['consumer_ids'])
开发者ID:CUXIDUMDUM,项目名称:pulp,代码行数:7,代码来源:consumer_groups.py

示例6: uninstall

 def uninstall(self, consumer_group_id):
     """
     Uninstall content (units) on a consumer.
     Expected body: {units:[], options:<dict>}
     where unit is: {type_id:<str>, unit_key={}} and the
     options is a dict of uninstall options.
     @param id: A consumer ID.
     @type id: str
     @return: TBD
     @rtype: dict
     """
     body = self.params()
     units = body.get('units')
     options = body.get('options')
     resources = {
         dispatch_constants.RESOURCE_CONSUMER_TYPE:
             {consumer_group_id:dispatch_constants.RESOURCE_READ_OPERATION},
     }
     args = [
         consumer_group_id,
         units,
         options,
     ]
     manager = managers_factory.consumer_group_manager()
     call_request = CallRequest(
         manager.uninstall_content,
         args,
         resources=resources,
         weight=0,
         asynchronous=True,
         archive=True,)
     result = execution.execute_async(self, call_request)
     return result
开发者ID:ehelms,项目名称:pulp,代码行数:33,代码来源:consumer_groups.py

示例7: DELETE

 def DELETE(self, consumer_group_id):
     manager = managers_factory.consumer_group_manager()
     tags = [resource_tag(dispatch_constants.RESOURCE_CONSUMER_GROUP_TYPE, consumer_group_id)]
     call_request = CallRequest(manager.delete_consumer_group,
                                [consumer_group_id],
                                tags=tags)
     call_request.deletes_resource(dispatch_constants.RESOURCE_CONSUMER_GROUP_TYPE, consumer_group_id)
     return execution.execute_ok(self, call_request)
开发者ID:ehelms,项目名称:pulp,代码行数:8,代码来源:consumer_groups.py

示例8: populate

 def populate(self):
     manager = managers.consumer_manager()
     for consumer_id in CONSUMER_IDS:
         manager.register(consumer_id)
     manager = managers.consumer_group_manager()
     manager.create_consumer_group(GROUP_ID)
     for consumer_id in CONSUMER_IDS:
         criteria = Criteria(filters={'id': consumer_id}, fields=['id'])
         manager.associate(GROUP_ID, criteria)
开发者ID:cliffy94,项目名称:pulp,代码行数:9,代码来源:test_consumer_group_controller.py

示例9: POST

 def POST(self, consumer_group_id):
     criteria = Criteria.from_client_input(self.params().get('criteria', {}))
     manager = managers_factory.consumer_group_manager()
     tags = [resource_tag(dispatch_constants.RESOURCE_CONSUMER_GROUP_TYPE, consumer_group_id),
             action_tag('consumer_group_unassociate')]
     call_request = CallRequest(manager.unassociate,
                                [consumer_group_id, criteria],
                                tags=tags)
     call_request.updates_resource(dispatch_constants.RESOURCE_CONSUMER_GROUP_TYPE, consumer_group_id)
     matched = execution.execute(call_request)
     return self.ok(matched)
开发者ID:jessegonzalez,项目名称:pulp,代码行数:11,代码来源:consumer_groups.py

示例10: PUT

 def PUT(self, consumer_group_id):
     update_data = self.params()
     manager = managers_factory.consumer_group_manager()
     tags = [resource_tag(dispatch_constants.RESOURCE_CONSUMER_GROUP_TYPE, consumer_group_id)]
     call_request = CallRequest(manager.update_consumer_group,
                                args=[consumer_group_id],
                                kwargs=update_data,
                                tags=tags)
     call_request.updates_resource(dispatch_constants.RESOURCE_CONSUMER_GROUP_TYPE, consumer_group_id)
     group = execution.execute(call_request)
     group.update(serialization.link.current_link_obj())
     return self.ok(group)
开发者ID:ehelms,项目名称:pulp,代码行数:12,代码来源:consumer_groups.py

示例11: POST

 def POST(self, consumer_group_id):
     criteria = Criteria.from_client_input(self.params().get('criteria', {}))
     manager = managers_factory.consumer_group_manager()
     tags = [resource_tag(dispatch_constants.RESOURCE_CONSUMER_GROUP_TYPE, consumer_group_id),
             action_tag('consumer_group_associate')]
     call_request = CallRequest(manager.associate,
                                [consumer_group_id, criteria],
                                tags=tags)
     call_request.updates_resource(dispatch_constants.RESOURCE_CONSUMER_GROUP_TYPE, consumer_group_id)
     execution.execute(call_request)
     collection = ConsumerGroup.get_collection()
     group = collection.find_one({'id': consumer_group_id})
     return self.ok(group['consumer_ids'])
开发者ID:ehelms,项目名称:pulp,代码行数:13,代码来源:consumer_groups.py

示例12: delete

    def delete(self, request, consumer_group_id):
        """
        Delete a specified consumer group.

        :param request: WSGI request object
        :type request: django.core.handlers.wsgi.WSGIRequest
        :param consumer_group_id: id for the requested group
        :type consumer_group_id: str
        :return: An empty response
        :rtype: django.http.HttpResponse
        """
        manager = factory.consumer_group_manager()
        result = manager.delete_consumer_group(consumer_group_id)
        return generate_json_response(result)
开发者ID:credativ,项目名称:pulp,代码行数:14,代码来源:consumer_groups.py

示例13: put

    def put(self, request, consumer_group_id):
        """
        Update a specified consumer group.

        :param request: WSGI request object
        :type request: django.core.handlers.wsgi.WSGIRequest
        :param consumer_group_id: id for the requested group
        :type consumer_group_id: str
        :return: Response representing the updated group
        :rtype: django.http.HttpResponse
        """
        update_data = request.body_as_json
        manager = factory.consumer_group_manager()
        group = manager.update_consumer_group(consumer_group_id, **update_data)
        return generate_json_response_with_pulp_encoder(serialize(group))
开发者ID:credativ,项目名称:pulp,代码行数:15,代码来源:consumer_groups.py

示例14: uninstall

 def uninstall(self, consumer_group_id):
     """
     Uninstall content (units) from the consumers in a consumer group.
     Expected body: {units:[], options:<dict>}
     where unit is: {type_id:<str>, unit_key={}} and the
     options is a dict of uninstall options.
     @param consumer_group_id: A consumer group ID.
     @type consumer_group_id: str
     @return: list of call requests
     @rtype: list
     """
     body = self.params()
     units = body.get('units')
     options = body.get('options')
     task = managers_factory.consumer_group_manager().uninstall_content(consumer_group_id,
                                                                        units, options)
     raise pulp_exceptions.OperationPostponed(task)
开发者ID:CUXIDUMDUM,项目名称:pulp,代码行数:17,代码来源:consumer_groups.py

示例15: uninstall

    def uninstall(self, request, consumer_group_id):
        """
        Uninstall content (units) from the consumers in a consumer group.

        Expected body: {units:[], options:<dict>}
        where unit is: {type_id:<str>, unit_key={}} and the
        options is a dict of uninstall options.

        :param request: WSGI request object
        :type request: django.core.handlers.wsgi.WSGIRequest
        :param consumer_group_id: A consumer group ID.
        :type consumer_group_id: str
        :raises: OperationPostponed when an async operation is performed
        """
        body = request.body_as_json
        units = body.get('units')
        options = body.get('options')
        task = factory.consumer_group_manager().uninstall_content(consumer_group_id,
                                                                  units, options)
        raise pulp_exceptions.OperationPostponed(task)
开发者ID:credativ,项目名称:pulp,代码行数:20,代码来源:consumer_groups.py


注:本文中的pulp.server.managers.factory.consumer_group_manager函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。