예제 #1
0
    def transport_mqttrpc(self):
        """
        Installs the MQTT-RPC transport bundles and instantiates components
        """
        # Install the bundle
        self.context.install_bundle("pelix.remote.transport.mqtt_rpc").start()

        with use_waiting_list(self.context) as ipopo:
            # Instantiate the discovery
            ipopo.add(
                rs.FACTORY_TRANSPORT_MQTTRPC_EXPORTER,
                "pelix-mqttrpc-exporter",
                {
                    "mqtt.host": self.arguments.mqtt_host,
                    "mqtt.port": self.arguments.mqtt_port,
                },
            )
            ipopo.add(
                rs.FACTORY_TRANSPORT_MQTTRPC_IMPORTER,
                "pelix-mqttrpc-importer",
                {
                    "mqtt.host": self.arguments.mqtt_host,
                    "mqtt.port": self.arguments.mqtt_port,
                },
            )
예제 #2
0
    def transport_mqttrpc(self):
        """
        Installs the MQTT-RPC transport bundles and instantiates components
        """
        # Install the bundle
        self.context.install_bundle("pelix.remote.transport.mqtt_rpc").start()

        with use_waiting_list(self.context) as ipopo:
            # Instantiate the discovery
            ipopo.add(
                rs.FACTORY_TRANSPORT_MQTTRPC_EXPORTER,
                "pelix-mqttrpc-exporter",
                {
                    "mqtt.host": self.arguments.mqtt_host,
                    "mqtt.port": self.arguments.mqtt_port,
                },
            )
            ipopo.add(
                rs.FACTORY_TRANSPORT_MQTTRPC_IMPORTER,
                "pelix-mqttrpc-importer",
                {
                    "mqtt.host": self.arguments.mqtt_host,
                    "mqtt.port": self.arguments.mqtt_port,
                },
            )
예제 #3
0
def main(http_port, peer_name, node_name, app_id):
    """
    Runs the framework

    :param http_port: HTTP port to listen to
    :param peer_name: Name of the peer
    :param node_name: Name (also, UID) of the node hosting the peer
    :param app_id: Application ID
    """
    # Create the framework
    framework = pelix.framework.create_framework(
        ('pelix.ipopo.core',
         'pelix.ipopo.waiting',
         'pelix.shell.core',
         'pelix.shell.ipopo',
         'pelix.shell.console',
         'pelix.http.basic',

         # Herald core
         'herald.core',
         'herald.directory',
         'herald.shell',

         # Herald HTTP
         'herald.transports.http.directory',
         'herald.transports.http.discovery_multicast',
         'herald.transports.http.servlet',
         'herald.transports.http.transport',

         # RPC
         'pelix.remote.dispatcher',
         'pelix.remote.registry',
         'herald.remote.discovery',
         'herald.remote.herald_xmlrpc',),
        {herald.FWPROP_NODE_UID: node_name,
         herald.FWPROP_NODE_NAME: node_name,
         herald.FWPROP_PEER_NAME: peer_name,
         herald.FWPROP_APPLICATION_ID: app_id})

    # Start everything
    framework.start()
    context = framework.get_bundle_context()

    # Instantiate components
    with use_waiting_list(context) as ipopo:
        # ... HTTP server
        ipopo.add(pelix.http.FACTORY_HTTP_BASIC, "http-server",
                  {pelix.http.HTTP_SERVICE_PORT: http_port})

        # ... HTTP reception servlet
        ipopo.add(herald.transports.http.FACTORY_SERVLET,
                  "herald-http-servlet")

        # ... HTTP multicast discovery
        ipopo.add(herald.transports.http.FACTORY_DISCOVERY_MULTICAST,
                  "herald-http-discovery-multicast")

    # Start the framework and wait for it to stop
    framework.wait_for_stop()
