Skip to content

Functions usage

José Bonnet edited this page Aug 30, 2017 · 11 revisions

This page details the Function-related endpoints of the SONATA Gatekeeper API.

Please note that functions are created, updated or deleted only when a package containing them is created, updated or deleted.

/functions

GET

Through this endpoint GET request, the Gatekeeper returns a JSON formatted paginated list of functions meta-data.

  • Request:
curl <base URL>/functions -H 'authorization:bearer <token>'

Like Packages, Functions are univocally identified by the trio of fields vendor, name and version, which is unique, besides the UUID.

  • Response:
[
    {
        "created_at": "2017-08-28T15:23:31.653+00:00", 
        "md5": "add46509964fb841584777155ac06bdd", 
        "signature": null, 
        "status": "active", 
        "updated_at": "2017-08-28T15:23:31.653+00:00", 
        "user_licence": "public", 
        "username": "sonata-1503933806", 
        "uuid": "39cfccd6-9475-4e99-aa88-9a2066ac3976", 
        "vnfd": {
            "author": "George Xilouris, NCSRD", 
            "connection_points": [
                {
                    "id": "mgmt", 
                    "interface": "ipv4", 
                    "type": "management"
                }, 
                {
                    "id": "input", 
                    "interface": "ipv4", 
                    "type": "external"
                }, 
                {
                    "id": "output", 
                    "interface": "ipv4", 
                    "type": "external"
                }
            ], 
            "description": "\"Virtual traffic classifier (vTC) descriptor file. vTC uses ndpi library for the implementation of the vTC\"\n", 
            "descriptor_version": "vnfd-schema-01", 
            "monitoring_rules": [
                {
                    "condition": "vdu01:vm_cpu_perc > 85", 
                    "description": "Trigger events if CPU load is above 85 percent.", 
                    "duration": 10, 
                    "duration_unit": "s", 
                    "name": "mon:rule:vm_cpu_usage_85_perc", 
                    "notification": [
                        {
                            "name": "notification01", 
                            "type": "rabbitmq_message"
                        }
                    ]
                }
            ], 
            "name": "vtc-vnf", 
            "vendor": "eu.sonata-nfv", 
            "version": "0.1", 
            "virtual_deployment_units": [
                {
                    "connection_points": [
                        {
                            "id": "eth0", 
                            "interface": "ipv4", 
                            "type": "management"
                        }, 
                        {
                            "id": "eth1", 
                            "interface": "ipv4", 
                            "type": "internal"
                        }, 
                        {
                            "id": "eth2", 
                            "interface": "ipv4", 
                            "type": "internal"
                        }
                    ], 
                    "description": "VNFC for the dashboard and the time-series database", 
                    "id": "vdu01", 
                    "monitoring_parameters": [
                        {
                            "name": "vm_cpu_perc", 
                            "unit": "Percentage"
                        }, 
                        {
                            "name": "vm_mem_perc", 
                            "unit": "Percentage"
                        }, 
                        {
                            "name": "vm_net_rx_bps", 
                            "unit": "bps"
                        }, 
                        {
                            "name": "vm_net_tx_bps", 
                            "unit": "bps"
                        }
                    ], 
                    "resource_requirements": {
                        "cpu": {
                            "vcpus": 1
                        }, 
                        "memory": {
                            "size": 2, 
                            "size_unit": "GB"
                        }, 
                        "storage": {
                            "size": 40, 
                            "size_unit": "GB"
                        }
                    }, 
                    "vm_image": "sonata-vtc", 
                    "vm_image_format": "qcow2"
                }
            ], 
            "virtual_links": [
                {
                    "connection_points_reference": [
                        "vdu01:eth0", 
                        "mgmt"
                    ], 
                    "connectivity_type": "E-LAN", 
                    "dhcp": true, 
                    "id": "mgmt"
                }, 
                {
                    "connection_points_reference": [
                        "vdu01:eth1", 
                        "input"
                    ], 
                    "connectivity_type": "E-Line", 
                    "dhcp": true, 
                    "id": "input"
                }, 
                {
                    "connection_points_reference": [
                        "vdu01:eth2", 
                        "output"
                    ], 
                    "connectivity_type": "E-Line", 
                    "dhcp": true, 
                    "id": "output"
                }
            ]
        }
    }
]

/functions/<function_uuid>

GET

Through this endpoint GET request, the Gatekeeper returns a JSON formatted function meta-data.

  • Request:
curl <base URL>/functions/<function_uuid> -H 'authorization:bearer <token>'

