예제 #1
0
def nfp_module_init(sc, conf):
    """Initializes configurator module.

    Creates de-multiplexer object and invokes all the agent entry point
    functions. Initializes oslo RPC client for receiving messages from
    REST server. Exceptions are raised to parent function for all types
    of failures.

    :param sc: Service Controller object that is used for interfacing
    with core service controller.
    :param conf: Configuration object that is used for configuration
    parameter access.

    Returns: None
    Raises: Generic exception including error message

    """

    # Create configurator module and de-multiplexer objects
    try:
        cm = get_configurator_module_instance(sc)
        demuxer_instance = demuxer.ServiceAgentDemuxer()
    except Exception as err:
        msg = ("Failed to initialize configurator de-multiplexer. %s." %
               (str(err).capitalize()))
        LOG.error(msg)
        raise Exception(err)
    else:
        msg = ("Initialized configurator de-multiplexer.")
        LOG.info(msg)

    # Initialize all the pre-loaded service agents
    try:
        conf.register_opts(config_opts.opts)
        cm.init_service_agents(sc, conf)
    except Exception as err:
        msg = ("Failed to initialize configurator agent modules. %s." %
               (str(err).capitalize()))
        LOG.error(msg)
        raise Exception(err)
    else:
        msg = ("Initialized configurator agents.")
        LOG.info(msg)

    # Initialize RPC client for receiving messages from REST server
    try:
        init_rpc(sc, cm, conf, demuxer_instance)
    except Exception as err:
        msg = ("Failed to initialize configurator RPC with topic %s. %s." %
               (const.CONFIGURATOR_RPC_TOPIC, str(err).capitalize()))
        LOG.error(msg)
        raise Exception(err)
    else:
        msg = ("Initialized configurator RPC with topic %s." %
               const.CONFIGURATOR_RPC_TOPIC)
        LOG.debug(msg)
예제 #2
0
    def _get_ConfiguratorRpcManager_object(self, sc, conf):
        """ Retrieves RPC manager object of configurator.

        :param sc: mocked service controller object of process model framework
        :param conf: mocked OSLO configuration file

        Returns: object of configurator's RPC manager.

        """

        cm = cfgr.ConfiguratorModule(sc)
        demuxer = demuxer_lib.ServiceAgentDemuxer()
        rpc_mgr = cfgr.ConfiguratorRpcManager(sc, cm, conf, demuxer)
        return sc, rpc_mgr
예제 #3
0
    def _get_configurator_rpc_manager_object(self, sc, conf):
        """ Retrieves RPC manager object of configurator.

        :param sc: mocked service controller object of process model framework
        :param conf: mocked OSLO configuration file

        Returns: object of RPC manager of configurator, and mock object of
                 service controller and oslo configurator.

        """

        cm = configurator.ConfiguratorModule(sc)
        dmx = demuxer.ServiceAgentDemuxer()
        rpc_mgr = configurator.ConfiguratorRpcManager(sc, cm, conf, dmx)
        return sc, conf, rpc_mgr
예제 #4
0
 def __init__(self, *args, **kwargs):
     super(ServiceAgentDemuxerTestCase, self).__init__(*args, **kwargs)
     self.fo = fo.FakeObjects()
     self.demuxer = demuxer.ServiceAgentDemuxer()
     self.maxDiff = None