예제 #4
0
def main(xmpp_server, xmpp_port, peer_name, node_name, app_id,
         xmpp_jid=None, xmpp_password=None):
    """
    Runs the framework

    :param xmpp_server: Address of the XMPP server
    :param xmpp_port: Port of the XMPP server
    :param peer_name: Name of the peer
    :param node_name: Name (also, UID) of the node hosting the peer
    :param app_id: Application ID
    :param xmpp_jid: XMPP JID, None for Anonymous login
    :param xmpp_password: XMPP account password
    """
    # Create the framework
    framework = pelix.framework.create_framework(
        ('pelix.ipopo.core',
         'pelix.ipopo.waiting',
         'pelix.shell.core',
         'pelix.shell.ipopo',
         'pelix.shell.console',

         # Herald core
         'herald.core',
         'herald.directory',
         'herald.shell',

         # Herald XMPP
         'herald.transports.xmpp.directory',
         'herald.transports.xmpp.transport',

         # RPC
         'pelix.remote.dispatcher',
         'pelix.remote.registry',
         'herald.remote.discovery',
         'herald.remote.herald_xmlrpc',),
        {herald.FWPROP_NODE_UID: node_name,
         herald.FWPROP_NODE_NAME: node_name,
         herald.FWPROP_PEER_NAME: peer_name,
         herald.FWPROP_APPLICATION_ID: app_id})
    context = framework.get_bundle_context()

    # Start everything
    framework.start()

    # Instantiate components
    with use_waiting_list(context) as ipopo:
        # ... XMPP Transport
        ipopo.add(herald.transports.xmpp.FACTORY_TRANSPORT,
                  "herald-xmpp-transport",
                  {herald.transports.xmpp.PROP_XMPP_SERVER: xmpp_server,
                   herald.transports.xmpp.PROP_XMPP_PORT: xmpp_port,
                   herald.transports.xmpp.PROP_XMPP_JID: xmpp_jid,
                   herald.transports.xmpp.PROP_XMPP_PASSWORD: xmpp_password})

    # Start the framework and wait for it to stop
    framework.wait_for_stop()
예제 #5
0
def main(xmpp_server, xmpp_port, peer_name, node_name, app_id,
         xmpp_jid=None, xmpp_password=None):
    """
    Runs the framework

    :param xmpp_server: Address of the XMPP server
    :param xmpp_port: Port of the XMPP server
    :param peer_name: Name of the peer
    :param node_name: Name (also, UID) of the node hosting the peer
    :param app_id: Application ID
    :param xmpp_jid: XMPP JID, None for Anonymous login
    :param xmpp_password: XMPP account password
    """
    # Create the framework
    framework = pelix.framework.create_framework(
        ('pelix.ipopo.core',
         'pelix.ipopo.waiting',
         'pelix.shell.core',
         'pelix.shell.ipopo',
         'pelix.shell.console',

         # Herald core
         'herald.core',
         'herald.directory',
         'herald.shell',

         # Herald XMPP
         'herald.transports.xmpp.directory',
         'herald.transports.xmpp.transport',

         # RPC
         'pelix.remote.dispatcher',
         'pelix.remote.registry',
         'herald.remote.discovery',
         'herald.remote.herald_xmlrpc',),
        {herald.FWPROP_NODE_UID: node_name,
         herald.FWPROP_NODE_NAME: node_name,
         herald.FWPROP_PEER_NAME: peer_name,
         herald.FWPROP_APPLICATION_ID: app_id})
    context = framework.get_bundle_context()

    # Start everything
    framework.start()

    # Instantiate components
    with use_waiting_list(context) as ipopo:
        # ... XMPP Transport
        ipopo.add(herald.transports.xmpp.FACTORY_TRANSPORT,
                  "herald-xmpp-transport",
                  {herald.transports.xmpp.PROP_XMPP_SERVER: xmpp_server,
                   herald.transports.xmpp.PROP_XMPP_PORT: xmpp_port,
                   herald.transports.xmpp.PROP_XMPP_JID: xmpp_jid,
                   herald.transports.xmpp.PROP_XMPP_PASSWORD: xmpp_password})

    # Start the framework and wait for it to stop
    framework.wait_for_stop()
예제 #6
0
    def discovery_multicast(self):
        """
        Installs the multicast discovery bundles and instantiates components
        """
        # Install the bundle
        self.context.install_bundle('pelix.remote.discovery.multicast').start()

        with use_waiting_list(self.context) as ipopo:
            # Instantiate the discovery
            ipopo.add(rs.FACTORY_DISCOVERY_MULTICAST,
                      "pelix-discovery-multicast")
예제 #7
0
    def discovery_multicast(self):
        """
        Installs the multicast discovery bundles and instantiates components
        """
        # Install the bundle
        self.context.install_bundle('pelix.remote.discovery.multicast').start()

        with use_waiting_list(self.context) as ipopo:
            # Instantiate the discovery
            ipopo.add(rs.FACTORY_DISCOVERY_MULTICAST,
                      "pelix-discovery-multicast")
예제 #8
0
    def discovery_mdns(self):
        """
        Installs the mDNS discovery bundles and instantiates components
        """
        # Remove Zeroconf debug output
        logging.getLogger("zeroconf").setLevel(logging.WARNING)

        # Install the bundle
        self.context.install_bundle("pelix.remote.discovery.mdns").start()

        with use_waiting_list(self.context) as ipopo:
            # Instantiate the discovery
            ipopo.add(rs.FACTORY_DISCOVERY_ZEROCONF, "pelix-discovery-zeroconf")