Like Packages, Functions are univocally identified by the trio of fields vendor, name and version, which is unique, besides the UUID.

  • Response:
{
    "created_at": "2017-08-28T15:23:31.653+00:00", 
    "md5": "add46509964fb841584777155ac06bdd", 
    "signature": null, 
    "status": "active", 
    "updated_at": "2017-08-28T15:23:31.653+00:00", 
    "username": "sonata-1503933806", 
    "uuid": "39cfccd6-9475-4e99-aa88-9a2066ac3976", 
    "vnfd": {
        "author": "George Xilouris, NCSRD", 
        "connection_points": [
            {
                "id": "mgmt", 
                "interface": "ipv4", 
                "type": "management"
            }, 
            {
                "id": "input", 
                "interface": "ipv4", 
                "type": "external"
            }, 
            {
                "id": "output", 
                "interface": "ipv4", 
                "type": "external"
            }
        ], 
        "description": "\"Virtual traffic classifier (vTC) descriptor file. vTC uses ndpi library for the implementation of the vTC\"\n", 
        "descriptor_version": "vnfd-schema-01", 
        "monitoring_rules": [
            {
                "condition": "vdu01:vm_cpu_perc > 85", 
                "description": "Trigger events if CPU load is above 85 percent.", 
                "duration": 10, 
                "duration_unit": "s", 
                "name": "mon:rule:vm_cpu_usage_85_perc", 
                "notification": [
                    {
                        "name": "notification01", 
                        "type": "rabbitmq_message"
                    }
                ]
            }
        ], 
        "name": "vtc-vnf", 
        "vendor": "eu.sonata-nfv", 
        "version": "0.1", 
        "virtual_deployment_units": [
            {
                "connection_points": [
                    {
                        "id": "eth0", 
                        "interface": "ipv4", 
                        "type": "management"
                    }, 
                    {
                        "id": "eth1", 
                        "interface": "ipv4", 
                        "type": "internal"
                    }, 
                    {
                        "id": "eth2", 
                        "interface": "ipv4", 
                        "type": "internal"
                    }
                ], 
                "description": "VNFC for the dashboard and the time-series database", 
                "id": "vdu01", 
                "monitoring_parameters": [
                    {
                        "name": "vm_cpu_perc", 
                        "unit": "Percentage"
                    }, 
                    {
                        "name": "vm_mem_perc", 
                        "unit": "Percentage"
                    }, 
                    {
                        "name": "vm_net_rx_bps", 
                        "unit": "bps"
                    }, 
                    {
                        "name": "vm_net_tx_bps", 
                        "unit": "bps"
                    }
                ], 
                "resource_requirements": {
                    "cpu": {
                        "vcpus": 1
                    }, 
                    "memory": {
                        "size": 2, 
                        "size_unit": "GB"
                    }, 
                    "storage": {
                        "size": 40, 
                        "size_unit": "GB"
                    }
                }, 
                "vm_image": "sonata-vtc", 
                "vm_image_format": "qcow2"
            }
        ], 
        "virtual_links": [
            {
                "connection_points_reference": [
                    "vdu01:eth0", 
                    "mgmt"
                ], 
                "connectivity_type": "E-LAN", 
                "dhcp": true, 
                "id": "mgmt"
            }, 
            {
                "connection_points_reference": [
                    "vdu01:eth1", 
                    "input"
                ], 
                "connectivity_type": "E-Line", 
                "dhcp": true, 
                "id": "input"
            }, 
            {
                "connection_points_reference": [
                    "vdu01:eth2", 
                    "output"
                ], 
                "connectivity_type": "E-Line", 
                "dhcp": true, 
                "id": "output"
            }
        ]
    }
}

/functions/metrics/<function instance uuid>/<vdu id>/<vc uuid>/asynch-mon-data/

GET

Through this endpoint GET request, the Gatekeeper returns a JSON formatted monitoring data, according to the filtering mandatory parameters:

  • metrics: a comma-separated list of metric names;

  • since: the starting date of the metrics collection;

  • until: the ending date of the metrics collection;

  • step: the step to be used, in seconds, in the metrics' collection.

  • Request:

curl <base URL>/functions/<function instance uuid>/<vdu id>/<vc uuid>/asynch-mon-data/metrics=<metric name>&since=<starting date>&until=<ending date>&step=<step of collection> \
 -H 'authorization:bearer <token>'
  • Response:
{
    "status":null,
    "function_instance_uuid":"e60558d6-91c3-4196-abad-46079a0e3c61",
    "vdu_id":"vdu01",
    "vc_uuid":"fa8869e3-cc5f-4a5e-8520-932226d804e1",
    "metrics":["vm_cpu_perc"],
    "requested_data":[{
        "metrics":{
            "resultType":"matrix",
            "result":[{
                "metric":{
                    "exported_instance":"vtc-vnf",
                    "core":"cpu",
                    "group":"development",
                    "exported_job":"vnf",
                    "instance":"pushgateway:9091",
                    "job":"sonata",
                    "__name__":"vm_cpu_perc",
                    "id":"fa8869e3-cc5f-4a5e-8520-932226d804e1"
                },
                "values":[
                    [1504011287,"0"],
                    [1504011301,"0"],
                    ...
                    [1504012267,"0"],
                    [1504012281,"0"]
                ]
            },
            {
                "metric":{
                    "exported_instance":"vtc-vnf",
                    "core":"cpu0",
                    "group":"development",
                    "exported_job":"vnf",
                    "instance":"pushgateway:9091",
                    "job":"sonata",
                    "__name__":"vm_cpu_perc",
                    "id":"fa8869e3-cc5f-4a5e-8520-932226d804e1"
                },
                "values":[
                    [1504011287,"0"],
                    [1504011301,"0"],
                    ...
                    [1504012267,"0"],
                    [1504012281,"0"]
                ]}
            ]}
        }
    ]
}

/functions/metrics/<function instance uuid>/<vdu id>/<vc uuid>/synch-mon-data/

GET

Through this endpoint GET request, the Gatekeeper returns a Web Socket URL, through which the client can get the monitoring data, according to the filtering mandatory parameters:

  • metrics: a comma-separated list of metric names;

  • since: the starting date of the metrics collection;

  • until: the ending date of the metrics collection;

  • step: the step to be used, in seconds, in the metrics' collection.

  • Request:

curl <base URL>/functions/<function instance uuid>/<vdu id>/<vc uuid>/synch-mon-data/metrics=<metric name list>&since=<starting date>&until=<ending date>&step=<step of collection> \
 -H 'authorization:bearer <token>'
  • Response:
{
    "status": "SUCCESS",
    "function_instance_uuid":"e60558d6-91c3-4196-abad-46079a0e3c61",
    "vdu_id": "vdu01",
    "vc_uuid": "fa8869e3-cc5f-4a5e-8520-932226d804e1",
    "metrics": ["vm_cpu_perc"],
    "ws_url": "ws://<web socket server url>/ws/<ws id>"
}
Clone this wiki locally