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

Python agent.AgentManager类代码示例

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

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



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

示例1: test_unregistered

    def test_unregistered(self, mock_agent, mock_context, mock_factory, mock_delete_queue):
        url = 'test-url'
        queue = 'test-queue'
        consumer_id = 'abc'
        consumer = {'id': consumer_id}
        mock_consumer_manager = Mock()
        mock_consumer_manager.get_consumer = Mock(return_value=consumer)
        mock_factory.consumer_manager = Mock(return_value=mock_consumer_manager)

        mock_context.return_value = Mock(url=url, address=queue)

        # test manager

        agent_manager = AgentManager()

        agent_manager.unregister(consumer_id)

        # validations

        task_tags = [
            tags.resource_tag(tags.ACTION_AGENT_QUEUE_DELETE, consumer['id'])
        ]

        mock_context.assert_called_with(consumer)
        mock_agent.unregister.assert_called_with(mock_context.return_value)
        mock_delete_queue.apply_async.assert_called_once_with(
            args=[url, queue, consumer_id], countdown=QUEUE_DELETE_DELAY, tags=task_tags)
开发者ID:alanoe,项目名称:pulp,代码行数:27,代码来源:test_agent.py


示例2: test_bind

    def test_bind(self, *mocks):

        mock_agent = mocks[0]
        mock_context = mocks[1]
        mock_factory = mocks[2]
        mock_bindings = mocks[3]
        mock_task_status = mocks[4]
        mock_uuid = mocks[5]

        consumer = {'id': '1234'}
        mock_consumer_manager = Mock()
        mock_consumer_manager.get_consumer = Mock(return_value=consumer)
        mock_factory.consumer_manager = Mock(return_value=mock_consumer_manager)

        binding = {}
        mock_bind_manager = Mock()
        mock_bind_manager.get_bind = Mock(return_value=binding)
        mock_bind_manager.action_pending = Mock()
        mock_factory.consumer_bind_manager = Mock(return_value=mock_bind_manager)

        agent_bindings = []
        mock_bindings.return_value = agent_bindings

        task_id = '2345'
        mock_context.return_value = {}
        mock_uuid.return_value = task_id

        # test manager

        repo_id = '100'
        distributor_id = '200'
        options = {}
        agent_manager = AgentManager()
        agent_manager.bind(consumer['id'], repo_id, distributor_id, options)

        # validations

        task_tags = [
            tags.resource_tag(tags.RESOURCE_CONSUMER_TYPE, consumer['id']),
            tags.resource_tag(tags.RESOURCE_REPOSITORY_TYPE, repo_id),
            tags.resource_tag(tags.RESOURCE_REPOSITORY_DISTRIBUTOR_TYPE, distributor_id),
            tags.action_tag(tags.ACTION_AGENT_BIND)
        ]

        mock_consumer_manager.get_consumer.assert_called_with(consumer['id'])
        mock_bind_manager.get_bind.assert_called_with(consumer['id'], repo_id, distributor_id)
        mock_bindings.assert_called_with([binding])

        mock_context.assert_called_with(
            consumer,
            task_id=task_id,
            action='bind',
            consumer_id=consumer['id'],
            repo_id=repo_id,
            distributor_id=distributor_id)

        mock_task_status.assert_called_with(task_id=task_id, worker_name='agent', tags=task_tags)
        mock_agent.bind.assert_called_with(mock_context.return_value, agent_bindings, options)
        mock_bind_manager.action_pending.assert_called_with(
            consumer['id'], repo_id, distributor_id, Bind.Action.BIND, task_id)
开发者ID:alanoe,项目名称:pulp,代码行数:60,代码来源:test_agent.py


示例3: test_invoke_plugin

 def test_invoke_plugin(self):
     method = Mock()
     args = 1, 2, 3
     kwargs = {'a': 1, 'b': 2}
     # test manager
     AgentManager._invoke_plugin(method, *args, **kwargs)
     # validate
     method.assert_called_once_with(*args, **kwargs)