예제 #9
0
    def transport_xmlrpc(self):
        """
        Installs the XML-RPC transport bundles and instantiates components
        """
        # Install the bundle
        self.context.install_bundle('pelix.remote.xml_rpc').start()

        with use_waiting_list(self.context) as ipopo:
            # Instantiate the discovery
            ipopo.add(rs.FACTORY_TRANSPORT_XMLRPC_EXPORTER,
                      "pelix-xmlrpc-exporter")
            ipopo.add(rs.FACTORY_TRANSPORT_XMLRPC_IMPORTER,
                      "pelix-xmlrpc-importer")
예제 #10
0
    def discovery_mqtt(self):
        """
        Installs the MQTT discovery bundles and instantiates components
        """
        # Install the bundle
        self.context.install_bundle('pelix.remote.discovery.mqtt').start()

        with use_waiting_list(self.context) as ipopo:
            # Instantiate the discovery
            ipopo.add(rs.FACTORY_DISCOVERY_MQTT, "pelix-discovery-mqtt",
                      {"application.id": "sample.rs",
                       "mqtt.host": self.arguments.mqtt_host,
                       "mqtt.port": self.arguments.mqtt_port})
예제 #11
0
    def transport_jsonrpc(self):
        """
        Installs the JSON-RPC transport bundles and instantiates components
        """
        # Install the bundle
        self.context.install_bundle("pelix.remote.json_rpc").start()

        with use_waiting_list(self.context) as ipopo:
            # Instantiate the discovery
            ipopo.add(rs.FACTORY_TRANSPORT_JSONRPC_EXPORTER,
                      "pelix-jsonrpc-exporter")
            ipopo.add(rs.FACTORY_TRANSPORT_JSONRPC_IMPORTER,
                      "pelix-jsonrpc-importer")
예제 #12
0
    def transport_xmlrpc(self):
        """
        Installs the XML-RPC transport bundles and instantiates components
        """
        # Install the bundle
        self.context.install_bundle('pelix.remote.xml_rpc').start()

        with use_waiting_list(self.context) as ipopo:
            # Instantiate the discovery
            ipopo.add(rs.FACTORY_TRANSPORT_XMLRPC_EXPORTER,
                      "pelix-xmlrpc-exporter")
            ipopo.add(rs.FACTORY_TRANSPORT_XMLRPC_IMPORTER,
                      "pelix-xmlrpc-importer")
예제 #13
0
    def transport_jabsorbrpc(self):
        """
        Installs the JABSORB-RPC transport bundles and instantiates components
        """
        # Install the bundle
        self.context.install_bundle('pelix.remote.transport.jabsorb_rpc') \
            .start()

        with use_waiting_list(self.context) as ipopo:
            # Instantiate the discovery
            ipopo.add(rs.FACTORY_TRANSPORT_JABSORBRPC_EXPORTER,
                      "pelix-jabsorbrpc-exporter")
            ipopo.add(rs.FACTORY_TRANSPORT_JABSORBRPC_IMPORTER,
                      "pelix-jabsorbrpc-importer")
예제 #14
0
    def discovery_mdns(self):
        """
        Installs the mDNS discovery bundles and instantiates components
        """
        # Remove Zeroconf debug output
        logging.getLogger("zeroconf").setLevel(logging.WARNING)

        # Install the bundle
        self.context.install_bundle('pelix.remote.discovery.mdns').start()

        with use_waiting_list(self.context) as ipopo:
            # Instantiate the discovery
            ipopo.add(rs.FACTORY_DISCOVERY_ZEROCONF,
                      "pelix-discovery-zeroconf")
예제 #15
0
    def transport_jabsorbrpc(self):
        """
        Installs the JABSORB-RPC transport bundles and instantiates components
        """
        # Install the bundle
        self.context.install_bundle('pelix.remote.transport.jabsorb_rpc') \
            .start()

        with use_waiting_list(self.context) as ipopo:
            # Instantiate the discovery
            ipopo.add(rs.FACTORY_TRANSPORT_JABSORBRPC_EXPORTER,
                      "pelix-jabsorbrpc-exporter")
            ipopo.add(rs.FACTORY_TRANSPORT_JABSORBRPC_IMPORTER,
                      "pelix-jabsorbrpc-importer")
