Ejemplo n.º 1
0
 def update(self, units, options):
     """
     Update the specified content units using the specified options.
     Delegated to content handlers.
     :param units: A list of content units to be updated.
     :type units: list of:
         { type_id:<str>, unit_key:<dict> }
     :param options: Update options; based on unit type.
     :type options: dict
     :return: A dispatch report.
     :rtype: DispatchReport
     """
     conduit = Conduit()
     dispatcher = Dispatcher()
     report = dispatcher.update(conduit, units, options)
     return report.dict()
Ejemplo n.º 2
0
 def unbind(self, bindings, options):
     """
     Unbind to the specified repository ID.
     Delegated to content handlers.
     :param bindings: A list of bindings to be removed.
       Each binding is: {type_id:<str>, repo_id:<str>}
     :type bindings: list
     :param options: Unbind options.
     :type options: dict
     :return: A dispatch report.
     :rtype: DispatchReport
     """
     conduit = Conduit()
     dispatcher = Dispatcher()
     report = dispatcher.unbind(conduit, bindings, options)
     return report.dict()
Ejemplo n.º 3
0
 def bind(self, bindings, options):
     """
     Bind to the specified repository ID.
     Delegated to content handlers.
     :param bindings: A list of bindings to add/update.
       Each binding is: {type_id:<str>, repo_id:<str>, details:<dict>}
         The 'details' are at the discretion of the distributor.
     :type bindings: list
     :param options: Bind options.
     :type options: dict
     :return: A dispatch report.
     :rtype: DispatchReport
     """
     conduit = Conduit()
     dispatcher = Dispatcher()
     report = dispatcher.bind(conduit, bindings, options)
     return report.dict()
Ejemplo n.º 4
0
 def send(self):
     """
     Send the content profile(s) to the server.
     Delegated to the handlers.
     :return: A dispatch report.
     :rtype: DispatchReport
     """
     bundle = ConsumerX509Bundle()
     consumer_id = bundle.cn()
     conduit = Conduit()
     bindings = PulpBindings()
     dispatcher = Dispatcher()
     report = dispatcher.profile(conduit)
     log.debug('reporting profiles: %s', report)
     for type_id, profile_report in report.details.items():
         if not profile_report['succeeded']:
             continue
         details = profile_report['details']
         http = bindings.profile.send(consumer_id, type_id, details)
         log.info('profile (%s), reported: %d', type_id, http.response_code)
     return report.dict()
Ejemplo n.º 5
0
from gofer.agent.plugin import Plugin
from gofer.messaging import Topic
from gofer.messaging.producer import Producer
from gofer.pmon import PathMonitor
from gofer.agent.rmi import Context

from pulp.common.bundle import Bundle
from pulp.common.config import Config
from pulp.agent.lib.dispatcher import Dispatcher
from pulp.agent.lib.conduit import Conduit as HandlerConduit
from pulp.bindings.server import PulpConnection
from pulp.bindings.bindings import Bindings

log = getLogger(__name__)
plugin = Plugin.find(__name__)
dispatcher = Dispatcher()
cfg = plugin.cfg()


# --- utils ------------------------------------------------------------------


def secret():
    """
    Get the shared secret used for auth of RMI requests.
    :return: The sha256 for the certificate
    :rtype: str
    """
    bundle = ConsumerX509Bundle()
    content = bundle.read()
    crt = bundle.split(content)[1]