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

Python factory.consumer_agent_manager函数代码示例

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

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



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

示例1: test_content_install

 def test_content_install(self):
     # Setup
     self.populate()
     # Test
     units = [
         {'type_id':'rpm',
          'unit_key':{'name':'zsh', 'version':'1.0'}},
         {'type_id':'rpm',
          'unit_key':{'name':'bar', 'version':'1.0'}},
         {'type_id':'rpm',
          'unit_key':{'name':'abc', 'version':'1.0'}},
         {'type_id':'mock-type',
          'unit_key':{'name':'monster', 'version':'5.0'}},
         {'type_id':'unsupported',
          'unit_key':{'name':'xxx', 'version':'1.0'}},
     ]
     options = dict(importkeys=True)
     manager = factory.consumer_agent_manager()
     manager.install_content(self.CONSUMER_ID, units, options)
     # Verify
     profiler = plugin_api.get_profiler_by_type('rpm')[0]
     pargs = profiler.install_units.call_args[0]
     self.assertEquals(pargs[0].id, self.CONSUMER_ID)
     self.assertEquals(pargs[0].profiles, {})
     self.assertEquals(pargs[1], units[:3])
     self.assertEquals(pargs[2], options)
     profiler = plugin_api.get_profiler_by_type('mock-type')[0]
     pargs = profiler.install_units.call_args[0]
     self.assertEquals(pargs[0].id, self.CONSUMER_ID)
     self.assertEquals(pargs[0].profiles, {})
     self.assertEquals(pargs[1], units[3:4])
     self.assertEquals(pargs[2], options)
开发者ID:ehelms,项目名称:pulp,代码行数:32,代码来源:test_agent_manager.py


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


示例3: create_unit_install_schedule

    def create_unit_install_schedule(self, consumer_id, units, install_options, schedule_data ):
        """
        Create a schedule for installing content units on a consumer.
        @param consumer_id: unique id for the consumer
        @param units: list of unit type and unit key dicts
        @param install_options: options to pass to the install manager
        @param schedule_data: scheduling data
        @return: schedule id
        """
        self._validate_consumer(consumer_id)
        self._validate_keys(install_options, _UNIT_INSTALL_OPTION_KEYS)
        if 'schedule' not in schedule_data:
            raise pulp_exceptions.MissingValue(['schedule'])

        manager = managers_factory.consumer_agent_manager()
        args = [consumer_id]
        kwargs = {'units': units,
                  'options': install_options.get('options', {})}
        weight = pulp_config.config.getint('tasks', 'consumer_content_weight')
        tags = [resource_tag(dispatch_constants.RESOURCE_CONSUMER_TYPE, consumer_id),
                action_tag('unit_install'), action_tag('scheduled_unit_install')]
        call_request = CallRequest(manager.install_content, args, kwargs, weight=weight, tags=tags, archive=True)
        call_request.reads_resource(dispatch_constants.RESOURCE_CONSUMER_TYPE, consumer_id)

        scheduler = dispatch_factory.scheduler()
        schedule_id = scheduler.add(call_request, **schedule_data)
        return schedule_id
开发者ID:ehelms,项目名称:pulp,代码行数:27,代码来源:cud.py


示例4: force_unbind

def force_unbind(consumer_id, repo_id, distributor_id, options):
    """
    Get the unbind itinerary.
    A forced unbind immediately deletes the binding instead
    of marking it deleted and going through that lifecycle.
    It is intended to be used to clean up orphaned bindings
    caused by failed/unconfirmed unbind actions on the consumer.
    The itinerary is:
      1. Delete the binding on the server.
      2. Request that the consumer (agent) perform the unbind.
    :param consumer_id: A 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: Unbind options passed to the agent handler.
    :type options: dict
    :returns TaskResult containing the result of the unbind & any spawned tasks or a dictionary
             of the unbind result if no tasks were spawned.
    :rtype: TaskResult
    """

    bind_manager = managers.consumer_bind_manager()
    binding = bind_manager.get_bind(consumer_id, repo_id, distributor_id)
    bind_manager.delete(consumer_id, repo_id, distributor_id, True)
    response = None

    if binding['notify_agent']:
        agent_manager = managers.consumer_agent_manager()
        task = agent_manager.unbind(consumer_id, repo_id, distributor_id, options)
        response = TaskResult(spawned_tasks=[task])

    return response
开发者ID:preethit,项目名称:pulp-1,代码行数:34,代码来源:consumer.py


示例5: uninstall_content

    def uninstall_content(self, consumer_group_id, units, options):
        group_collection = validate_existing_consumer_group(consumer_group_id)
        consumer_group = group_collection.find_one({'id': consumer_group_id})
        agent_manager = manager_factory.consumer_agent_manager()

        for consumer_id in consumer_group['consumer_ids']:
            agent_manager.uninstall_content(consumer_id, units, options)