예제 #16
0
    def discovery_mqtt(self):
        """
        Installs the MQTT discovery bundles and instantiates components
        """
        # Install the bundle
        self.context.install_bundle('pelix.remote.discovery.mqtt').start()

        with use_waiting_list(self.context) as ipopo:
            # Instantiate the discovery
            ipopo.add(
                rs.FACTORY_DISCOVERY_MQTT, "pelix-discovery-mqtt", {
                    "application.id": "sample.rs",
                    "mqtt.host": self.arguments.mqtt_host,
                    "mqtt.port": self.arguments.mqtt_port
                })
예제 #17
0
    def discovery_zookeeper(self):
        """
        Installs the ZooKeeper discovery bundles and instantiates components
        """
        # Install the bundle
        self.context.install_bundle('pelix.remote.discovery.zookeeper').start()

        with use_waiting_list(self.context) as ipopo:
            # Instantiate the discovery
            ipopo.add(
                rs.FACTORY_DISCOVERY_ZOOKEEPER, "pelix-discovery-zookeeper", {
                    "application.id": "sample.rs",
                    "zookeeper.hosts": self.arguments.zk_hosts,
                    "zookeeper.prefix": self.arguments.zk_prefix
                })
예제 #18
0
    def discovery_redis(self):
        """
        Installs the Redis discovery bundles and instantiates components
        """
        # Install the bundle
        self.context.install_bundle('pelix.remote.discovery.redis').start()

        with use_waiting_list(self.context) as ipopo:
            # Instantiate the discovery
            ipopo.add(
                rs.FACTORY_DISCOVERY_REDIS, "pelix-discovery-redis", {
                    "application.id": "sample.rs",
                    "redis.host": self.arguments.redis_host,
                    "redis.port": self.arguments.redis_port
                })
예제 #19
0
    def transport_jsonrpc(self):
        """
        Installs the JSON-RPC transport bundles and instantiates components
        """
        # Install the bundle
        self.context.install_bundle("pelix.remote.json_rpc").start()

        with use_waiting_list(self.context) as ipopo:
            # Instantiate the discovery
            ipopo.add(
                rs.FACTORY_TRANSPORT_JSONRPC_EXPORTER, "pelix-jsonrpc-exporter"
            )
            ipopo.add(
                rs.FACTORY_TRANSPORT_JSONRPC_IMPORTER, "pelix-jsonrpc-importer"
            )
예제 #20
0
    def discovery_redis(self):
        """
        Installs the Redis discovery bundles and instantiates components
        """
        # Install the bundle
        self.context.install_bundle("pelix.remote.discovery.redis").start()

        with use_waiting_list(self.context) as ipopo:
            # Instantiate the discovery
            ipopo.add(
                rs.FACTORY_DISCOVERY_REDIS,
                "pelix-discovery-redis",
                {
                    "application.id": "sample.rs",
                    "redis.host": self.arguments.redis_host,
                    "redis.port": self.arguments.redis_port,
                },
            )
예제 #21
0
    def discovery_zookeeper(self):
        """
        Installs the ZooKeeper discovery bundles and instantiates components
        """
        # Install the bundle
        self.context.install_bundle("pelix.remote.discovery.zookeeper").start()

        with use_waiting_list(self.context) as ipopo:
            # Instantiate the discovery
            ipopo.add(
                rs.FACTORY_DISCOVERY_ZOOKEEPER,
                "pelix-discovery-zookeeper",
                {
                    "application.id": "sample.rs",
                    "zookeeper.hosts": self.arguments.zk_hosts,
                    "zookeeper.prefix": self.arguments.zk_prefix,
                },
            )
예제 #22
0
def main(http_port, peer_name, node_name, app_id):
    """
    Runs the framework

    :param http_port: HTTP port to listen to
    :param peer_name: Name of the peer
    :param node_name: Name (also, UID) of the node hosting the peer
    :param app_id: Application ID
    """
    # Create the framework
    framework = pelix.framework.create_framework(
        (
            'pelix.ipopo.core',
            'pelix.ipopo.waiting',
            'pelix.shell.core',
            'pelix.shell.ipopo',
            'pelix.shell.console',
            'pelix.http.basic',

            # Herald core
            'herald.core',
            'herald.directory',
            'herald.shell',

            # Herald HTTP
            'herald.transports.http.directory',
            'herald.transports.http.discovery_multicast',
            'herald.transports.http.servlet',
            'herald.transports.http.transport',

            # RPC
            'pelix.remote.dispatcher',
            'pelix.remote.registry',
            'herald.remote.discovery',
            'herald.remote.herald_xmlrpc',
        ),
        {
            herald.FWPROP_NODE_UID: node_name,
            herald.FWPROP_NODE_NAME: node_name,
            herald.FWPROP_PEER_NAME: peer_name,
            herald.FWPROP_APPLICATION_ID: app_id
        })

    # Start everything
    framework.start()
    context = framework.get_bundle_context()

    # Instantiate components
    with use_waiting_list(context) as ipopo:
        # ... HTTP server
        ipopo.add(pelix.http.FACTORY_HTTP_BASIC, "http-server",
                  {pelix.http.HTTP_SERVICE_PORT: http_port})

        # ... HTTP reception servlet
        ipopo.add(herald.transports.http.FACTORY_SERVLET,
                  "herald-http-servlet")

        # ... HTTP multicast discovery
        ipopo.add(herald.transports.http.FACTORY_DISCOVERY_MULTICAST,
                  "herald-http-discovery-multicast")

    # Start the framework and wait for it to stop
    framework.wait_for_stop()
