cleanup rest API issues
diff --git a/src/emuvim/api/rest/compute.py b/src/emuvim/api/rest/compute.py
index e412133..9f0516b 100755
--- a/src/emuvim/api/rest/compute.py
+++ b/src/emuvim/api/rest/compute.py
@@ -78,7 +78,8 @@
'''
nw_list = list()
- if network_str is None or '),(' not in network_str :
+ # TODO make this more robust with regex check
+ if network_str is None :
return nw_list
networks = network_str[1:-1].split('),(')
diff --git a/src/emuvim/api/rest/monitor.py b/src/emuvim/api/rest/monitor.py
index 15ec014..45d9541 100755
--- a/src/emuvim/api/rest/monitor.py
+++ b/src/emuvim/api/rest/monitor.py
@@ -53,7 +53,7 @@
"""
global net
- def put(self, vnf_name, vnf_interface, metric):
+ def put(self, vnf_name, vnf_interface=None, metric='tx_packets'):
logging.debug("REST CALL: start monitor VNF interface")
try:
c = net.monitor_agent.setup_metric(vnf_name, vnf_interface, metric)
@@ -63,7 +63,7 @@
logging.exception("API error.")
return ex.message, 500
- def delete(self, vnf_name, vnf_interface, metric):
+ def delete(self, vnf_name, vnf_interface=None, metric='tx_packets'):
logging.debug("REST CALL: stop monitor VNF interface")
try:
c = net.monitor_agent.stop_metric(vnf_name, vnf_interface, metric)
@@ -85,7 +85,7 @@
"""
global net
- def put(self, vnf_name, vnf_interface, metric, cookie):
+ def put(self, vnf_name, vnf_interface=None, metric='tx_packets', cookie=0):
logging.debug("REST CALL: start monitor VNF interface")
try:
c = net.monitor_agent.setup_flow(vnf_name, vnf_interface, metric, cookie)
@@ -95,7 +95,7 @@
logging.exception("API error.")
return ex.message, 500
- def delete(self, vnf_name, vnf_interface, metric, cookie):
+ def delete(self, vnf_name, vnf_interface=None, metric='tx_packets', cookie=0):
logging.debug("REST CALL: stop monitor VNF interface")
try:
c = net.monitor_agent.stop_flow(vnf_name, vnf_interface, metric, cookie)
diff --git a/src/emuvim/api/rest/rest_api_endpoint.py b/src/emuvim/api/rest/rest_api_endpoint.py
index d6c1185..536ed7a 100755
--- a/src/emuvim/api/rest/rest_api_endpoint.py
+++ b/src/emuvim/api/rest/rest_api_endpoint.py
@@ -69,10 +69,14 @@
self.api.add_resource(DatacenterList, "/restapi/datacenter")
self.api.add_resource(DatacenterStatus, "/restapi/datacenter/<dc_label>")
- self.api.add_resource(NetworkAction, "/restapi/network/<vnf_src_name>/<vnf_dst_name>")
+ self.api.add_resource(NetworkAction, "/restapi/network/<vnf_src_name>/<vnf_dst_name>",)
- self.api.add_resource(MonitorInterfaceAction, "/restapi/monitor/<vnf_name>/<vnf_interface>/<metric>")
- self.api.add_resource(MonitorFlowAction, "/restapi/monitor/<vnf_name>/<vnf_interface>/<metric>/<cookie>")
+ self.api.add_resource(MonitorInterfaceAction,
+ "/restapi/monitor/<vnf_name>/<metric>",
+ "/restapi/monitor/<vnf_name>/<vnf_interface>/<metric>")
+ self.api.add_resource(MonitorFlowAction,
+ "/restapi/flowmon/<vnf_name>/<metric>/<cookie>",
+ "/restapi/flowmon/<vnf_name>/<vnf_interface>/<metric>/<cookie>")
logging.debug("Created API endpoint %s(%s:%d)" % (self.__class__.__name__, self.ip, self.port))