X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=near-rt-ric-simulator%2Fric-plt%2Fa1%2Fa1.py;h=7f77781a4fc16d75c73e4b6598f24c61cdc4de40;hb=e2ac0dcf30eaf828a7c7bbd722730410f4110030;hp=bc78b97e3c83d337e10d2783dc19193abae96b6e;hpb=7164d4da7a92cfe8b19a23fda9442e419f1db34f;p=nonrtric.git diff --git a/near-rt-ric-simulator/ric-plt/a1/a1.py b/near-rt-ric-simulator/ric-plt/a1/a1.py index bc78b97e..7f77781a 100644 --- a/near-rt-ric-simulator/ric-plt/a1/a1.py +++ b/near-rt-ric-simulator/ric-plt/a1/a1.py @@ -44,15 +44,20 @@ def put_policy(policyId): if policyId != i and \ data == policy_instances[i] and \ policyTypeId == policy_type_per_instance[i]: - return(set_error(None, "The policy already exists with a different id.", 404, "No action has been taken. The id of the existing policy instance is: " + i + ".", None, None, None, None)) + return(set_error(None, "The policy already exists with a different id.", 400, "No action has been taken. The id of the existing policy instance is: " + i + ".", None, None, None, None)) if policyId in list(policy_instances.keys()): if data["scope"] != policy_instances[policyId]["scope"]: - return(set_error(None, "The policy already exists with a different scope.", 404, "The policy put involves a modification of the existing scope, which is not allowed.", None, None, "scope", None)) + return(set_error(None, "The policy already exists with a different scope.", 400, "The policy put involves a modification of the existing scope, which is not allowed.", None, None, "scope", None)) if 'code' in request.args: return(send_error_code(request.args)) + if policyId in policy_instances.keys(): + code = 201 + else: + code = 200 + policy_instances[policyId] = data policy_status[policyId] = set_status("UNDEFINED") if 'policyTypeId' in request.args: @@ -65,11 +70,6 @@ def put_policy(policyId): else: policy_type_per_instance[policyId] = "UNDEFINED" - if policyId in policy_instances.keys(): - code = 201 - else: - code = 200 - response = make_response(policy_instances[policyId], code) if code == 201: response.headers['Location'] = "http://localhost:8085/A1-P/v1/policies/" + policyId