示例#1
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)

        msg = _('reporting profiles: %(r)s')
        log.debug(msg, {'r': 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)

            msg = _('profile (%(t)s), reported: %(r)s')
            log.info(msg, {'t': type_id, 'r': http.response_code})

        return report.dict()
示例#2
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)

        msg = _('reporting profiles: %(r)s')
        log.debug(msg, {'r': 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)

            msg = _('profile (%(t)s), reported: %(r)s')
            log.info(msg, {'t': type_id, 'r': http.response_code})

        return report.dict()
示例#3
0
 def unregister(self):
     """
     Notification that the consumer had been unregistered.
     The action is to clean up registration and bind artifacts.
     The consumer bundle is deleted.  Then, all handlers
     are requested to perform a clean().
     """
     bundle = ConsumerX509Bundle()
     bundle.delete()
     conduit = Conduit()
     dispatcher = Dispatcher()
     report = dispatcher.clean(conduit)
     return report.dict()
示例#4
0
 def unregister(self):
     """
     Notification that the consumer had been unregistered.
     The action is to clean up registration and bind artifacts.
     The consumer bundle is deleted.  Then, all handlers
     are requested to perform a clean().
     """
     bundle = ConsumerX509Bundle()
     bundle.delete()
     conduit = Conduit()
     dispatcher = Dispatcher()
     report = dispatcher.clean(conduit)
     return report.dict()
示例#5
0
 def uninstall(self, units, options):
     """
     Uninstall the specified content units using the specified options.
     Delegated to content handlers.
     :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
     :return: A dispatch report.
     :rtype: DispatchReport
     """
     conduit = Conduit()
     dispatcher = Dispatcher()
     report = dispatcher.uninstall(conduit, units, options)
     return report.dict()
示例#6
0
 def uninstall(self, units, options):
     """
     Uninstall the specified content units using the specified options.
     Delegated to content handlers.
     :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
     :return: A dispatch report.
     :rtype: DispatchReport
     """
     conduit = Conduit()
     dispatcher = Dispatcher()
     report = dispatcher.uninstall(conduit, units, options)
     return report.dict()
示例#7
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()
示例#8
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()
示例#9
0
 def test_handler(*unused):
     # publish
     self.populate(constants.ADDITIVE_STRATEGY)
     pulp_conf.set('server', 'storage_dir', self.parentfs)
     dist = NodesHttpDistributor()
     repo = Repository(self.REPO_ID)
     conduit = RepoPublishConduit(self.REPO_ID, constants.HTTP_DISTRIBUTOR)
     dist.publish_repo(repo, conduit, self.dist_conf())
     units = [{'type_id':'node', 'unit_key':None}]
     pulp_conf.set('server', 'storage_dir', self.childfs)
     container = Container(self.parentfs)
     dispatcher = Dispatcher(container)
     container.handlers[CONTENT]['node'] = NodeHandler(self)
     container.handlers[CONTENT]['repository'] = RepositoryHandler(self)
     report = dispatcher.update(Conduit(), units, {})
     _report.append(report)
示例#10
0
 def setUp(self):
     mock_yum.install()
     self.deployer = Deployer()
     dpath, hpath = self.deployer.install()
     self.container = Container(root=dpath, path=[hpath])
     self.dispatcher = Dispatcher(self.container)
     self.__system = os.system
     os.system = Mock()
示例#11
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()
示例#12
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()
示例#13
0
 def test_handler(*unused):
     # publish
     self.populate()
     pulp_conf.set('server', 'storage_dir', self.upfs)
     dist = CitrusHttpDistributor()
     repo = Repository(self.REPO_ID)
     conduit = RepoPublishConduit(self.REPO_ID, CITRUS_DISTRUBUTOR)
     dist.publish_repo(repo, conduit, self.dist_conf())
     options = dict(strategy='additive')
     units = [{'type_id':'node', 'unit_key':None}]
     pulp_conf.set('server', 'storage_dir', self.downfs)
     container = Container(self.upfs)
     dispatcher = Dispatcher(container)
     container.handlers[CONTENT]['node'] = NodeHandler(self)
     container.handlers[CONTENT]['repository'] = RepositoryHandler(self)
     report = dispatcher.update(Conduit(), units, options)
     _report.append(report)
示例#14
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]