예제 #23
0
def main(is_server, discoveries, transports, http_port, other_arguments):
    """
    Runs the framework

    :param is_server: If True, starts the provider bundle,
                      else the consumer one
    :param discoveries: List of discovery protocols
    :param transports: List of RPC protocols
    :param http_port: Port of the HTTP server
    :param other_arguments: Other arguments
    """
    # Create the framework
    framework = pelix.framework.create_framework(
        (
            'pelix.ipopo.core',
            'pelix.ipopo.waiting',
            # Shell
            'pelix.shell.core',
            'pelix.shell.ipopo',
            'pelix.shell.console',
            # HTTP Service
            "pelix.http.basic",
            # Remote Services (core)
            'pelix.remote.dispatcher',
            'pelix.remote.registry'),
        # Framework properties
        {pelix.constants.FRAMEWORK_UID: other_arguments.fw_uid})

    # Start everything
    framework.start()
    context = framework.get_bundle_context()

    # Instantiate components
    # Get the iPOPO service
    with use_waiting_list(context) as ipopo:
        # Instantiate remote service components
        # ... HTTP server
        ipopo.add("pelix.http.service.basic.factory", "http-server",
                  {"pelix.http.port": http_port})

        # ... servlet giving access to the registry
        ipopo.add(rs.FACTORY_REGISTRY_SERVLET,
                  "pelix-remote-dispatcher-servlet")

    # Prepare the utility object
    util = InstallUtils(context, other_arguments)

    # Install the discovery bundles
    for discovery in discoveries:
        getattr(util, "discovery_{0}".format(discovery))()

    # Install the transport bundles
    for transport in transports:
        getattr(util, "transport_{0}".format(transport))()

    # Start the service provider or consumer
    if is_server:
        # ... the provider
        context.install_bundle("remote.provider").start()

    else:
        # ... or the consumer
        context.install_bundle("remote.consumer").start()

    # Start the framework and wait for it to stop
    framework.wait_for_stop()
예제 #24
0
def main(is_server, discoveries, transports, http_port, other_arguments):
    """
    Runs the framework

    :param is_server: If True, starts the provider bundle,
                      else the consumer one
    :param discoveries: List of discovery protocols
    :param transports: List of RPC protocols
    :param http_port: Port of the HTTP server
    :param other_arguments: Other arguments
    """
    # Create the framework
    framework = pelix.framework.create_framework(
        ('pelix.ipopo.core',
         'pelix.ipopo.waiting',
         # Shell
         'pelix.shell.core',
         'pelix.shell.ipopo',
         'pelix.shell.console',
         # HTTP Service
         "pelix.http.basic",
         # Remote Services (core)
         'pelix.remote.dispatcher',
         'pelix.remote.registry'),
        # Framework properties
        {pelix.constants.FRAMEWORK_UID: other_arguments.fw_uid})

    # Start everything
    framework.start()
    context = framework.get_bundle_context()

    # Instantiate components
    # Get the iPOPO service
    with use_waiting_list(context) as ipopo:
        # Instantiate remote service components
        # ... HTTP server
        ipopo.add("pelix.http.service.basic.factory", "http-server",
                  {"pelix.http.address": "0.0.0.0",
                   "pelix.http.port": http_port})

        # ... servlet giving access to the registry
        ipopo.add(rs.FACTORY_REGISTRY_SERVLET,
                  "pelix-remote-dispatcher-servlet")

    # Prepare the utility object
    util = InstallUtils(context, other_arguments)

    # Install the discovery bundles
    for discovery in discoveries:
        getattr(util, "discovery_{0}".format(discovery))()

    # Install the transport bundles
    for transport in transports:
        getattr(util, "transport_{0}".format(transport))()

    # Start the service provider or consumer
    if is_server:
        # ... the provider
        context.install_bundle("remote.provider").start()

    else:
        # ... or the consumer
        context.install_bundle("remote.consumer").start()

    # Start the framework and wait for it to stop
    framework.wait_for_stop()