开发者ID:signull,项目名称:pulp,代码行数:8,代码来源:test_agent_manager.py


示例4: test_delete_queue_still_registered

    def test_delete_queue_still_registered(self, agent, consumer_manager):
        url = 'test-url'
        queue = 'test-queue'
        consumer_id = 'test-consumer'

        # test
        AgentManager.delete_queue(url, queue, consumer_id)

        # validation
        consumer_manager.assert_called_once_with()
        consumer_manager = consumer_manager.return_value
        consumer_manager.get_consumer.assert_called_once_with(consumer_id)
        self.assertFalse(agent.called)
开发者ID:alanoe,项目名称:pulp,代码行数:13,代码来源:test_agent.py


示例5: test_uninstall_content

    def test_uninstall_content(self, *mocks):
        mock_agent = mocks[0]
        mock_context = mocks[1]
        mock_factory = mocks[2]
        mock_get_profiler = mocks[3]
        mock_get_profiled_consumer = mocks[4]
        mock_task_status_manager = mocks[5]
        mock_uuid = mocks[6]

        unit = {'type_id': 'xyz', 'unit_key': {}}

        consumer = {'id': '1234'}
        mock_consumer_manager = Mock()
        mock_consumer_manager.get_consumer = Mock(return_value=consumer)
        mock_factory.consumer_manager = Mock(return_value=mock_consumer_manager)

        mock_get_profiled_consumer.return_value = consumer

        mock_profiler = Mock()
        mock_profiler.uninstall_units = Mock(return_value=[unit])
        mock_get_profiler.return_value = (mock_profiler, {})

        task_id = '2345'
        mock_task = {'task_id': task_id}
        mock_task_status_manager.create_task_status = Mock(return_value=mock_task)

        mock_context.return_value = {}

        mock_uuid.return_value = task_id

        # test manager

        options = {'a': 1}
        agent_manager = AgentManager()
        task = agent_manager.uninstall_content(consumer['id'], [unit], options)

        # validations

        task_tags = [
            tags.resource_tag(tags.RESOURCE_CONSUMER_TYPE, consumer['id']),
            tags.action_tag(tags.ACTION_AGENT_UNIT_UNINSTALL)
        ]

        self.assertEqual(task, mock_task)
        mock_consumer_manager.get_consumer.assert_called_with(consumer['id'])
        mock_context.assert_called_with(consumer, task_id=task_id, consumer_id=consumer['id'])
        mock_task_status_manager.create_task_status.assert_called_with(task_id, 'agent',
                                                                       tags=task_tags)
        mock_profiler.uninstall_units.assert_called_with(consumer, [unit], options, {}, ANY)
        mock_agent.uninstall.assert_called_with(mock_context.return_value, [unit], options)
开发者ID:noris-network,项目名称:pulp,代码行数:50,代码来源:test_agent.py


示例6: test_get_agent_bindings

    def test_get_agent_bindings(self, mock_factory):
        bind_payload = {'a': 1, 'b': 2}
        distributor = {'distributor_type_id': '3838'}
        mock_distributor_manager = Mock()
        mock_distributor_manager.get_distributor = Mock(return_value=distributor)
        mock_distributor_manager.create_bind_payload = Mock(return_value=bind_payload)
        mock_factory.repo_distributor_manager = Mock(return_value=mock_distributor_manager)

        # test manager

        bindings = [
            {'consumer_id': '10', 'repo_id': '20', 'distributor_id': '30', 'binding_config': {}},
            {'consumer_id': '40', 'repo_id': '50', 'distributor_id': '60', 'binding_config': {}},
        ]
        agent_bindings = AgentManager._bindings(bindings)

        # validation

        for binding in bindings:
            mock_distributor_manager.get_distributor.assert_any_call(
                binding['repo_id'], binding['distributor_id'])
            mock_distributor_manager.create_bind_payload.assert_any_call(
                binding['repo_id'], binding['distributor_id'], binding['binding_config'])

        self.assertEqual(len(agent_bindings), 2)
        for binding, agent_binding in itertools.izip(bindings, agent_bindings):
            self.assertEqual(binding['repo_id'], agent_binding['repo_id'])
            self.assertEqual(distributor['distributor_type_id'], agent_binding['type_id'])
            self.assertEqual(bind_payload, agent_binding['details'])
