Example #1
0
from sonmanobase.plugin import ManoBasePlugin
from sonmanobase.logger import TangoLogger
import sonmanobase.messaging as messaging

try:
    from son_mano_flm import flm_helpers as tools
except:
    import flm_helpers as tools

try:
    from son_mano_flm import flm_topics as t
except:
    import flm_topics as t

LOG = TangoLogger.getLogger(__name__, log_level=logging.INFO, log_json=True)
TangoLogger.getLogger("son-mano-base:messaging", logging.INFO, log_json=True)
TangoLogger.getLogger("son-mano-base:plugin", logging.INFO, log_json=True)


class FunctionLifecycleManager(ManoBasePlugin):
    """
    This class implements the Function lifecycle manager.
    """
    def __init__(self,
                 auto_register=True,
                 wait_for_registration=True,
                 start_running=True):
        """
        Initialize class and son-mano-base.plugin.BasePlugin class.
        This will automatically connect to the broker, contact the
Example #2
0
# the Horizon 2020 and 5G-PPP programmes. The authors would like to
# acknowledge the contributions of their colleagues of the 5GTANGO
# partner consortium (www.5gtango.eu).

from amqpstorm import UriConnection
from sonmanobase.logger import TangoLogger
import logging
import threading
import concurrent.futures as pool
import uuid
import traceback
import yaml
import time
import os

TangoLogger.getLogger("pika", log_level=logging.ERROR, log_json=True)
LOG = TangoLogger.getLogger("son-mano-base:messaging",
                            log_level=logging.DEBUG,
                            log_json=True)

# if we don't find a broker configuration in our ENV, we use this URL as default
RABBITMQ_URL_FALLBACK = "amqp://*****:*****@localhost:5672/%2F"
# if we don't find a broker configuration in our ENV, we use this exchange as default
RABBITMQ_EXCHANGE_FALLBACK = "son-kernel"


class ManoBrokerConnection(object):
    """
    This class encapsulates a bare RabbitMQ connection setup.
    It provides helper methods to easily publish/subscribe to a given topic.
    It uses the asynchronous adapter implementation of the amqpstorm library.
Example #3
0
# funded by the European Commission under Grant number 761493 through
# the Horizon 2020 and 5G-PPP programmes. The authors would like to
# acknowledge the contributions of their colleagues of the 5GTANGO
# partner consortium (www.5gtango.eu).

from amqpstorm import UriConnection
from sonmanobase.logger import TangoLogger
import logging
import threading
import concurrent.futures as pool
import uuid
import traceback
import time
import os

TangoLogger.getLogger("pika", log_level=logging.ERROR, log_json=True)
LOG = TangoLogger.getLogger("son-mano-base:messaging", log_level=logging.DEBUG, log_json=True)

# if we don't find a broker configuration in our ENV, we use this URL as default
RABBITMQ_URL_FALLBACK = "amqp://*****:*****@localhost:5672/%2F"
# if we don't find a broker configuration in our ENV, we use this exchange as default
RABBITMQ_EXCHANGE_FALLBACK = "son-kernel"


class ManoBrokerConnection(object):
    """
    This class encapsulates a bare RabbitMQ connection setup.
    It provides helper methods to easily publish/subscribe to a given topic.
    It uses the asynchronous adapter implementation of the amqpstorm library.
    """
# This work has been performed in the framework of the 5GTANGO project,
# funded by the European Commission under Grant number 761493 through
# the Horizon 2020 and 5G-PPP programmes. The authors would like to
# acknowledge the contributions of their colleagues of the 5GTANGO
# partner consortium (www.5gtango.eu).
"""
This is the main module of the Placement Executive Plugin.
"""
import logging
import yaml
import os
from sonmanobase.plugin import ManoBasePlugin
from sonmanobase.logger import TangoLogger
from sonmanobase import messaging

LOG = TangoLogger.getLogger(__name__, log_level=logging.INFO, log_json=True)
TangoLogger.getLogger("son-mano-base:messaging", logging.INFO, log_json=True)
TangoLogger.getLogger("son-mano-base:plugin", logging.INFO, log_json=True)


class PlacementExecutive(ManoBasePlugin):

    def __init__(self):

        self.version = 'v0.01'
        self.description = 'Placement Executive Plugin'

        if 'sm_broker_host' in os.environ:
            self.sm_broker_host = os.environ['sm_broker_host']
        else:
            self.ssm_user = '******'
Example #5
0
# acknowledge the contributions of their colleagues of the SONATA
# partner consortium (www.sonata-nfv.eu).
#
# This work has been performed in the framework of the 5GTANGO project,
# funded by the European Commission under Grant number 761493 through
# the Horizon 2020 and 5G-PPP programmes. The authors would like to
# acknowledge the contributions of their colleagues of the 5GTANGO
# partner consortium (www.5gtango.eu).

import logging
import os
from datetime import datetime
from sonmanobase.logger import TangoLogger
from mongoengine import Document, connect, StringField, DateTimeField, BooleanField, signals

LOG = TangoLogger.getLogger("son-mano-pluginmanger:model", log_level=logging.INFO, log_json=True)


class Plugin(Document):
    """
    This model represents a plugin that is registered to the plugin manager.
    We use mongoengine as ORM to interact with MongoDB.
    """
    uuid = StringField(primary_key=True, required=True)
    name = StringField(required=True)
    version = StringField(required=True)
    description = StringField(required=False)
    state = StringField(required=True, max_length=16)
    registered_at = DateTimeField(default=datetime.now())
    last_heartbeat_at = DateTimeField()
    #deregistered = BooleanField(default=False)
