Esempio n. 1
0
import os, sys, logging, json, argparse
from configparser import ConfigParser
import requests
from adapters import adapter as adapter
from adapters.serviceplatform import ServicePlatform
from models import utils
from models import users
import psycopg2
#from validator_collection import validators, checkers
import validators

from logger import TangoLogger as TangoLogger

app = Flask(__name__)

LOG = TangoLogger.getLogger(__name__, log_level=logging.DEBUG, log_json=True)
TangoLogger.getLogger("your_module:main", logging.DEBUG, log_json=True)
LOG.setLevel(logging.DEBUG)
#LOG.info("Hello world.")


##### SERVICE PLATFORMS ROUTES #####
@app.route('/service_platforms/count', methods=['GET'])
def countSPs():
    sp = ServicePlatform()
    return sp.countServicePlatforms()


@app.route('/service_platforms',
           methods=['GET', 'POST', 'OPTIONS', 'DELETE', 'PATCH'])
def sps():
Esempio n. 2
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 flask import Flask, request, jsonify
import logging, json, datetime


import translator.nsi_translator as nsi_translator
import interfaces.validate_incoming_json as json_validator
from logger import TangoLogger

#Log definition to make the slice logs idetified among the other possible 5GTango components.
LOG = TangoLogger.getLogger(__name__, log_level=logging.DEBUG, log_json=True)
TangoLogger.getLogger("sonataAdapter:nbi", logging.DEBUG, log_json=True)
LOG.setLevel(logging.DEBUG)

app = Flask(__name__)

#Variables with the API path sections
API_ROOT="/api"
API_VERSION="/v1"
API_NS="/ns"

############################################# NETWORK SLICE PING ############################################
# PING function to validate if the onata-adaptor-docker is active
@app.route('/pings', methods=['GET'])
def getPings():
  ping_response  = {'alive_since': '2018-07-18 10:00:00 UTC', 'current_time': str(datetime.datetime.now().isoformat())}
Esempio n. 3
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).
# encoding: utf-8

import logging, logging.handlers, sys, yaml, os.path, httplib2
from flask import json, request, Flask, url_for, jsonify
from functools import wraps
from ruleFile import fileBuilder
from logger import TangoLogger as TangoLogger

app = Flask(__name__)
global logger
global promPath
promPath = '/opt/Monitoring/prometheus/'
logger = TangoLogger.getLogger(__name__, log_level=logging.INFO, log_json=True)
TangoLogger.getLogger("Prometheus Plugin", logging.INFO, log_json=True)
logger.setLevel(logging.INFO)


@app.route("/")
def hello():

    urls = "I am alive..."
    logger.info(urls)
    return urls


'''
{"service":"NF777777","rules":[{"description": "Rule_#1", "summary": "Rule combines two metrics", "duration": "4m", "notification_type": 2, "condition": "metric1 - metric2 > 0.25", "name": "Rule 1", "labels":["id = docker","mode = user"]},{"description": "Rule_#2", "summary": "Rule combines two other metrics", "duration": "4m", "notification_type": 2, "condition": "metric3 - metric4 > 0.25", "name": "Rule 2", "labels":["id = docker","mode = user1"]}]}
'''
Esempio n. 4
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 os, sys, requests, json, logging, uuid, time
import database.database as db
import objects.nsd as nsd
from logger import TangoLogger

JSON_CONTENT_HEADER = {'Content-Type':'application/json'}

#Log definition to make the slice logs idetified among the other possible 5GTango components.
LOG = TangoLogger.getLogger(__name__, log_level=logging.DEBUG, log_json=True)
TangoLogger.getLogger("slicemngr:mapper", logging.DEBUG, log_json=True)
LOG.setLevel(logging.DEBUG)


######################################### URLs PREPARATION #########################################
# Returns the last URL version to send reqauests to the Catalogues Docker
def get_url_catalogues():
  ip_address = os.environ.get("SONATA_CAT")
  port = os.environ.get("SONATA_CAT_PORT")
  base_url = 'http://'+ip_address+':'+port
  return base_url
    
# Prepares the URL_requests to manage Network Services instantiations belonging to the NST/NSI
def get_url_sp_gtk():
  ip_address = os.environ.get("SONATA_GTK_SP")
Esempio n. 5
0
## 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).
# encoding: utf-8

from flask import Flask, json, request
from rabbitMQ import amqp
from logger import TangoLogger as TangoLogger
import os, logging, datetime