开发者ID:signull,项目名称:pulp,代码行数:29,代码来源:test_agent_manager.py


示例7: test_delete_queue

    def test_delete_queue(self, agent, consumer_manager):
        url = 'test-url'
        queue = 'test-queue'
        consumer_id = 'test-consumer'
        consumer_manager.return_value.get_consumer.side_effect = MissingResource

        # test
        AgentManager.delete_queue(url, queue, consumer_id)

        # validation
        consumer_manager.assert_called_once_with()
        consumer_manager = consumer_manager.return_value
        consumer_manager.get_consumer.assert_called_once_with(consumer_id)
        agent.assert_called_once_with()
        agent = agent.return_value
        agent.delete_queue.assert_called_once_with(url, queue)
开发者ID:alanoe,项目名称:pulp,代码行数:16,代码来源:test_agent.py


示例8: test_unregistered

    def test_unregistered(self, mock_agent, mock_context, mock_factory):
        consumer = {'id': 'xyz'}
        mock_consumer_manager = Mock()
        mock_consumer_manager.get_consumer = Mock(return_value=consumer)
        mock_factory.consumer_manager = Mock(return_value=mock_consumer_manager)

        mock_context.return_value = {}

        # test manager

        agent_manager = AgentManager()
        consumer_id = 'abc'
        agent_manager.unregistered(consumer_id)

        # validations

        mock_context.assert_called_with(consumer)
        mock_agent.unregistered.assert_called_with(mock_context.return_value)
开发者ID:signull,项目名称:pulp,代码行数:18,代码来源:test_agent_manager.py


示例9: test_find_profiler_not_found

    def test_find_profiler_not_found(self, mock_plugins):
        type_id = '2344'
        mock_plugins.get_profiler_by_type.side_effect = plugin_exceptions.PluginNotFound()

        # test manager

        plugin, cfg = AgentManager._profiler(type_id)

        # validation

        mock_plugins.get_profiler_by_type.assert_called_with(type_id)
        self.assertTrue(isinstance(plugin, Profiler))
        self.assertEqual(cfg, {})
开发者ID:signull,项目名称:pulp,代码行数:13,代码来源:test_agent_manager.py


示例10: test_find_profiler

    def test_find_profiler(self, mock_plugins):
        type_id = '2344'
        plugin = Mock()
        mock_plugins.get_profiler_by_type.return_value = (plugin, {})

        # test manager

        _plugin, cfg = AgentManager._profiler(type_id)

        # validation

        mock_plugins.get_profiler_by_type.assert_called_with(type_id)
        self.assertEqual(plugin, _plugin)
        self.assertEqual(cfg, {})
开发者ID:signull,项目名称:pulp,代码行数:14,代码来源:test_agent_manager.py


示例11: test_cancel

    def test_cancel(self, agent, context, mock_factory):
        consumer = {'id': 'xyz'}
        mock_consumer_manager = Mock()
        mock_consumer_manager.get_consumer = Mock(return_value=consumer)
        mock_factory.consumer_manager = Mock(return_value=mock_consumer_manager)

        mock_context = Mock()
        mock_context.uuid = 'test-uuid'
        mock_context.url = 'http://broker.com'
        context.return_value = mock_context

        mock_agent = Mock()
        agent.return_value = mock_agent

        # test manager

        task_id = '1234'
        agent_manager = AgentManager()
        consumer_id = 'abc'
        agent_manager.cancel_request(consumer_id, task_id)

        # validations

        mock_agent.cancel.assert_called_with(mock_context, task_id)
开发者ID:signull,项目名称:pulp,代码行数:24,代码来源:test_agent_manager.py


