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

Python factory.consumer_profile_manager函数代码示例

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

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



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

示例1: PUT

    def PUT(self, consumer_id, content_type):
        """
        Update the association of a profile with a consumer by content type ID.
        @param consumer_id: A consumer ID.
        @type consumer_id: str
        @param content_type: A content unit type ID.
        @type content_type: str
        @return: The updated model object:
            {consumer_id:<str>, content_type:<str>, profile:<dict>}
        @rtype: dict
        """
        body = self.params()
        profile = body.get('profile')

        manager = managers.consumer_profile_manager()
        tags = [resource_tag(dispatch_constants.RESOURCE_CONSUMER_TYPE, consumer_id),
                resource_tag(dispatch_constants.RESOURCE_CONTENT_UNIT_TYPE, content_type),
                action_tag('profile_update')]

        call_request = CallRequest(manager.update,
                                   [consumer_id, content_type],
                                   {'profile': profile},
                                   tags=tags,
                                   weight=0,
                                   kwarg_blacklist=['profile'])
        call_request.reads_resource(dispatch_constants.RESOURCE_CONSUMER_TYPE, consumer_id)

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

        consumer = execution.execute_sync(call_request, call_report)
        link = serialization.link.child_link_obj(consumer_id, content_type)
        consumer.update(link)

        return self.ok(consumer)
开发者ID:graco,项目名称:pulp,代码行数:35,代码来源:consumers.py


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


示例3: DELETE

 def DELETE(self, consumer_id, content_type):
     """
     Delete an association between the specified
     consumer and profile.  Designed to be idempotent.
     @param consumer_id: A consumer ID.
     @type consumer_id: str
     @param content_type: The content type ID.
     @type content_type: str
     @return: The deleted model object:
         {consumer_id:<str>, content_type:<str>, profile:<dict>}
         Or, None if bind does not exist.
     @rtype: dict
     """
     manager = managers.consumer_profile_manager()
     resources = {
         dispatch_constants.RESOURCE_CONSUMER_TYPE:
             {consumer_id:dispatch_constants.RESOURCE_READ_OPERATION},
     }
     args = [
         consumer_id,
         content_type,
     ]
     tags = [
         resource_tag(dispatch_constants.RESOURCE_CONSUMER_TYPE, consumer_id),
     ]
     call_request = CallRequest(manager.delete,
                                args=args,
                                resources=resources,
                                tags=tags)
     return self.ok(execution.execute(call_request))
开发者ID:graco,项目名称:pulp,代码行数:30,代码来源:consumers.py


示例4: unregister

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

        @param id: identifies the consumer being unregistered
        @type  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(id)
        
        # Remove associate bind
        manager = factory.consumer_bind_manager()
        manager.consumer_deleted(id)
        
        # Remove associated profiles
        manager = factory.consumer_profile_manager()
        manager.consumer_deleted(id)

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

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

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


示例5: test_get_profiles_none

 def test_get_profiles_none(self):
     # Setup
     self.populate()
     # Test
     manager = factory.consumer_profile_manager()
     profiles = manager.get_profiles(self.CONSUMER_ID)
     self.assertEquals(len(profiles), 0)
开发者ID:bartwo,项目名称:pulp,代码行数:7,代码来源:test_profile_manager.py


示例6: test_missing_consumer

 def test_missing_consumer(self):
     # Test
     manager = factory.consumer_profile_manager()
     # self.CONSUMER_ID is not an existing consumer, as it is not built during setUp(), so this
     # should raise MissingResource
     self.assertRaises(MissingResource, manager.update, self.CONSUMER_ID, self.TYPE_1,
                       self.PROFILE_1)
开发者ID:alanoe,项目名称:pulp,代码行数:7,代码来源:test_profile.py


