예제 #1
0
def stop_ns_monitoring(nsId):
    """
    Contact with the monitoring manager to delete the monitoring jobs and the dashboard
    Parameters
    ----------
    nsId: string 
        String identifying the network service
    Returns
    -------
    None
    """
    # parse NSD / VNFDs to get the list of montoring jobs to be configured and its information
    if monitoring_pushgateway == "no":
        job_ids = ns_db.get_monitoring_info(nsId)
        for job_id in job_ids:
            stop_monitoring_job(job_id['exporterId'])
        # delete monitor jobs from database by posting an empty list
        ns_db.set_monitoring_info(nsId, [])
        dashboard_info = ns_db.get_dashboard_info(nsId)
        if "dashboardId" in dashboard_info.keys():
            stop_dashboard(dashboard_info["dashboardId"])
            ns_db.set_dashboard_info(nsId, {})
    else:
        job_ids = ns_db.get_monitoring_info(nsId)
        for job_id in job_ids:
            stop_monitoring_job(job_id['exporterId'])
            stop_exporters_on_rvm_agent(job_id)
            delete_rvm_agent(job_id['agent_id'])
        # delete monitor jobs from database by posting an empty list
        ns_db.set_monitoring_info(nsId, [])
        dashboard_info = ns_db.get_dashboard_info(nsId)
        if "dashboardId" in dashboard_info.keys():
            stop_dashboard(dashboard_info["dashboardId"])
            ns_db.set_dashboard_info(nsId, {})
예제 #2
0
def get_performance_metric_for_aiml_rule(nsId, aiml_element, nsd_json):
    return_list = []
    # monitored_infos = nsd_json['nsd']['monitoredInfo']
    # for param_ref in aiml_element['nsMonitoringParamRef']:
    # for monitored_info in monitored_infos:
    # monitoring_parameter_id = monitored_info['monitoringParameter']['monitoringParameterId']
    # performance_metric = monitored_info['monitoringParameter']['performanceMetric']
    # if monitoring_parameter_id == param_ref:
    # metric, vnf  = performance_metric.split(".")
    # expression = convert_expresion(performance_metric, None, nsId, vnf)
    # return_value = {
    # "expression": expression,
    # "vnf": vnf,
    # "metric": metric
    # }
    # return_list.append(return_value)
    # print(param_ref)
    panels_info = ns_db.get_dashboard_info(nsId)["panelsInfo"]
    for panel in panels_info:
        if (panel["monitoringParameterId"]
                in aiml_element["nsMonitoringParamRef"]):
            performance_metric = panel["performanceMetric"]
            metric, vnf = panel["performanceMetric"].split(".")
            expression = convert_expresion(performance_metric, None, nsId, vnf)
            return_value = {
                "expression": expression,
                "vnf": vnf,
                "metric": metric,
                "collectionPeriod": panel["collectionPeriod"]
            }
            return_list.append(return_value)
            print(panel["monitoringParameterId"])
    return return_list
예제 #3
0
파일: soe.py 프로젝트: 5growth/5gr-so
def query_ns(nsId):
    """
    Returns the information of the Network Service Instance identified by nsId.
    Parameters
    ----------
    nsId: string
        Identifier of the NS instance to terminate.
    Returns
    -------
    dict
        Information of the Network Service Instance.
    """

    if not ns_db.exists_nsId(nsId):
        # TODO create errors
        return 404
    # TODO: lines below are a stub
    status = ns_db.get_ns_status(nsId)
    vs_status = "FAILED"
    if status in ["TERMINATED", "INSTANTIATING", "TERMINATING"]:
        vs_status = "NOT_INSTANTIATED"
    elif status == "INSTANTIATED":
        vs_status = "INSTANTIATED"

    nsd_id = ns_db.get_nsdId(nsId)
    nsd_json = nsd_db.get_nsd_json(nsd_id)
    ns_name = ns_db.get_ns_name(nsId)
    ns_description = ns_db.get_ns_description(nsId)
    flavour_id = ns_db.get_ns_flavour_id(nsId)
    info = {
        "nsInstanceId": nsId,
        "nsName": ns_name,
        "description": ns_description,
        "nsdId": nsd_id,
        "flavourId": flavour_id,
        "nsState": vs_status,
    }
    #turn void the sap_info and the monitoring if the service is terminated
    if vs_status == "NOT_INSTANTIATED":
        info["sapInfo"] = []
        log_queue.put(["INFO", "hola"])
        return info

    if "sapd" in nsd_json["nsd"]:
        total_sap_info = get_ns_sap_info(nsId, nsd_json["nsd"]["sapd"])
        if total_sap_info is not None:
            info["sapInfo"] = total_sap_info

    dashboard_info = ns_db.get_dashboard_info(nsId)
    if "dashboardUrl" in dashboard_info.keys():
        info["monitoringDashboardUrl"] = dashboard_info["dashboardUrl"]

    log_queue.put(
        ["INFO",
         "query_result: %s" % dumps(info, indent=4, sort_keys=True)])
    return info
예제 #4
0
def update_ns_monitoring(nsId, nsd, vnfds, deployed_vnfs_info):
    """
    Contact with the monitoring manager to update the monitoring jobs and the dashboard
    Parameters
    ----------
    nsId: string 
        String identifying the network service
    nsd: json
        Network service descriptor
    vnfds: json
        VNF descriptor
    deployed_vnfs_info: dict
        Dictionary with information of the saps of the deployed vnfs in a network service
    Returns
    -------
    None
    """
    if monitoring_pushgateway == "no":
        new_jobs = []  # result of scale out operations
        old_jobs = []  # result of scale in operations
        job_ids = []
        [new_jobs, old_jobs] = update_pm_jobs(nsId, deployed_vnfs_info)
        for job in new_jobs:
            job_elem = configure_monitoring_job(job)
            job_ids.append(job_elem)
        # update the list of jobs in the database
        for job in old_jobs:
            stop_monitoring_job(job)
        ns_db.update_monitoring_info(nsId, job_ids, old_jobs)
        # update the dashboard for the monitoring jobs: once all required ones have been created or erased
        jobs = ns_db.get_monitoring_info(nsId)
        dashboard_info = ns_db.get_dashboard_info(nsId)
        if "dashboardId" in dashboard_info.keys():
            stop_dashboard(dashboard_info["dashboardId"])
        dashboard_id = configure_dashboard_v2(nsId, jobs)
        # we rewrite the dasboard info
        ns_db.set_dashboard_info(nsId, dashboard_id)
    else:
        new_jobs = []  # result of scale out operations
        old_jobs = []  # result of scale in operations
        job_ids = []
        [new_jobs,
         old_jobs] = update_pm_jobs_rvm_agents(nsId, deployed_vnfs_info)
        for job in new_jobs:
            job_elem = configure_monitoring_job_prometheus(job)
            job_elem = start_exporters_on_rvm_agent(job_elem)
            job_ids.append(job_elem)
        # update the list of jobs in the database
        old_jobs_ids = []
        for job_id in old_jobs:
            stop_monitoring_job(job_id['exporterId'])
            stop_exporters_on_rvm_agent(job_id)
            delete_rvm_agent(job_id['agent_id'])
            old_jobs_ids.append(job_id['exporterId'])
        ns_db.update_monitoring_info(nsId, job_ids, old_jobs_ids)