示例12: test_get_agent_unbindings

    def test_get_agent_unbindings(self, m_model):
        distributor = model.Distributor(distributor_type_id='3838')
        m_model.Distributor.objects.get_or_404.return_value = distributor

        bindings = [
            {'consumer_id': '10', 'repo_id': '20', 'distributor_id': '30', 'binding_config': {}},
            {'consumer_id': '40', 'repo_id': '50', 'distributor_id': '60', 'binding_config': {}},
        ]
        agent_bindings = AgentManager._unbindings(bindings)

        for binding in bindings:
            m_model.Distributor.objects.get_or_404.assert_any_call(
                repo_id=binding['repo_id'], distributor_id=binding['distributor_id'])

        self.assertEqual(len(agent_bindings), 2)
        for binding, agent_binding in itertools.izip(bindings, agent_bindings):
            self.assertEqual(binding['repo_id'], agent_binding['repo_id'])
            self.assertEqual(distributor['distributor_type_id'], agent_binding['type_id'])
开发者ID:alanoe,项目名称:pulp,代码行数:18,代码来源:test_agent.py


示例13: test_get_agent_unbindings_distributor_deleted

    def test_get_agent_unbindings_distributor_deleted(self, m_model):
        """
        Test that AgentManager._unbindings does not raise an exception when the distributor is
        deleted and returns None as the distributor_type_id.
        """
        m_model.Distributor.objects.get_or_404.side_effect = MissingResource
        bindings = [
            {'consumer_id': '10', 'repo_id': '20', 'distributor_id': '30', 'binding_config': {}},
            {'consumer_id': '40', 'repo_id': '50', 'distributor_id': '60', 'binding_config': {}},
        ]
        agent_bindings = AgentManager._unbindings(bindings)

        # validation
        self.assertTrue(m_model.Distributor.objects.get_or_404.called)
        self.assertEqual(len(agent_bindings), 2)
        for binding, agent_binding in itertools.izip(bindings, agent_bindings):
            self.assertEqual(binding['repo_id'], agent_binding['repo_id'])
            self.assertEqual(None, agent_binding['type_id'])
开发者ID:alanoe,项目名称:pulp,代码行数:18,代码来源:test_agent.py


示例14: test_profiled_consumer

    def test_profiled_consumer(self, mock_factory):
        consumer_id = '2345'
        type_id = 123
        profile = {'a': 1}
        profiles = [{'content_type': type_id, 'profile': profile}]
        mock_profile_manager = Mock()
        mock_profile_manager.get_profiles = Mock(return_value=profiles)
        mock_factory.consumer_profile_manager = Mock(return_value=mock_profile_manager)

        # test manager

        profiled = AgentManager._profiled_consumer(consumer_id)

        # validation

        mock_profile_manager.get_profiles.assert_called_once_with(consumer_id)
        self.assertTrue(isinstance(profiled, ProfiledConsumer))
        self.assertEqual(profiled.id, consumer_id)
        self.assertEqual(profiled.profiles, {type_id: profile})
开发者ID:signull,项目名称:pulp,代码行数:19,代码来源:test_agent_manager.py


示例15: test_get_agent_unbindings_distributor_deleted

    def test_get_agent_unbindings_distributor_deleted(self, mock_repo_distributor_manager):
        # Test that AgentManager._unbindings does not raise an exception
        # when the distributor is deleted and returns None as the distributor_type_id.
        def test_get_distributor():
            raise MissingResource()
        mock_repo_distributor_manager.get_distributor = test_get_distributor

        # test
        bindings = [
            {'consumer_id': '10', 'repo_id': '20', 'distributor_id': '30', 'binding_config': {}},
            {'consumer_id': '40', 'repo_id': '50', 'distributor_id': '60', 'binding_config': {}},
        ]
        agent_bindings = AgentManager._unbindings(bindings)

        # validation
        self.assertEqual(len(agent_bindings), 2)
        for binding, agent_binding in itertools.izip(bindings, agent_bindings):
            self.assertEqual(binding['repo_id'], agent_binding['repo_id'])
            self.assertEqual(None, agent_binding['type_id'])
开发者ID:CUXIDUMDUM,项目名称:pulp,代码行数:19,代码来源:test_agent_manager.py


