示例#1
0
文件: agent.py 项目: tomlanyon/pulp
 def cancel_request(self, consumer_id, task_id):
     """
     Cancel an agent request associated with the specified task ID.
     :param consumer_id: The consumer ID.
     :type consumer_id: str
     :param: task_id: The task ID associated with the request.
     :type: str
     """
     manager = managers.consumer_manager()
     consumer = manager.get_consumer(consumer_id)
     agent = PulpAgent(consumer)
     agent.cancel(task_id)
示例#2
0
文件: agent.py 项目: ashcrow/pulp
 def cancel_request(self, consumer_id, task_id):
     """
     Cancel an agent request associated with the specified task ID.
     :param consumer_id: The consumer ID.
     :type consumer_id: str
     :param: task_id: The task ID associated with the request.
     :type: str
     """
     manager = managers.consumer_manager()
     consumer = manager.get_consumer(consumer_id)
     agent = PulpAgent(consumer)
     agent.cancel(task_id)
示例#3
0
文件: agent.py 项目: tomlanyon/pulp
    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)
示例#4
0
 def uninstall(self, id, units, options={}):
     """
     Uninstall content on a consumer.
     @param id: A consumer id.
     @type id: str
     @param units: A list of content units to be uninstalled.
     @type units: list of:
         { type_id:<str>, unit_key:<dict> }
     @param options: Uninstall options; based on unit type.
     @type options: dict
     """
     collection = Consumer.get_collection()
     consumer = collection.find_one({'id': id})
     if consumer is None:
         raise MissingResource(id)
     agent = PulpAgent(consumer)
     agent.uninstall_units(units, options)
示例#5
0
 def uninstall(self, id, units, options={}):
     """
     Uninstall content on a consumer.
     @param id: A consumer id.
     @type id: str
     @param units: A list of content units to be uninstalled.
     @type units: list of:
         { type_id:<str>, unit_key:<dict> }
     @param options: Uninstall options; based on unit type.
     @type options: dict
     """
     collection = Consumer.get_collection()
     consumer = collection.find_one({'id':id})
     if consumer is None:
         raise MissingResource(id)
     agent = PulpAgent(consumer)
     agent.uninstall_units(units, options)
示例#6
0
文件: agent.py 项目: tomlanyon/pulp
 def unregistered(self, consumer_id):
     """
     Notification that a consumer (agent) has
     been unregistered.  This ensure that all registration
     artifacts have been cleaned up.
     :param consumer_id: The consumer ID.
     :type consumer_id: str
     """
     manager = managers.consumer_manager()
     consumer = manager.get_consumer(consumer_id)
     agent = PulpAgent(consumer)
     agent.consumer.unregistered()
示例#7
0
文件: agent.py 项目: omps/pulp
    def bind(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
        :return: The task created by the bind
        :rtype: dict
        """
        # track agent operations using a pseudo task
        task_id = str(uuid4())
        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)
        ]
        task = TaskStatusManager.create_task_status(task_id, 'agent', tags=task_tags)

        # 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 = AgentManager._bindings([binding])
        context = Context(
            consumer,
            task_id=task_id,
            action='bind',
            consumer_id=consumer_id,
            repo_id=repo_id,
            distributor_id=distributor_id)
        agent = PulpAgent()
        agent.consumer.bind(context, agent_bindings, options)

        # bind action tracking
        consumer_manager = managers.consumer_bind_manager()
        consumer_manager.action_pending(
            consumer_id,
            repo_id,
            distributor_id,
            Bind.Action.BIND,
            task_id)

        return task
示例#8
0
文件: agent.py 项目: omps/pulp
    def unbind(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
        :return: A task ID that may be used to track the agent request.
        :rtype: str
        """
        # track agent operations using a pseudo task
        task_id = str(uuid4())
        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_UNBIND)
        ]
        task = TaskStatusManager.create_task_status(task_id, 'agent', tags=task_tags)

        # agent request
        manager = managers.consumer_manager()
        consumer = manager.get_consumer(consumer_id)
        binding = dict(repo_id=repo_id, distributor_id=distributor_id)
        bindings = AgentManager._unbindings([binding])
        context = Context(
            consumer,
            task_id=task_id,
            action='unbind',
            consumer_id=consumer_id,
            repo_id=repo_id,
            distributor_id=distributor_id)
        agent = PulpAgent()
        agent.consumer.unbind(context, bindings, options)

        # unbind action tracking
        manager = managers.consumer_bind_manager()
        manager.action_pending(
            consumer_id,
            repo_id,
            distributor_id,
            Bind.Action.UNBIND,
            task_id)

        return task
示例#9
0
文件: agent.py 项目: omps/pulp
    def uninstall_content(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
        :return: A task ID that may be used to track the agent request.
        :rtype: dict
        """
        # track agent operations using a pseudo task
        task_id = str(uuid4())
        task_tags = [
            tags.resource_tag(tags.RESOURCE_CONSUMER_TYPE, consumer_id),
            tags.action_tag(tags.ACTION_AGENT_UNIT_UNINSTALL)
        ]
        task = TaskStatusManager.create_task_status(task_id, 'agent', tags=task_tags)

        # agent request
        manager = managers.consumer_manager()
        consumer = manager.get_consumer(consumer_id)
        conduit = ProfilerConduit()
        collated = Units(units)
        for typeid, units in collated.items():
            pc = AgentManager._profiled_consumer(consumer_id)
            profiler, cfg = AgentManager._profiler(typeid)
            units = AgentManager._invoke_plugin(
                profiler.uninstall_units,
                pc,
                units,
                options,
                cfg,
                conduit)
            collated[typeid] = units
        units = collated.join()
        context = Context(consumer, task_id=task_id, consumer_id=consumer_id)
        agent = PulpAgent()
        agent.content.uninstall(context, units, options)
        return task
示例#10
0
文件: agent.py 项目: tomlanyon/pulp
 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)
示例#11
0
文件: agent.py 项目: tomlanyon/pulp
 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)