app = Flask(__name__)
LOG = TangoLogger.getLogger(__name__, log_level=logging.INFO, log_json=True)
TangoLogger.getLogger("Alert_manager", logging.INFO, log_json=True)
LOG.setLevel(logging.INFO)
LOG.info('Alert manager to RMQ started ')

@app.before_first_request
def _declareStuff():
    global host
    global port
    global debug

    try:
        if 'RABBIT_URL' in os.environ:
            rabbit = str(os.environ['RABBIT_URL']).strip()
            global host
            global port
## 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 json, datetime, logging, time
from uuid import UUID
from logger import TangoLogger

# Global variables
returnData = {}

#Log definition to make the slice logs idetified among the other possible 5GTango components.
LOG = TangoLogger.getLogger(__name__, log_level=logging.DEBUG, log_json=True)
TangoLogger.getLogger("slicemngr:json_validator", logging.DEBUG, log_json=True)
LOG.setLevel(logging.DEBUG)


# Checks if the uuid has the right format (uuidv4)
def is_valid_uuid(uuid_to_test, version=4):
    try:
        uuid_obj = UUID(uuid_to_test, version=version)
    except:
        return False
    return str(uuid_obj) == uuid_to_test


# Validates the incoming json to start a Network Slice Instantiation process.
def validate_create_instantiation(jsonData):
Esempio n. 7
0
        sh.timer.start()
        workers[str(str(ent.id) + ':' + e.ip + ':' + e.port)] = sh
        h.updateEntStatus(host_=e.ip,port_=e.port,status_='ACTIVE')
        logger.info('SNMP ENTITY UPDATED '+ str(e.ip + ':' + e.port))

    for ent in dl_ents:
        lb = str(str(ent.id) + ":"+ ent.ip + ':' + ent.port)
        h.deleteEntity(id_=ent.id, host_=ent.ip, port_=ent.port)
        if lb in workers:
            workers[lb].stopThread()
            del workers[lb]
    h.session.close()


if __name__ == '__main__':
    logger = TangoLogger.getLogger(__name__, log_level=logging.INFO, log_json=True)
    TangoLogger.getLogger("SNMP_Manager", logging.INFO, log_json=True)
    logger.setLevel(logging.INFO)

    #logger = logging.getLogger('SNMP_Manager')
    #hdlr = RotatingFileHandler('snmp_manager.log', maxBytes=1000000, backupCount=1)
    #formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
    #hdlr.setFormatter(formatter)
    #logger.addHandler(hdlr)
    #logger.setLevel(logging.WARNING)
    #logger.setLevel(logging.INFO)
    init(logger)

    logger.info('SNMP Manager started!!')
    logger.info('Promth P/W Server ' + json.dumps(prometh_server))
#!/usr/bin/python

import psycopg2
import requests

from flask import Flask, request, jsonify, render_template
import os, sys, logging, json, argparse
from configparser import ConfigParser
from logger import TangoLogger

LOG = TangoLogger.getLogger("adapter", log_level=logging.DEBUG, log_json=True)

LOG.setLevel(logging.DEBUG)


class ServicePlatform:
    def __init__(self,
                 name=None,
                 host=None,
                 type=None,
                 username=None,
                 password=None,
                 project_name=None,
                 vim_account=None,
                 service_token=None,
                 monitoring_urls=None):
        self.name = name
        self.host = host
        self.type = type
        self.username = username
        self.password = password
Esempio n. 9
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 os, sys, requests, json, logging, time
from flask import jsonify

import database.database as db
from logger import TangoLogger

JSON_CONTENT_HEADER = {'Content-Type':'application/json'}

#Log definition to make the slice logs idetified among the other possible 5GTango components.
LOG = TangoLogger.getLogger(__name__, log_level=logging.DEBUG, log_json=True)
TangoLogger.getLogger("slicemngr:nsi_manager2repo", logging.DEBUG, log_json=True)
LOG.setLevel(logging.DEBUG)

# Returns the last URL version to send reqauests to the Repositories Docker
def get_url_repositories():
    ip_address = os.environ.get("SONATA_REP")
    port = os.environ.get("SONATA_REP_PORT")
    base_url = 'http://'+ip_address+':'+port
    return base_url

# POST to send the NSI information to the repositories
def safe_nsi(NSI_dict):
    url = get_url_repositories() + '/records/nsir/ns-instances'
    data = json.dumps(NSI_dict)
    response = requests.post(url, data, headers=JSON_CONTENT_HEADER)