示例16: test_get_agent_bindings

    def test_get_agent_bindings(self, m_model, m_dist_cont):
        bind_payload = {'a': 1, 'b': 2}
        distributor = model.Distributor(distributor_type_id='3838')
        m_model.Distributor.objects.get_or_404.return_value = distributor
        m_dist_cont.create_bind_payload = Mock(return_value=bind_payload)

        bindings = [
            {'consumer_id': '10', 'repo_id': '20', 'distributor_id': '30', 'binding_config': {}},
            {'consumer_id': '40', 'repo_id': '50', 'distributor_id': '60', 'binding_config': {}},
        ]
        agent_bindings = AgentManager._bindings(bindings)

        for binding in bindings:
            m_model.Distributor.objects.get_or_404.assert_any_call(
                repo_id=binding['repo_id'], distributor_id=binding['distributor_id'])
            m_dist_cont.create_bind_payload.assert_any_call(
                binding['repo_id'], binding['distributor_id'], binding['binding_config'])

        self.assertEqual(len(agent_bindings), 2)
        for binding, agent_binding in itertools.izip(bindings, agent_bindings):
            self.assertEqual(binding['repo_id'], agent_binding['repo_id'])
            self.assertEqual(distributor['distributor_type_id'], agent_binding['type_id'])
            self.assertEqual(bind_payload, agent_binding['details'])
开发者ID:alanoe,项目名称:pulp,代码行数:23,代码来源:test_agent.py


示例17: test_unbind

    def test_unbind(self, *mocks):
        mock_agent = mocks[0]
        mock_context = mocks[1]
        mock_factory = mocks[2]
        mock_unbindings = mocks[3]
        mock_task_status_manager = mocks[4]
        mock_uuid = mocks[5]

        consumer = {'id': '1234'}
        mock_consumer_manager = Mock()
        mock_consumer_manager.get_consumer = Mock(return_value=consumer)
        mock_factory.consumer_manager = Mock(return_value=mock_consumer_manager)

        repo_id = '100'
        distributor_id = '200'
        binding = {'repo_id': repo_id, 'distributor_id': distributor_id}
        mock_bind_manager = Mock()
        mock_bind_manager.action_pending = Mock()
        mock_factory.consumer_bind_manager = Mock(return_value=mock_bind_manager)

        agent_bindings = []
        mock_unbindings.return_value = agent_bindings

        task_id = '2345'
        mock_task = {'task_id': task_id}
        mock_task_status_manager.create_task_status = Mock(return_value=mock_task)

        mock_context.return_value = {}

        mock_uuid.return_value = task_id

        # test manager

        options = {}
        agent_manager = AgentManager()
        task = agent_manager.unbind(consumer['id'], repo_id, distributor_id, options)

        # validations

        tags = [
            resource_tag(dispatch_constants.RESOURCE_CONSUMER_TYPE, consumer['id']),
            resource_tag(dispatch_constants.RESOURCE_REPOSITORY_TYPE, repo_id),
            resource_tag(dispatch_constants.RESOURCE_REPOSITORY_DISTRIBUTOR_TYPE, distributor_id),
            action_tag(ACTION_AGENT_UNBIND)
        ]

        mock_consumer_manager.get_consumer.assert_called_with(consumer['id'])
        mock_unbindings.assert_called_with([binding])

        mock_context.assert_called_with(
            consumer,
            task_id=task_id,
            action='unbind',
            consumer_id=consumer['id'],
            repo_id=repo_id,
            distributor_id=distributor_id)

        self.assertEqual(task, mock_task)
        mock_task_status_manager.create_task_status.assert_called_with(task_id, 'agent', tags=tags)
        mock_agent.unbind.assert_called_with(mock_context.return_value, agent_bindings, options)
        mock_bind_manager.action_pending.assert_called_with(
            consumer['id'], repo_id, distributor_id, Bind.Action.UNBIND, task_id)
开发者ID:signull,项目名称:pulp,代码行数:62,代码来源:test_agent_manager.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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