• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python factory.consumer_manager函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: get

    def get(self, request, consumer_id):
        """
        List schedules <action>.

        :param request: WSGI request object
        :type request: django.core.handlers.wsgi.WSGIRequest
        :param consumer_id: The consumer ID.
        :type consumer_id: str

        :raises MissingResource: if consumer does not exist

        :return: Response containing consumer's schedules <action>
        :rtype: django.http.HttpResponse
        """

        try:
            factory.consumer_manager().get_consumer(consumer_id)
        except MissingResource:
            raise MissingResource(consumer_id=consumer_id)
        schedules = self.manager.get(consumer_id, self.ACTION)

        schedule_objs = []
        for schedule in schedules:
            obj = scheduled_unit_management_obj(schedule.for_display())
            add_link_schedule(obj, self.ACTION, consumer_id)
            schedule_objs.append(obj)

        return generate_json_response_with_pulp_encoder(schedule_objs)
开发者ID:alanoe,项目名称:pulp,代码行数:28,代码来源:consumers.py


示例2: GET

    def GET(self, consumer_id, repo_id=None):
        """
        Fetch all bind objects referencing the specified consumer_id. Optionally,
        specify a repo_id to fetch all bind objects for the consumer_id to the repo_id

        :param consumer_id: The specified consumer.
        :type  consumer_id: str
        :param repo_id:     The repository to retrieve bindings for (optional)
        :type  repo_id:     str

        :return: A list of dictionaries that represent pulp.server.db.model.consumer.Bind objects
        :rtype:  list
        """
        # Check to make sure the resources exist
        missing_resources = {}
        if repo_id is not None:
            repo = managers.repo_query_manager().find_by_id(repo_id)
            if repo is None:
                missing_resources['repo_id'] = repo_id
        # If get_consumer raises MissingResource we might miss reporting a bad repo_id
        try:
            managers.consumer_manager().get_consumer(consumer_id)
        except MissingResource:
            missing_resources['consumer_id'] = consumer_id

        if len(missing_resources) > 0:
            raise MissingResource(**missing_resources)

        manager = managers.consumer_bind_manager()
        bindings = manager.find_by_consumer(consumer_id, repo_id)
        bindings = [serialization.binding.serialize(b) for b in bindings]
        return self.ok(bindings)
开发者ID:AndreaGiardini,项目名称:pulp,代码行数:32,代码来源:consumers.py


示例3: _validate_consumer_repo

    def _validate_consumer_repo(consumer_id, repo_id, distributor_id):
        """
        Validate that the given consumer, repository, and distributor are present.
        Rather than raising an exception, this method returns a dictionary of missing
        values and allows the caller to decide what exception to raise.

        :param consumer_id:     The consumer id to validate
        :type  consumer_id:     str
        :param repo_id:         The repository id to validate
        :type  repo_id:         str
        :param distributor_id:  The distributor_id to validate
        :type  distributor_id:  str

        :return: A dictionary containing the missing values, or an empty dict if everything is valid
        :rtype:  dict
        """
        missing_values = {}

        try:
            factory.consumer_manager().get_consumer(consumer_id)
        except MissingResource:
            missing_values['consumer_id'] = consumer_id
        try:
            model.Repository.objects.get_repo_or_missing_resource(repo_id)
        except MissingResource:
            missing_values['repo_id'] = repo_id
        try:
            factory.repo_distributor_manager().get_distributor(repo_id, distributor_id)
        except MissingResource:
            missing_values['distributor_id'] = distributor_id

        return missing_values
开发者ID:nbetm,项目名称:pulp,代码行数:32,代码来源:bind.py


示例4: POST

    def POST(self):
        body = self.params()
        id = body.get('id')
        display_name = body.get('display_name')
        description = body.get('description')
        notes = body.get('notes')

        manager = managers.consumer_manager()
        args = [id, display_name, description, notes]
        weight = pulp_config.config.getint('tasks', 'create_weight')
        tags = [resource_tag(dispatch_constants.RESOURCE_CONSUMER_TYPE, id),
                action_tag('create')]

        call_request = CallRequest(manager.register,
                                   args,
                                   weight=weight,
                                   tags=tags)
        call_request.creates_resource(dispatch_constants.RESOURCE_CONSUMER_TYPE, id)

        call_report = CallReport.from_call_request(call_request)
        call_report.serialize_result = False

        consumer = execution.execute_sync(call_request, call_report)
        consumer.update({'_href': serialization.link.child_link_obj(consumer['id'])})
        return self.created(consumer['_href'], consumer)
开发者ID:graco,项目名称:pulp,代码行数:25,代码来源:consumers.py