示例7: units_applicable

 def units_applicable(self, criteria, units):
     """
     Detemine and report which of the specified content units
     is applicable to consumers specified by the I{criteria}.
     @param criteria: The consumer selection criteria.
     @type criteria: list
     @param units: A list of content units to be installed.
     @type units: list of:
         { type_id:<str>, unit_key:<dict> }
     @return: A dict:
         {consumer_id:[<ApplicabilityReport>]}
     @rtype: list
     """
     result = {}
     conduit = ProfilerConduit()
     manager = managers.consumer_query_manager()
     ids = [c['id'] for c in manager.find_by_criteria(criteria)]
     manager = managers.consumer_profile_manager()
     profiles = manager.find_profiles(ids)
     for id in ids:
         for unit in units:
             typeid = unit['type_id']
             profiler, cfg = self.__profiler(typeid)
             pc = self.__profiled_consumer(id)
             report = profiler.unit_applicable(pc, unit, cfg, conduit)
             report.unit = unit
             ulist = result.setdefault(id, [])
             ulist.append(report)
     return result
开发者ID:ehelms,项目名称:pulp,代码行数:29,代码来源:applicability.py


示例8: post

    def post(self, request, consumer_id):
        """
        Associate a profile with a consumer by content type ID.

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

        :raises MissingValue: if some parameter were not provided

        :return: Response representing the created profile
        :rtype: django.http.HttpResponse
        """

        body = request.body_as_json
        content_type = body.get('content_type')
        profile = body.get('profile')

        manager = factory.consumer_profile_manager()
        new_profile = manager.create(consumer_id, content_type, profile)
        if content_type is None:
            raise MissingValue('content_type')
        link = add_link_profile(new_profile)
        response = generate_json_response_with_pulp_encoder(new_profile)
        redirect_response = generate_redirect_response(response, link['_href'])
        return redirect_response
开发者ID:alanoe,项目名称:pulp,代码行数:27,代码来源:consumers.py


示例9: PUT

 def PUT(self, consumer_id, content_type):
     """
     Update the association of a profile with a consumer by content type ID.
     @param consumer_id: A consumer ID.
     @type consumer_id: str
     @param content_type: A content unit type ID.
     @type content_type: str
     @return: The updated model object:
         {consumer_id:<str>, content_type:<str>, profile:<dict>}
     @rtype: dict
     """
     body = self.params()
     profile = body.get('profile')
     resources = {
         dispatch_constants.RESOURCE_CONSUMER_TYPE:
             {consumer_id:dispatch_constants.RESOURCE_READ_OPERATION},
     }
     args = [
         consumer_id,
         content_type,
         profile,
     ]
     manager = managers.consumer_profile_manager()
     call_request = CallRequest(
         manager.update,
         args,
         resources=resources,
         weight=0)
     link = serialization.link.child_link_obj(consumer_id, content_type)
     result = execution.execute_sync_created(self, call_request, link)
     return result
开发者ID:ryanschneider,项目名称:pulp,代码行数:31,代码来源:consumers.py


示例10: test_delete_not_found

 def test_delete_not_found(self):
     # Setup
     manager = factory.consumer_profile_manager()
     # Test
     path = '/v2/consumers/%s/profiles/unknown/' % self.CONSUMER_ID
     status, body = self.delete(path)
     self.assertEqual(status, 404)
开发者ID:jessegonzalez,项目名称:pulp,代码行数:7,代码来源:test_consumer_controller.py


示例11: populate_profile

 def populate_profile(self, id, env):
     manager = managers.consumer_profile_manager()
     profile = []
     for i in range(0, env.profile_units):
         p = PROFILE_TEMPLATE.copy()
         p['name'] = 'unit_%d' % i
         profile.append(p)
     manager.create(id, self.TYPE_ID, profile)
开发者ID:bechtoldt,项目名称:pulp_rpm,代码行数:8,代码来源:test_errata.py


示例12: test_get_profile_not_found

 def test_get_profile_not_found(self):
     # Setup
     self.populate()
     # Test
     manager = factory.consumer_profile_manager()
     manager.create(self.CONSUMER_ID, self.TYPE_2, self.PROFILE_2)
     # Verify
     self.assertRaises(MissingResource, manager.get_profile, self.CONSUMER_ID, self.TYPE_1)
开发者ID:bartwo,项目名称:pulp,代码行数:8,代码来源:test_profile_manager.py


