From: Venkata Harshavardhan Reddy Allu Date: Fri, 1 Mar 2019 20:39:56 +0000 (+0530) Subject: Fix logic in adding prefix to ip-a in classifier X-Git-Tag: v6.0.0~39 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F76%2F7276%2F3;p=osm%2FRO.git Fix logic in adding prefix to ip-a in classifier This commit has following changes: - When 'source-ip-address' or 'destination-ip-address' are not provided under "nsd:nsd-catalog:nsd:vnffgd:classifier:match-attributes" this would avoid adding the '/32' prefix in the classifier definition. - add details to classifier definition only if provided. This patch helps us in creating classifier with minimum details and avoid errors when 'source-ip-address' or 'destination-ip-address' were not provided in nsd. Change-Id: I5b572552bd670b56faa0aba5833209d198e10450 Signed-off-by: Venkata Harshavardhan Reddy Allu --- 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)