示例5: bind

 def bind(self, consumer_id, repo_id, distributor_id):
     """
     Bind consumer to a specific distributor associated with
     a repository.  This call is idempotent.
     @param consumer_id: uniquely identifies the consumer.
     @type consumer_id: str
     @param repo_id: uniquely identifies the repository.
     @type repo_id: str
     @param distributor_id: uniquely identifies a distributor.
     @type distributor_id: str
     @return: The Bind object
     @rtype: SON
     @raise MissingResource: when given consumer does not exist.
     """
     # ensure the consumer is valid
     manager = factory.consumer_manager()
     manager.get_consumer(consumer_id)
     # ensure the repository & distributor are valid
     manager = factory.repo_distributor_manager()
     manager.get_distributor(repo_id, distributor_id)
     # perform the bind
     collection = Bind.get_collection()
     try:
         bind = Bind(consumer_id, repo_id, distributor_id)
         collection.save(bind, safe=True)
     except DuplicateKeyError:
         self.__reset_bind(consumer_id, repo_id, distributor_id)
     # fetch the inserted/updated bind
     bind = self.get_bind(consumer_id, repo_id, distributor_id)
     # update history
     details = {'repo_id':repo_id, 'distributor_id':distributor_id}
     manager = factory.consumer_history_manager()
     manager.record_event(consumer_id, 'repo_bound', details)
     return bind
开发者ID:pkilambi,项目名称:pulp,代码行数:34,代码来源:bind.py


示例6: populate

 def populate(self, strategy=constants.DEFAULT_STRATEGY, ssl=False):
     PluginTestBase.populate(self)
     # register child
     manager = managers.consumer_manager()
     manager.register(self.PULP_ID, notes={constants.STRATEGY_NOTE_KEY: strategy})
     manager = managers.repo_importer_manager()
     # add importer
     importer_conf = {
         constants.MANIFEST_URL_KEYWORD: 'http://redhat.com',
         constants.STRATEGY_KEYWORD: constants.DEFAULT_STRATEGY,
         constants.PROTOCOL_KEYWORD: 'file',
     }
     manager.set_importer(self.REPO_ID, constants.HTTP_IMPORTER, importer_conf)
     # add distributors
     if ssl:
         dist_conf = self.dist_conf_with_ssl()
     else:
         dist_conf = self.dist_conf()
     manager = managers.repo_distributor_manager()
     manager.add_distributor(
         self.REPO_ID,
         constants.HTTP_DISTRIBUTOR,
         dist_conf,
         False,
         constants.HTTP_DISTRIBUTOR)
     manager.add_distributor(self.REPO_ID, FAKE_DISTRIBUTOR, {}, False, FAKE_DISTRIBUTOR)
     # bind
     conf = {constants.STRATEGY_KEYWORD: strategy}
     manager = managers.consumer_bind_manager()
     manager.bind(self.PULP_ID, self.REPO_ID, constants.HTTP_DISTRIBUTOR, False, conf)
开发者ID:bartwo,项目名称:pulp,代码行数:30,代码来源:test_plugins.py


示例7: test_syntactic_sugar_methods

    def test_syntactic_sugar_methods(self):
        """
        Tests the syntactic sugar methods for retrieving specific managers.
        """
        # Setup
        factory.initialize()

        # Test
        self.assertTrue(isinstance(factory.authentication_manager(), AuthenticationManager))
        self.assertTrue(isinstance(factory.cert_generation_manager(), CertGenerationManager))
        self.assertTrue(isinstance(factory.certificate_manager(), CertificateManager))
        self.assertTrue(isinstance(factory.password_manager(), PasswordManager))
        self.assertTrue(isinstance(factory.permission_manager(), PermissionManager))
        self.assertTrue(isinstance(factory.permission_query_manager(), PermissionQueryManager))
        self.assertTrue(isinstance(factory.role_manager(), RoleManager))
        self.assertTrue(isinstance(factory.role_query_manager(), RoleQueryManager))
        self.assertTrue(isinstance(factory.user_manager(), UserManager))
        self.assertTrue(isinstance(factory.user_query_manager(), UserQueryManager))
        self.assertTrue(isinstance(factory.repo_manager(), RepoManager))
        self.assertTrue(isinstance(factory.repo_unit_association_manager(),
                                   RepoUnitAssociationManager))
        self.assertTrue(isinstance(factory.repo_publish_manager(), RepoPublishManager))
        self.assertTrue(isinstance(factory.repo_query_manager(), RepoQueryManager))
        self.assertTrue(isinstance(factory.repo_sync_manager(), RepoSyncManager))
        self.assertTrue(isinstance(factory.content_manager(), ContentManager))
        self.assertTrue(isinstance(factory.content_query_manager(), ContentQueryManager))
        self.assertTrue(isinstance(factory.content_upload_manager(), ContentUploadManager))
        self.assertTrue(isinstance(factory.consumer_manager(), ConsumerManager))
        self.assertTrue(isinstance(factory.topic_publish_manager(), TopicPublishManager))
