X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=near-rt-ric-simulator%2Fsrc%2FSTD_2.0.0%2Fa1.py;h=2dc7b5531e80590ad8fdeda3cb3ace2e9a5a525b;hb=24ee2701e54884c8fc2ed7e6cf522d71286a3b33;hp=c4aa4ca6260d3648320b1b20bc7c712546ecaa6a;hpb=59e2b2abfe0474acacb44a2922bfaf01b26bfa06;p=sim%2Fa1-interface.git diff --git a/near-rt-ric-simulator/src/STD_2.0.0/a1.py b/near-rt-ric-simulator/src/STD_2.0.0/a1.py index c4aa4ca..2dc7b55 100644 --- a/near-rt-ric-simulator/src/STD_2.0.0/a1.py +++ b/near-rt-ric-simulator/src/STD_2.0.0/a1.py @@ -1,5 +1,5 @@ # ============LICENSE_START=============================================== -# Copyright (C) 2020 Nordix Foundation. All rights reserved. +# Copyright (C) 2021 Nordix Foundation. All rights reserved. # ======================================================================== # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ from flask import Flask, escape, request, Response, make_response from jsonschema import validate from var_declaration import policy_instances, policy_types, policy_status, callbacks, forced_settings, policy_fingerprint, hosts_set from utils import calcFingerprint -from maincommon import check_apipath, apipath, get_supported_interfaces_response, extract_host_name +from maincommon import check_apipath, apipath, get_supported_interfaces_response, extract_host_name, is_duplicate_check #Constsants APPL_JSON='application/json' @@ -107,13 +107,21 @@ def put_policy(policyTypeId, policyId): retcode=201 if policy_id in policy_instances[policy_type_id].keys(): retcode=200 - fp_previous=calcFingerprint(policy_instances[policy_type_id][policy_id]) + if (is_duplicate_check()): + fp_previous=calcFingerprint(policy_instances[policy_type_id][policy_id], policy_type_id) + else: + fp_previous=policy_id else: if (policy_id in policy_fingerprint.values()): - return (None, 400) + pjson=create_problem_json(None, "The policy id already exist for other policy type.", 400, None, policy_id) + return Response(json.dumps(pjson), 400, mimetype=APPL_PROB_JSON) + + if (is_duplicate_check()): + fp=calcFingerprint(data, policy_type_id) + else: + fp=policy_id - fp=calcFingerprint(data) - if (fp in policy_fingerprint.keys()): + if ((fp in policy_fingerprint.keys()) and is_duplicate_check()): p_id=policy_fingerprint[fp] if (p_id != policy_id): pjson=create_problem_json(None, "Duplicate, the policy json already exists.", 400, None, policy_id) @@ -183,7 +191,11 @@ def delete_policy(policyTypeId, policyId): pjson=create_problem_json(None, "The requested policy does not exist.", 404, None, policy_id) return Response(json.dumps(pjson), 404, mimetype=APPL_PROB_JSON) - fp_previous=calcFingerprint(policy_instances[policy_type_id][policy_id]) + if (is_duplicate_check()): + fp_previous=calcFingerprint(policy_instances[policy_type_id][policy_id], policy_type_id) + else: + fp_previous=policy_id + policy_fingerprint.pop(fp_previous) policy_instances[policy_type_id].pop(policy_id) policy_status.pop(policy_id)