X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_ro%2Fvim_thread.py;h=02b3bccfe974627ff87dd27bde38d7e680535cfc;hb=264c0cf3aea0dc1a0d539c5f535cde562cd47b16;hp=80024365a3ebc18b37133def435d484cf8f10879;hpb=dfed511cd627748046d90894f8600331413b1cd3;p=osm%2FRO.git diff --git a/osm_ro/vim_thread.py b/osm_ro/vim_thread.py index 80024365..02b3bccf 100644 --- a/osm_ro/vim_thread.py +++ b/osm_ro/vim_thread.py @@ -990,7 +990,7 @@ class vim_thread(threading.Thread): # CREATE params = task["params"] action_text = "creating VIM" - vim_net_id = self.vim.new_network(*params[0:3]) + vim_net_id, created_items = self.vim.new_network(*params[0:3]) net_name = params[0] net_type = params[1] @@ -1039,6 +1039,7 @@ class vim_thread(threading.Thread): task["extra"]["vim_info"] = {} task["extra"]["sdn_net_id"] = sdn_net_id task["extra"]["created"] = True + task["extra"]["created_items"] = created_items task["error_msg"] = None task["vim_id"] = vim_net_id instance_element_update = {"vim_net_id": vim_net_id, "sdn_net_id": sdn_net_id, "status": "BUILD", @@ -1068,7 +1069,7 @@ class vim_thread(threading.Thread): self.ovim.delete_port(port['uuid'], idempotent=True) self.ovim.delete_network(sdn_net_id, idempotent=True) if net_vim_id: - self.vim.delete_network(net_vim_id) + self.vim.delete_network(net_vim_id, task["extra"].get("created_items")) task["status"] = "DONE" task["error_msg"] = None return True, None @@ -1222,26 +1223,31 @@ class vim_thread(threading.Thread): ip_proto = int(params.get("ip_proto")) source_ip = params.get("source_ip") destination_ip = params.get("destination_ip") - if ip_proto == 1: - ip_proto = 'icmp' - elif ip_proto == 6: - ip_proto = 'tcp' - elif ip_proto == 17: - ip_proto = 'udp' - if '/' not in source_ip: - source_ip += '/32' - if '/' not in destination_ip: - destination_ip += '/32' - definition = { - "logical_source_port": interfaces[0], - "protocol": ip_proto, - "source_ip_prefix": source_ip, - "destination_ip_prefix": destination_ip, - "source_port_range_min": params.get("source_port"), - "source_port_range_max": params.get("source_port"), - "destination_port_range_min": params.get("destination_port"), - "destination_port_range_max": params.get("destination_port"), - } + source_port = params.get("source_port") + destination_port = params.get("destination_port") + definition = {"logical_source_port": interfaces[0]} + if ip_proto: + if ip_proto == 1: + ip_proto = 'icmp' + elif ip_proto == 6: + ip_proto = 'tcp' + elif ip_proto == 17: + ip_proto = 'udp' + definition["protocol"] = ip_proto + if source_ip: + if '/' not in source_ip: + source_ip += '/32' + definition["source_ip_prefix"] = source_ip + if source_port: + definition["source_port_range_min"] = source_port + definition["source_port_range_max"] = source_port + if destination_port: + definition["destination_port_range_min"] = destination_port + definition["destination_port_range_max"] = destination_port + if destination_ip: + if '/' not in destination_ip: + destination_ip += '/32' + definition["destination_ip_prefix"] = destination_ip vim_classification_id = self.vim.new_classification( name, 'legacy_flow_classifier', definition)