开发者ID:credativ,项目名称:pulp,代码行数:29,代码来源:test_factory.py


示例8: populate

 def populate(self):
     config = {"key1": "value1", "key2": None}
     manager = factory.repo_distributor_manager()
     manager.add_distributor(self.REPO_ID, "mock-distributor", config, True, distributor_id=self.DISTRIBUTOR_ID)
     manager = factory.consumer_manager()
     for consumer_id in self.ALL_CONSUMERS:
         manager.register(consumer_id)
开发者ID:nbetm,项目名称:pulp,代码行数:7,代码来源:test_bind.py


示例9: bind

    def bind(self, consumer_id, repo_id, distributor_id, options):
        """
        Request the agent to perform the specified bind. This method will be called
        after the server-side representation of the binding has been created.

        :param consumer_id: The consumer ID.
        :type consumer_id: str
        :param repo_id: A repository ID.
        :type repo_id: str
        :param distributor_id: A distributor ID.
        :type distributor_id: str
        :param options: The options are handler specific.
        :type options: dict
        """
        # agent request
        consumer_manager = managers.consumer_manager()
        binding_manager = managers.consumer_bind_manager()

        consumer = consumer_manager.get_consumer(consumer_id)
        binding = binding_manager.get_bind(consumer_id, repo_id, distributor_id)

        agent_bindings = self.__bindings([binding])
        agent = PulpAgent(consumer)
        agent.consumer.bind(agent_bindings, options)

        # request tracking
        action_id = factory.context().call_request_id
        consumer_manager = managers.consumer_bind_manager()
        consumer_manager.action_pending(
            consumer_id,
            repo_id,
            distributor_id,
            Bind.Action.BIND,
            action_id)
开发者ID:ashcrow,项目名称:pulp,代码行数:34,代码来源:agent.py


示例10: test_get_with_bindings

 def test_get_with_bindings(self):
     """
     Test consumer with bindings.
     """
     # Setup
     manager = factory.repo_manager()
     repo = manager.create_repo(self.REPO_ID)
     manager = factory.repo_distributor_manager()
     manager.add_distributor(self.REPO_ID, self.DISTRIBUTOR_TYPE_ID, {}, True, distributor_id=self.DISTRIBUTOR_ID)
     manager = factory.consumer_manager()
     manager.register(self.CONSUMER_ID)
     manager = factory.consumer_bind_manager()
     bind = manager.bind(self.CONSUMER_ID, self.REPO_ID, self.DISTRIBUTOR_ID)
     # Test
     params = {"bindings": True}
     path = "/v2/consumers/%s/" % self.CONSUMER_ID
     status, body = self.get(path, params=params)
     # Verify
     self.assertEqual(200, status)
     self.assertEqual(self.CONSUMER_ID, body["id"])
     self.assertTrue("_href" in body)
     self.assertTrue(body["_href"].endswith(path))
     self.assertTrue("bindings" in body)
     bindings = body["bindings"]
     self.assertEquals(len(bindings), 1)
     self.assertEquals(bindings[0], self.REPO_ID)
开发者ID:ryanschneider,项目名称:pulp,代码行数:26,代码来源:test_consumer_controller.py


示例11: PUT

    def PUT(self, consumer_id, schedule_id):
        consumer_manager = managers.consumer_manager()
        consumer_manager.get_consumer(consumer_id)

        schedule_data = self.params()
        install_options = None
        units = schedule_data.pop('units', None)

        if 'options' in schedule_data:
            install_options = {'options': schedule_data.pop('options')}

        schedule_manager = managers.schedule_manager()

        tags = [resource_tag(dispatch_constants.RESOURCE_CONSUMER_TYPE, consumer_id),
                resource_tag(dispatch_constants.RESOURCE_SCHEDULE_TYPE, schedule_id),
                action_tag('update_unit_uninstall_schedule')]

        call_request = CallRequest(schedule_manager.update_unit_uninstall_schedule,
                                   [consumer_id, schedule_id, units, install_options, schedule_data],
                                   tags=tags,
                                   archive=True)
        call_request.reads_resource(dispatch_constants.RESOURCE_CONSUMER_TYPE, consumer_id)
        call_request.updates_resource(dispatch_constants.RESOURCE_SCHEDULE_TYPE, schedule_id)

        execution.execute(call_request)

        scheduler = dispatch_factory.scheduler()
        scheduled_call = scheduler.get(schedule_id)

        scheduled_obj = serialization.dispatch.scheduled_unit_management_obj(scheduled_call)
        scheduled_obj.update(serialization.link.current_link_obj())
        return self.ok(scheduled_obj)