示例13: GET

 def GET(self, consumer_id, content_type):
     """
     @param consumer_id: The consumer ID.
     @type consumer_id: str
     """
     manager = managers.consumer_profile_manager()
     profile = manager.get_profile(consumer_id, content_type)
     serialized = serialization.consumer.profile(profile)
     return self.ok(serialized)
开发者ID:AndreaGiardini,项目名称:pulp,代码行数:9,代码来源:consumers.py


示例14: test_get_profile

 def test_get_profile(self):
     # Setup
     self.populate()
     # Test
     manager = factory.consumer_profile_manager()
     manager.create(self.CONSUMER_ID, self.TYPE_1, self.PROFILE_1)
     manager.create(self.CONSUMER_ID, self.TYPE_2, self.PROFILE_2)
     profile = manager.get_profile(self.CONSUMER_ID, self.TYPE_1)
     self.assertTrue(profile is not None)
开发者ID:bartwo,项目名称:pulp,代码行数:9,代码来源:test_profile_manager.py


示例15: GET

 def GET(self, consumer_id):
     """
     Get all profiles associated with a consumer.
     @param consumer_id: The consumer ID.
     @type consumer_id: str
     @return: A list of profiles:
       profile is: {consumer_id:<str>, content_type:<str>, profile:<dict>}
     @return: list
     """
     manager = managers.consumer_profile_manager()
     profiles = manager.get_profiles(consumer_id)
     profiles = [serialization.consumer.profile(p) for p in profiles]
     return self.ok(profiles)
开发者ID:aweiteka,项目名称:pulp,代码行数:13,代码来源:consumers.py


示例16: test_get_by_type

 def test_get_by_type(self):
     # Setup
     self.populate()
     manager = factory.consumer_profile_manager()
     manager.create(self.CONSUMER_ID, self.TYPE_1, self.PROFILE_1)
     manager.create(self.CONSUMER_ID, self.TYPE_2, self.PROFILE_2)
     # Test
     path = '/v2/consumers/%s/profiles/%s/' % (self.CONSUMER_ID, self.TYPE_1)
     status, body = self.get(path)
     self.assertEqual(status, 200)
     self.assertEqual(body['consumer_id'], self.CONSUMER_ID)
     self.assertEqual(body['content_type'], self.TYPE_1)
     self.assertEqual(body['profile'], self.PROFILE_1)
开发者ID:pkilambi,项目名称:pulp,代码行数:13,代码来源:test_consumer_controller.py


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


示例18: test_create

 def test_create(self):
     # Setup
     self.populate()
     # Test
     manager = factory.consumer_profile_manager()
     manager.update(self.CONSUMER_ID, self.TYPE_1, self.PROFILE_1)
     # Verify
     collection = UnitProfile.get_collection()
     cursor = collection.find({"consumer_id": self.CONSUMER_ID})
     profiles = list(cursor)
     self.assertEquals(len(profiles), 1)
     self.assertEquals(profiles[0]["consumer_id"], self.CONSUMER_ID)
     self.assertEquals(profiles[0]["content_type"], self.TYPE_1)
     self.assertEquals(profiles[0]["profile"], self.PROFILE_1)
开发者ID:ryanschneider,项目名称:pulp,代码行数:14,代码来源:test_profile_manager.py


示例19: test_fetch_by_type2

 def test_fetch_by_type2(self):
     # Setup
     self.populate()
     collection = UnitProfile.get_collection()
     manager = factory.consumer_profile_manager()
     manager.update(self.CONSUMER_ID, self.TYPE_1, self.PROFILE_1)
     manager.update(self.CONSUMER_ID, self.TYPE_2, self.PROFILE_2)
     # Test
     profile = manager.get_profile(self.CONSUMER_ID, self.TYPE_2)
     # Verify
     self.assertTrue(profile is not None)
     self.assertEquals(profile["consumer_id"], self.CONSUMER_ID)
     self.assertEquals(profile["content_type"], self.TYPE_2)
     self.assertEquals(profile["profile"], self.PROFILE_2)
开发者ID:ryanschneider,项目名称:pulp,代码行数:14,代码来源:test_profile_manager.py


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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python factory.content_manager函数代码示例发布时间:2022-05-25
下一篇:
Python factory.consumer_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