X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_ro%2Fvim_thread.py;fp=osm_ro%2Fvim_thread.py;h=d57ec470cff7ab9d4a517e81496ad4eca915c78a;hb=a1b2e57563f82763eaf940e836e2f8683fa9be81;hp=80024365a3ebc18b37133def435d484cf8f10879;hpb=40c6a3fd270d6d00f1fc073c2277ff724b4e385a;p=osm%2FRO.git diff --git a/osm_ro/vim_thread.py b/osm_ro/vim_thread.py index 80024365..d57ec470 100644 --- a/osm_ro/vim_thread.py +++ b/osm_ro/vim_thread.py @@ -1222,26 +1222,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)