开发者ID:graco,项目名称:pulp,代码行数:32,代码来源:consumers.py


示例12: 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


示例13: populate

    def populate(self, ssl=False):
        PluginTestBase.populate(self)
        # register downstream
        manager = managers.consumer_manager()
        manager.register(self.PULP_ID)
        manager = managers.repo_importer_manager()
        # add importer
        cfg = dict(manifest_url='http://apple.com', protocol='file')
        manager.set_importer(self.REPO_ID, CITRUS_IMPORTER, cfg)
        # add distributor
        if ssl:
            dist_conf = self.dist_conf_with_ssl()
        else:
            dist_conf = self.dist_conf()

        manager = managers.repo_distributor_manager()
        manager.add_distributor(
            self.REPO_ID,
            CITRUS_DISTRUBUTOR,
            dist_conf,
            False,
            CITRUS_DISTRUBUTOR)
        # bind
        manager = managers.consumer_bind_manager()
        manager.bind(self.PULP_ID, self.REPO_ID, CITRUS_DISTRUBUTOR)
开发者ID:pieska,项目名称:pulp,代码行数:25,代码来源:test_plugins.py


示例14: update

    def update(self, consumer_id, content_type, profile):
        """
        Update a unit profile.
        Created if not already exists.
        @param consumer_id: uniquely identifies the consumer.
        @type consumer_id: str
        @param content_type: The profile (content) type ID.
        @type content_type: str
        @param profile: The unit profile
        @type profile: object
        """
        try:
            profiler, config = plugin_api.get_profiler_by_type(content_type)
        except plugin_exceptions.PluginNotFound:
            # Not all profile types have a type specific profiler, so let's use the baseclass
            # Profiler
            profiler, config = (Profiler(), {})
        consumer = factory.consumer_manager().get_consumer(consumer_id)
        # Allow the profiler a chance to update the profile before we save it
        profile = profiler.update_profile(consumer, content_type, profile, config)

        try:
            p = self.get_profile(consumer_id, content_type)
            p['profile'] = profile
            # We store the profile's hash anytime the profile gets altered
            p['profile_hash'] = UnitProfile.calculate_hash(profile)
        except MissingResource:
            p = UnitProfile(consumer_id, content_type, profile)
        collection = UnitProfile.get_collection()
        collection.save(p, safe=True)
        return p
开发者ID:ashcrow,项目名称:pulp,代码行数:31,代码来源:profile.py


示例15: POST

    def POST(self):
        body = self.params()
        consumer_id = body.get('id')
        display_name = body.get('display_name')
        description = body.get('description')
        notes = body.get('notes')
        rsa_pub = body.get('rsa_pub')

        manager = managers.consumer_manager()

        created, certificate = manager.register(
            consumer_id,
            display_name=display_name,
            description=description,
            notes=notes,
            rsa_pub=rsa_pub)

        link = serialization.link.child_link_obj(consumer_id)
        created.update({'_href': link})

        document = {
            'consumer': created,
            'certificate': certificate
        }

        return self.created(link['_href'], document)
开发者ID:AndreaGiardini,项目名称:pulp,代码行数:26,代码来源:consumers.py


示例16: uninstall_content

 def uninstall_content(self, consumer_id, units, options):
     """
     Uninstall content units on a consumer.
     @param consumer_id: The consumer ID.
     @type consumer_id: str
     @param units: A list of content units to be uninstalled.
     @type units: list of:
         { type_id:<str>, type_id:<dict> }
     @param options: Uninstall options; based on unit type.
     @type options: dict
     """
     manager = managers.consumer_manager()
     consumer = manager.get_consumer(consumer_id)
     conduit = ProfilerConduit()
     collated = Units(units)
     for typeid, units in collated.items():
         pc = self.__profiled_consumer(consumer_id)
         profiler, cfg = self.__profiler(typeid)
         units = self.__invoke_plugin(
             profiler.uninstall_units,
             pc,
             units,
             options,
             cfg,
             conduit)
         collated[typeid] = units
     units = collated.join()
     agent = PulpAgent(consumer)
     agent.content.uninstall(units, options)