Example #6
0
# the Horizon 2020 and 5G-PPP programmes. The authors would like to
# acknowledge the contributions of their colleagues of the 5GTANGO
# partner consortium (www.5gtango.eu).
'''
This is the engine module of SONATA's Specific Manager Registry.
'''

import logging
import os
import docker
import requests
import yaml
from sonmanobase.logger import TangoLogger

LOG = TangoLogger.getLogger("son-mano-specific-manager-registry-engine",
                            log_level=logging.INFO,
                            log_json=True)


class SMREngine(object):
    def __init__(self):
        # connect to docker
        self.dc = self.connect()

        # create rabbitmq user that will be used for communication between FSMs/SSMs and MANO plugins
        if 'broker_man_host' in os.environ:
            self.host = os.environ['broker_man_host']
        else:
            self.host = 'http://localhost:15672'
        url_user = "******".format(self.host)
        self.headers = {'content-type': 'application/json'}
Example #7
0
# This work has been performed in the framework of the 5GTANGO project,
# funded by the European Commission under Grant number 761493 through
# the Horizon 2020 and 5G-PPP programmes. The authors would like to
# acknowledge the contributions of their colleagues of the 5GTANGO
# partner consortium (www.5gtango.eu).

import logging
import json
import time
import os
import threading

from sonmanobase import messaging
from sonmanobase.logger import TangoLogger

LOG = TangoLogger.getLogger("son-mano-base:plugin", log_level=logging.DEBUG, log_json=True)

class ManoBasePlugin(object):
    """
    Abstract class that should be inherited by other MANO plugins.
    This class provides basic mechanisms to
    - connect to the broker
    - send/receive async/sync request/response calls
    - send/receive notifications
    - register / de-register plugin to plugin manager

    It also implements a automatic heartbeat mechanism that periodically sends
    heartbeat notifications.
    """

    def __init__(self,
# acknowledge the contributions of their colleagues of the 5GTANGO
# partner consortium (www.5gtango.eu).

"""
Adds a REST interface to the plugin manager to control plugins registered to the platfoem.
"""
import logging
import threading
import json
from flask import Flask, request
import flask_restful as fr
from mongoengine import DoesNotExist
from son_mano_pluginmanager import model
from sonmanobase.logger import TangoLogger

LOG = TangoLogger.getLogger("son-mano-pluginmanger:interface", log_level=logging.INFO, log_json=True)
TangoLogger.getLogger("werkzeug").setLevel(logging.WARNING)


class PluginsEndpoint(fr.Resource):

    def get(self):
        LOG.debug("GET plugin list")
        return [p.uuid for p in model.Plugin.objects], 200


class PluginEndpoint(fr.Resource):

    def get(self, plugin_uuid=None):
        LOG.debug("GET plugin info for: %r" % plugin_uuid)
        try:
# funded by the European Commission under Grant number 761493 through
# the Horizon 2020 and 5G-PPP programmes. The authors would like to
# acknowledge the contributions of their colleagues of the 5GTANGO
# partner consortium (www.5gtango.eu).
'''
This is the engine module of SONATA's Specific Manager Registry.
'''

import logging
import os
import docker
import requests
import yaml
from sonmanobase.logger import TangoLogger

LOG = TangoLogger.getLogger("son-mano-specific-manager-registry-engine", log_level=logging.INFO, log_json=True)

class SMREngine(object):
    def __init__(self):
        # connect to docker
        self.dc = self.connect()

        # create rabbitmq user that will be used for communication between FSMs/SSMs and MANO plugins
        if 'broker_man_host' in os.environ:
            self.host = os.environ['broker_man_host']
        else:
            self.host = 'http://localhost:15672'
        url_user = "******".format(self.host)
        self.headers = {'content-type': 'application/json'}
        data = '{"password":"******","tags":"son-sm"}'
        response = requests.put(url=url_user, headers=self.headers, data=data, auth=('guest', 'guest'))
Example #10
0
# acknowledge the contributions of their colleagues of the 5GTANGO
# partner consortium (www.5gtango.eu).
"""
Adds a REST interface to the plugin manager to control plugins registered to the platfoem.
"""
import logging
import threading
import json
from flask import Flask, request
import flask_restful as fr
from mongoengine import DoesNotExist
from son_mano_pluginmanager import model
from sonmanobase.logger import TangoLogger

LOG = TangoLogger.getLogger("son-mano-pluginmanger:interface",
                            log_level=logging.INFO,
                            log_json=True)
TangoLogger.getLogger("werkzeug").setLevel(logging.WARNING)


class PluginsEndpoint(fr.Resource):
    def get(self):
        LOG.debug("GET plugin list")
        return [p.uuid for p in model.Plugin.objects], 200


class PluginEndpoint(fr.Resource):
    def get(self, plugin_uuid=None):
        LOG.debug("GET plugin info for: %r" % plugin_uuid)
        try:
            p = model.Plugin.objects.get(uuid=plugin_uuid)
Example #11
0
# funded by the European Commission under Grant number 761493 through
# the Horizon 2020 and 5G-PPP programmes. The authors would like to
# acknowledge the contributions of their colleagues of the 5GTANGO
# partner consortium (www.5gtango.eu).

import logging
import json
import time
import os
import threading

from sonmanobase import messaging
from sonmanobase.logger import TangoLogger

LOG = TangoLogger.getLogger("son-mano-base:plugin",
                            log_level=logging.DEBUG,
                            log_json=True)


class ManoBasePlugin(object):
    """
    Abstract class that should be inherited by other MANO plugins.
    This class provides basic mechanisms to
    - connect to the broker
    - send/receive async/sync request/response calls
    - send/receive notifications
    - register / de-register plugin to plugin manager

    It also implements a automatic heartbeat mechanism that periodically sends
    heartbeat notifications.
    """