开发者ID:ehelms,项目名称:pulp,代码行数:7,代码来源:cud.py


示例6: unbind

 def unbind(self, consumer_id, repo_id, distributor_id):
     """
     Unbind consumer to a specifiec distirbutor 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
     """
     query = dict(consumer_id=consumer_id, repo_id=repo_id, distributor_id=distributor_id)
     collection = Bind.get_collection()
     bind = collection.find_one(query)
     if bind is None:
         # idempotent
         return
     collection.remove(bind, safe=True)
     manager = factory.consumer_agent_manager()
     manager.unbind(consumer_id, repo_id)
     consumer_event_details = {"repo_id": repo_id, "distributor_id": distributor_id}
     factory.consumer_history_manager().record_event(consumer_id, "repo_unbound", consumer_event_details)
     return bind
开发者ID:jlsherrill,项目名称:pulp,代码行数:25,代码来源:bind.py


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


示例8: uninstall

 def uninstall(self, 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:
             {id:dispatch_constants.RESOURCE_READ_OPERATION},
     }
     args = [
         id,
         units,
         options,
     ]
     manager = managers.consumer_agent_manager()
     call_request = CallRequest(
         manager.uninstall_content,
         args,
         resources=resources,
         weight=pulp_config.config.getint('tasks', 'consumer_content_weight'),
         asynchronous=True,
         archive=True,)
     result = execution.execute_async(self, call_request)
     return result
开发者ID:ryanschneider,项目名称:pulp,代码行数:33,代码来源:consumers.py


示例9: consumer_content_update_itinerary

def consumer_content_update_itinerary(consumer_id, units, options):
    """
    Create an itinerary for consumer content update.
    @param consumer_id: unique id of the consumer
    @type consumer_id: str
    @param units: units to update
    @type units: list or tuple
    @param options: options to pass to the update manager
    @type options: dict or None
    @return: list of call requests
    @rtype: list
    """
    manager = managers_factory.consumer_agent_manager()
    args = [consumer_id]
    kwargs = {'units': units, 'options': options}
    weight = pulp_config.config.getint('tasks', 'consumer_content_weight')
    tags = [resource_tag(dispatch_constants.RESOURCE_CONSUMER_TYPE, consumer_id),
            action_tag('unit_update')]
    call_request = CallRequest(
        manager.update_content,
        args,
        kwargs,
        weight=weight,
        tags=tags,
        archive=True,
        asynchronous=True,
        kwarg_blacklist=['options'])
    call_request.add_control_hook(dispatch_constants.CALL_CANCEL_CONTROL_HOOK, cancel_agent_request)
    call_request.reads_resource(dispatch_constants.RESOURCE_CONSUMER_TYPE, consumer_id)
    return [call_request]
开发者ID:ashcrow,项目名称:pulp,代码行数:30,代码来源:consumer.py


示例10: test_content_install

 def test_content_install(self):
     # Setup
     self.populate()
     # Test
     units = [
         {"type_id": "rpm", "unit_key": {"name": "zsh", "version": "1.0"}},
         {"type_id": "rpm", "unit_key": {"name": "bar", "version": "1.0"}},
         {"type_id": "rpm", "unit_key": {"name": "abc", "version": "1.0"}},
         {"type_id": "mock-type", "unit_key": {"name": "monster", "version": "5.0"}},
         {"type_id": "unsupported", "unit_key": {"name": "xxx", "version": "1.0"}},
     ]
     options = dict(importkeys=True)
     manager = factory.consumer_agent_manager()
     manager.install_content(self.CONSUMER_ID, units, options)
     # Verify
     # agent call
     params = mock_agent.Content.install.call_args[0]
     self.assertEqual(sorted(params[0]), sorted(units))
     self.assertEqual(params[1], options)
     # profiler call
     profiler = plugin_api.get_profiler_by_type("rpm")[0]
     pargs = profiler.install_units.call_args[0]
     self.assertEquals(pargs[0].id, self.CONSUMER_ID)
     self.assertEquals(pargs[0].profiles, {})
     self.assertEquals(pargs[1], units[:3])
     self.assertEquals(pargs[2], options)
     profiler = plugin_api.get_profiler_by_type("mock-type")[0]
     pargs = profiler.install_units.call_args[0]
     self.assertEquals(pargs[0].id, self.CONSUMER_ID)
     self.assertEquals(pargs[0].profiles, {})
     self.assertEquals(pargs[1], units[3:4])
     self.assertEquals(pargs[2], options)
开发者ID:pkilambi,项目名称:pulp,代码行数:32,代码来源:test_agent_manager.py