开发者ID:domcleal,项目名称:pulp,代码行数:29,代码来源:agent.py


示例17: unbind

 def unbind(self, consumer_id, repo_id, distributor_id, options):
     """
     Request the agent to perform the specified unbind.
     @param consumer_id: The consumer ID.
     @type consumer_id: str
     @param repo_id: A repository ID.
     @type repo_id: str
     @param distributor_id: A distributor ID.
     @type distributor_id: str
     @param options: The options are handler specific.
     @type options: dict
     """
     # agent request
     manager = managers.consumer_manager()
     consumer = manager.get_consumer(consumer_id)
     binding = dict(repo_id=repo_id, distributor_id=distributor_id)
     bindings = self.__unbindings([binding])
     agent = PulpAgent(consumer)
     agent.consumer.unbind(bindings, options)
     # request tracking
     action_id = factory.context().call_request_id
     manager = managers.consumer_bind_manager()
     manager.action_pending(
         consumer_id,
         repo_id,
         distributor_id,
         Bind.Action.UNBIND,
         action_id)
开发者ID:domcleal,项目名称:pulp,代码行数:28,代码来源:agent.py


示例18: populate

 def populate(self):
     manager = factory.consumer_manager()
     for id in self.CONSUMER_IDS:
         manager.register(id)
     manager = factory.consumer_profile_manager()
     for id in self.CONSUMER_IDS:
         manager.create(id, 'rpm', self.PROFILE)
开发者ID:pkilambi,项目名称:pulp,代码行数:7,代码来源:test_consumer_controller.py


示例19: test_get_with_bindings

 def test_get_with_bindings(self):
     """
     Test consumer with bindings.
     """
     # Setup
     manager = factory.repo_manager()
     repo = manager.create_repo(self.REPO_ID)
     manager = factory.repo_distributor_manager()
     manager.add_distributor(
         self.REPO_ID,
         self.DISTRIBUTOR_TYPE_ID,
         {},
         True,
         distributor_id=self.DISTRIBUTOR_ID)
     manager = factory.consumer_manager()
     manager.register(self.CONSUMER_ID)
     manager = factory.consumer_bind_manager()
     bind = manager.bind(self.CONSUMER_ID, self.REPO_ID, self.DISTRIBUTOR_ID)
     # Test
     params = {'bindings':True}
     path = '/v2/consumers/%s/' % self.CONSUMER_ID
     status, body = self.get(path, params=params)
     # Verify
     self.assertEqual(200, status)
     self.assertEqual(self.CONSUMER_ID, body['id'])
     self.assertTrue('_href' in body)
     self.assertTrue(body['_href'].endswith(path))
     self.assertTrue('bindings' in body)
     bindings = body['bindings']
     self.assertEquals(len(bindings), 1)
     self.assertEquals(bindings[0]['repo_id'], self.REPO_ID)
     self.assertEquals(bindings[0]['distributor_id'], self.DISTRIBUTOR_ID)
     self.assertEquals(bindings[0]['consumer_actions'], [])
开发者ID:pkilambi,项目名称:pulp,代码行数:33,代码来源:test_consumer_controller.py


示例20: bind

 def bind(self, consumer_id, repo_id, distributor_id):
     """
     Bind consumer to a specific distributor associated with
     a repository.  This call is idempotent.
     @param consumer_id: uniquely identifies the consumer.
     @type consumer_id: str
     @param repo_id: uniquely identifies the repository.
     @type repo_id: str
     @param distributor_id: uniquely identifies a distributor.
     @type distributor_id: str
     @return: The Bind object
     @rtype: SON
     @raise MissingResource: when given consumer does not exist.
     """
     manager = factory.consumer_manager()
     manager.get_consumer(consumer_id)
     manager = factory.repo_distributor_manager()
     distributor = manager.get_distributor(repo_id, distributor_id)
     bind = Bind(consumer_id, repo_id, distributor_id)
     collection = Bind.get_collection()
     try:
         collection.save(bind, safe=True)
         bind = self.get_bind(consumer_id, repo_id, distributor_id)
     except DuplicateKeyError:
         # idempotent
         pass
     manager = factory.consumer_agent_manager()
     manager.bind(consumer_id, repo_id)
     consumer_event_details = {"repo_id": repo_id, "distributor_id": distributor_id}
     factory.consumer_history_manager().record_event(consumer_id, "repo_bound", consumer_event_details)
     return bind
开发者ID:jlsherrill,项目名称:pulp,代码行数:31,代码来源:bind.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python factory.consumer_profile_manager函数代码示例发布时间:2022-05-25
下一篇:
Python factory.consumer_history_manager函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap