2 from flask_restful
import Resource
3 from flask
import request
6 logging
.basicConfig(level
=logging
.INFO
)
12 class MonitorInterfaceAction(Resource
):
14 Monitor the counters of a VNF interface
15 :param vnf_name: name of the VNF to be monitored
16 :param vnf_interface: name of the VNF interface to be monitored
17 :param metric: tx_bytes, rx_bytes, tx_packets, rx_packets
18 :return: message string indicating if the monitor action is succesful or not
22 def put(self
, vnf_name
, vnf_interface
, metric
):
23 logging
.debug("REST CALL: start monitor VNF interface")
25 c
= net
.monitor_agent
.setup_metric(vnf_name
, vnf_interface
, metric
)
26 # return monitor message response
28 except Exception as ex
:
29 logging
.exception("API error.")
30 return ex
.message
, 500
32 def delete(self
, vnf_name
, vnf_interface
, metric
):
33 logging
.debug("REST CALL: stop monitor VNF interface")
35 c
= net
.monitor_agent
.stop_metric(vnf_name
, vnf_interface
, metric
)
36 # return monitor message response
38 except Exception as ex
:
39 logging
.exception("API error.")
40 return ex
.message
, 500
43 class MonitorFlowAction(Resource
):
45 Monitor the counters of a specific flow
46 :param vnf_name: name of the VNF to be monitored
47 :param vnf_interface: name of the VNF interface to be monitored
48 :param metric: tx_bytes, rx_bytes, tx_packets, rx_packets
49 :param cookie: specific identifier of flows to monitor
50 :return: message string indicating if the monitor action is succesful or not
54 def put(self
, vnf_name
, vnf_interface
, metric
, cookie
):
55 logging
.debug("REST CALL: start monitor VNF interface")
57 c
= net
.monitor_agent
.setup_flow(vnf_name
, vnf_interface
, metric
, cookie
)
58 # return monitor message response
60 except Exception as ex
:
61 logging
.exception("API error.")
62 return ex
.message
, 500
64 def delete(self
, vnf_name
, vnf_interface
, metric
, cookie
):
65 logging
.debug("REST CALL: stop monitor VNF interface")
67 c
= net
.monitor_agent
.stop_flow(vnf_name
, vnf_interface
, metric
, cookie
)
68 # return monitor message response
70 except Exception as ex
:
71 logging
.exception("API error.")
72 return ex
.message
, 500