示例11: test_unregistered

 def test_unregistered(self):
     # Setup
     self.populate()
     # Test
     manager = factory.consumer_agent_manager()
     manager.unregistered(self.CONSUMER_ID)
     # verify
     mock_agent.Consumer.unregistered.assert_called_once_with()
开发者ID:pkilambi,项目名称:pulp,代码行数:8,代码来源:test_agent_manager.py


示例12: test_unbind

 def test_unbind(self):
     # Setup
     self.populate()
     manager = factory.consumer_bind_manager()
     bind = manager.bind(
         self.CONSUMER_ID,
         self.REPO_ID,
         self.DISTRIBUTOR_ID)
     # Test
     manager = factory.consumer_agent_manager()
     manager.unbind(self.CONSUMER_ID, self.REPO_ID)
开发者ID:ehelms,项目名称:pulp,代码行数:11,代码来源:test_agent_manager.py


示例13: create_unit_uninstall_schedule

 def create_unit_uninstall_schedule(self, consumer_id, units, uninstall_options, schedule_data):
     """
     Create a schedule for uninstalling content units on a consumer.
     @param consumer_id: unique id for the consumer
     @param units: list of unit type and unit key dicts
     @param uninstall_options: options to pass to the uninstall manager
     @param schedule_data: scheduling data
     @return: schedule id
     """
     manager = managers_factory.consumer_agent_manager()
     return self._create_schedule(manager.uninstall_content, UNIT_UNINSTALL_ACTION, consumer_id, units, uninstall_options, schedule_data)
开发者ID:ryanschneider,项目名称:pulp,代码行数:11,代码来源:consumer.py


示例14: cancel_agent_request

def cancel_agent_request(call_request, call_report):
    """
    Cancel the agent request associated with the task.
    :param call_request: The call request that has been cancelled.
    :type call_request: pulp.server.dispatch.call.CallRequest
    :param call_report: The report associated with the call request to be cancelled.
    :type call_report: pulp.server.dispatch.call.CallReport
    """
    task_id = call_report.call_request_id
    consumer_id = call_request.args[0]
    agent_manager = managers_factory.consumer_agent_manager()
    agent_manager.cancel_request(consumer_id, task_id)
开发者ID:ashcrow,项目名称:pulp,代码行数:12,代码来源:consumer.py


示例15: consumer_deleted

 def consumer_deleted(self, id):
     """
     Notification that a consumer has been deleted.
     Associated binds are removed.
     @param id: A consumer ID.
     @type id: str
     """
     collection = Bind.get_collection()
     agent_manager = factory.consumer_agent_manager()
     for bind in self.find_by_consumer(id):
         collection.remove(bind, safe=True)
         repo_id = bind["repo_id"]
         agent_manager.unbind(id, repo_id)
开发者ID:jlsherrill,项目名称:pulp,代码行数:13,代码来源:bind.py


示例16: repo_deleted

 def repo_deleted(self, repo_id):
     """
     Notification that a repository has been deleted.
     Associated binds are removed.
     @param repo_id: A repo ID.
     @type repo_id: str
     """
     collection = Bind.get_collection()
     agent_manager = factory.consumer_agent_manager()
     for bind in self.find_by_repo(repo_id):
         collection.remove(bind, safe=True)
         consumer_id = bind["consumer_id"]
         agent_manager.unbind(consumer_id, repo_id)
开发者ID:jlsherrill,项目名称:pulp,代码行数:13,代码来源:bind.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: 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


示例19: uninstall_content

def uninstall_content(consumer_id, units, options):
    """
    Uninstall content from a consumer.

    :param consumer_id: unique id of the consumer
    :type consumer_id: str
    :param units: units to install
    :type units: list or tuple
    :param options: options to pass to the install manager
    :type options: dict or None
    :returns Dictionary representation of a task status
    :rtype: dictionary
    """
    agent_manager = managers.consumer_agent_manager()
    return agent_manager.uninstall_content(consumer_id, units, options)
开发者ID:preethit,项目名称:pulp-1,代码行数:15,代码来源:consumer.py


示例20: distributor_deleted

 def distributor_deleted(self, repo_id, distributor_id):
     """
     Notification that a distributor has been deleted.
     Associated binds are removed.
     @param repo_id: A Repo ID.
     @type repo_id: str
     @param distributor_id: A Distributor ID.
     @type distributor_id: str
     """
     collection = Bind.get_collection()
     agent_manager = factory.consumer_agent_manager()
     for bind in self.find_by_distributor(repo_id, distributor_id):
         collection.remove(bind, safe=True)
         consumer_id = bind['consumer_id']
         agent_manager.unbind(consumer_id, repo_id)
开发者ID:ehelms,项目名称:pulp,代码行数:15,代码来源:bind.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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