diff --git a/docs/favicon.ico b/docs/favicon.ico deleted file mode 100644 index 00b0fd0ef0b4e78fbb8cdb413ce84561dfeb404f..0000000000000000000000000000000000000000 Binary files a/docs/favicon.ico and /dev/null differ diff --git a/docs/requirements-docs.txt b/docs/requirements-docs.txt deleted file mode 100644 index 09a0c1cb0a13731780cfde2d2bb3e7abf07a5dec..0000000000000000000000000000000000000000 --- a/docs/requirements-docs.txt +++ /dev/null @@ -1,5 +0,0 @@ -sphinx -sphinx-rtd-theme -sphinxcontrib-httpdomain -recommonmark -lfdocs-conf diff --git a/near-rt-ric-simulator/api/STD_1.1.3/STD_A1.yaml b/near-rt-ric-simulator/api/STD_1.1.3/STD_A1.yaml deleted file mode 100644 index 71638f4b9d8e35c83abd8a47bd1c2c0387a45cea..0000000000000000000000000000000000000000 --- a/near-rt-ric-simulator/api/STD_1.1.3/STD_A1.yaml +++ /dev/null @@ -1,258 +0,0 @@ -openapi: 3.0.0 -info: - title: 'A1-P Policy Management Service' - version: 1.1.3 - description: | - API for Policy Management Service. - © 2019, O-RAN Alliance. - All rights reserved. -externalDocs: - description: 'ORAN-WG2.A1.AP-v01.01 A1 interface: Application protocol' - url: 'https://www.o-ran.org/specifications' -servers: - - url: '{apiRoot}/A1-P/v1' - variables: - apiRoot: - default: 'https://example.com' - description: 'apiRoot as defined in clause 4.2.1 in ORAN-WG2.A1.AP' -paths: - '/policies': - get: - operationId: a1.get_all_policy_identities - description: 'Get all policy identities' - tags: - - All Policy Identities - responses: - 200: - description: 'Array of all policy identities' - content: - application/json: - schema: - type: array - items: - "$ref": "#/components/schemas/PolicyId" - minItems: 0 - 429: - "$ref": "#/components/responses/429-TooManyRequests" - 503: - "$ref": "#/components/responses/503-ServiceUnavailable" - - '/policies/{policyId}': - parameters: - - name: policyId - in: path - required: true - schema: - "$ref": "#/components/schemas/PolicyId" - put: - operationId: a1.put_policy - description: 'Create, or update, a policy' - tags: - - Individual Policy Object - parameters: - - name: notificationDestination - in: query - required: false - schema: - "$ref": "#/components/schemas/NotificationDestination" - requestBody: - required: true - content: - application/json: - schema: - "$ref": "#/components/schemas/PolicyObject" - responses: - 200: - description: 'The policy was updated' - content: - application/json: - schema: - "$ref": "#/components/schemas/PolicyObject" - 201: - description: 'The policy was created' - content: - application/json: - schema: - "$ref": "#/components/schemas/PolicyObject" - headers: - Location: - description: 'Contains the URI of the created policy' - required: true - schema: - type: string - - 400: - "$ref": "#/components/responses/400-BadRequest" - 409: - "$ref": "#/components/responses/409-Conflict" - 429: - "$ref": "#/components/responses/429-TooManyRequests" - 503: - "$ref": "#/components/responses/503-ServiceUnavailable" - 507: - "$ref": "#/components/responses/507-InsufficientStorage" - callbacks: - policyStatusNotification: - '{$request.query.notificationDestination}': - post: - description: 'Notify about status changes for this policy' - requestBody: - required: true - content: - application/json: - schema: - "$ref": "#/components/schemas/PolicyStatusObject" - responses: - 204: - description: 'Notification received' - get: - operationId: a1.get_policy - description: 'Query a policy' - tags: - - Individual Policy Object - responses: - 200: - description: 'The requested policy' - content: - application/json: - schema: - "$ref": "#/components/schemas/PolicyObject" - 404: - "$ref": "#/components/responses/404-NotFound" - 409: - "$ref": "#/components/responses/409-Conflict" - 429: - "$ref": "#/components/responses/429-TooManyRequests" - 503: - "$ref": "#/components/responses/503-ServiceUnavailable" - delete: - operationId: a1.delete_policy - description: 'Delete a policy' - tags: - - Individual Policy Object - responses: - 204: - description: 'The policy was deleted' - 404: - "$ref": "#/components/responses/404-NotFound" - 429: - "$ref": "#/components/responses/429-TooManyRequests" - 503: - "$ref": "#/components/responses/503-ServiceUnavailable" - - '/policies/{policyId}/status': - parameters: - - name: policyId - in: path - required: true - schema: - "$ref": "#/components/schemas/PolicyId" - get: - operationId: a1.get_policy_status - description: 'Query a policy status' - tags: - - Individual Policy Status Object - responses: - 200: - description: 'The requested policy status' - content: - application/json: - schema: - "$ref": "#/components/schemas/PolicyStatusObject" - 404: - "$ref": "#/components/responses/404-NotFound" - 409: - "$ref": "#/components/responses/409-Conflict" - 429: - "$ref": "#/components/responses/429-TooManyRequests" - 503: - "$ref": "#/components/responses/503-ServiceUnavailable" - -components: - schemas: - # - # Representation objects - # - PolicyObject: - description: 'A generic policy object that can be used to transport any policy. Additionally, a policy shall be valid according to the schema of its specific policy type.' - type: object - - PolicyStatusObject: - description: 'A generic policy status object that can be used to transport any policy status. Additionally, a policy status shall be valid according to the schema of its specific policy type.' - type: object - - ProblemDetails: - description: 'A problem detail to carry details in a HTTP response according to RFC 7807' - type: object - properties: - type: - type: string - title: - type: string - status: - type: number - detail: - type: string - instance: - type: string - - # - # Simple data types - # - NotificationDestination: - description: 'A complete callback URI defined according to IETF RFC 3986 where to send notifications' - type: string - - PolicyId: - description: 'Policy identifier assigned by the A1-P Consumer when a policy is created' - type: string - - responses: - 400-BadRequest: - description: 'Object in payload not properly formulated or not related to the method' - content: - application/problem+json: - schema: - "$ref": "#/components/schemas/ProblemDetails" - - 404-NotFound: - description: 'No resource found at the URI' - content: - application/problem+json: - schema: - "$ref": "#/components/schemas/ProblemDetails" - - 405-MethodNotAllowed: - description: 'Method not allowed for the URI' - content: - application/problem+json: - schema: - "$ref": "#/components/schemas/ProblemDetails" - - 409-Conflict: - description: 'Request could not be processed in the current state of the resource' - content: - application/problem+json: - schema: - "$ref": "#/components/schemas/ProblemDetails" - - 429-TooManyRequests: - description: 'Too many requests have been sent in a given amount of time' - content: - application/problem+json: - schema: - "$ref": "#/components/schemas/ProblemDetails" - - 503-ServiceUnavailable: - description: 'The provider is currently unable to handle the request due to a temporary overload' - content: - application/problem+json: - schema: - "$ref": "#/components/schemas/ProblemDetails" - - 507-InsufficientStorage: - description: 'The method could not be performed on the resource because the provider is unable to store the representation needed to successfully complete the request' - content: - application/problem+json: - schema: - "$ref": "#/components/schemas/ProblemDetails" \ No newline at end of file diff --git a/near-rt-ric-simulator/api/STD_2.0.0/ORAN_A1-p_V2.0.0_api.yaml b/near-rt-ric-simulator/api/STD_2.0.0/ORAN_A1-p_V2.0.0_api.yaml deleted file mode 100644 index 3cb62c5b0817e1af94e217afbca0188622b39c56..0000000000000000000000000000000000000000 --- a/near-rt-ric-simulator/api/STD_2.0.0/ORAN_A1-p_V2.0.0_api.yaml +++ /dev/null @@ -1,341 +0,0 @@ -openapi: 3.0.0 -info: - title: 'A1-P Policy Management Service' - version: 2.0.0 - description: | - API for Policy Management Service. - © 2020, O-RAN Alliance. - All rights reserved. -externalDocs: - description: 'O-RAN.WG2.A1AP-v02.00 A1 interface: Application Protocol' - url: 'https://www.o-ran.org/specifications' -servers: - - url: '{apiRoot}/A1-P/v2' - variables: - apiRoot: - default: 'https://example.com' - description: 'apiRoot as defined in clause 4.2.1 in ORAN-WG2.A1.AP' -paths: - '/policytypes': - get: - operationId: a1.get_all_policy_types - description: 'Get all policy type identifiers' - tags: - - All Policy Type Identifiers - responses: - 200: - description: 'Array of all policy type identifiers' - content: - application/json: - schema: - type: array - items: - "$ref": "#/components/schemas/PolicyTypeId" - minItems: 0 - 429: - "$ref": "#/components/responses/429-TooManyRequests" - 503: - "$ref": "#/components/responses/503-ServiceUnavailable" - - '/policytypes/{policyTypeId}': - parameters: - - name: policyTypeId - in: path - required: true - schema: - "$ref": "#/components/schemas/PolicyTypeId" - get: - operationId: a1.get_policy_type - description: 'Get the schemas for a policy type' - tags: - - Individual Policy Type - responses: - 200: - description: 'The policy type schemas' - content: - application/json: - schema: - "$ref": "#/components/schemas/PolicyTypeObject" - 404: - "$ref": "#/components/responses/404-NotFound" - 429: - "$ref": "#/components/responses/429-TooManyRequests" - 503: - "$ref": "#/components/responses/503-ServiceUnavailable" - - '/policytypes/{policyTypeId}/policies': - get: - operationId: a1.get_all_policy_identities - description: 'Get all policy identifiers' - tags: - - All Policy Identifiers - parameters: - - name: policyTypeId - in: path - required: true - schema: - "$ref": "#/components/schemas/PolicyTypeId" - responses: - 200: - description: 'Array of all policy identifiers' - content: - application/json: - schema: - type: array - items: - "$ref": "#/components/schemas/PolicyId" - minItems: 0 - 429: - "$ref": "#/components/responses/429-TooManyRequests" - 503: - "$ref": "#/components/responses/503-ServiceUnavailable" - - '/policytypes/{policyTypeId}/policies/{policyId}': - parameters: - - name: policyTypeId - in: path - required: true - schema: - "$ref": "#/components/schemas/PolicyTypeId" - - name: policyId - in: path - required: true - schema: - "$ref": "#/components/schemas/PolicyId" - put: - operationId: a1.put_policy - description: 'Create, or update, a policy' - tags: - - Individual Policy Object - parameters: - - name: notificationDestination - in: query - required: false - schema: - "$ref": "#/components/schemas/NotificationDestination" - requestBody: - required: true - content: - application/json: - schema: - "$ref": "#/components/schemas/PolicyObject" - responses: - 200: - description: 'The policy was updated' - content: - application/json: - schema: - "$ref": "#/components/schemas/PolicyObject" - 201: - description: 'The policy was created' - content: - application/json: - schema: - "$ref": "#/components/schemas/PolicyObject" - headers: - Location: - description: 'Contains the URI of the created policy' - required: true - schema: - type: string - 400: - "$ref": "#/components/responses/400-BadRequest" - 409: - "$ref": "#/components/responses/409-Conflict" - 429: - "$ref": "#/components/responses/429-TooManyRequests" - 503: - "$ref": "#/components/responses/503-ServiceUnavailable" - 507: - "$ref": "#/components/responses/507-InsufficientStorage" - callbacks: - policyStatusNotification: - '{$request.query.notificationDestination}': - post: - description: 'Notify about status changes for this policy' - requestBody: - required: true - content: - application/json: - schema: - "$ref": "#/components/schemas/PolicyStatusObject" - responses: - 204: - description: 'Notification received' - get: - operationId: a1.get_policy - description: 'Query a policy' - tags: - - Individual Policy Object - responses: - 200: - description: 'The requested policy' - content: - application/json: - schema: - "$ref": "#/components/schemas/PolicyObject" - 404: - "$ref": "#/components/responses/404-NotFound" - 409: - "$ref": "#/components/responses/409-Conflict" - 429: - "$ref": "#/components/responses/429-TooManyRequests" - 503: - "$ref": "#/components/responses/503-ServiceUnavailable" - delete: - operationId: a1.delete_policy - description: 'Delete a policy' - tags: - - Individual Policy Object - responses: - 204: - description: 'The policy was deleted' - 404: - "$ref": "#/components/responses/404-NotFound" - 429: - "$ref": "#/components/responses/429-TooManyRequests" - 503: - "$ref": "#/components/responses/503-ServiceUnavailable" - - '/policytypes/{policyTypeId}/policies/{policyId}/status': - parameters: - - name: policyTypeId - in: path - required: true - schema: - "$ref": "#/components/schemas/PolicyTypeId" - - name: policyId - in: path - required: true - schema: - "$ref": "#/components/schemas/PolicyId" - get: - operationId: a1.get_policy_status - description: 'Query a policy status' - tags: - - Individual Policy Status Object - responses: - 200: - description: 'The requested policy status' - content: - application/json: - schema: - "$ref": "#/components/schemas/PolicyStatusObject" - 404: - "$ref": "#/components/responses/404-NotFound" - 409: - "$ref": "#/components/responses/409-Conflict" - 429: - "$ref": "#/components/responses/429-TooManyRequests" - 503: - "$ref": "#/components/responses/503-ServiceUnavailable" - -components: - schemas: - # - # Representation objects - # - PolicyObject: - description: 'A generic policy object that can be used to transport any policy. Additionally, a policy shall be valid according to the schema of its specific policy type.' - type: object - - PolicyStatusObject: - description: 'A generic policy status object that can be used to transport any policy status. Additionally, a policy status shall be valid according to the schema of its specific policy type.' - type: object - - PolicyTypeObject: - description: 'A definition of a policy type, i.e. the schemas for a policy respectively its status' - type: object - properties: - policySchema: - "$ref": "#/components/schemas/JsonSchema" - statusSchema: - "$ref": "#/components/schemas/JsonSchema" - required: - - policySchema - - ProblemDetails: - description: 'A problem detail to carry details in a HTTP response according to RFC 7807' - type: object - properties: - type: - type: string - title: - type: string - status: - type: number - detail: - type: string - instance: - type: string - - # - # Simple data types - # - JsonSchema: - description: 'A JSON schema following http://json-schema.org/draft-07/schema' - type: object - - NotificationDestination: - description: 'A complete callback URI defined according to IETF RFC 3986 where to send notifications' - type: string - - PolicyId: - description: 'Policy identifier assigned by the A1-P Consumer when a policy is created' - type: string - - PolicyTypeId: - description: 'Policy type identifier assigned by the A1-P Provider' - type: string - - responses: - 400-BadRequest: - description: 'Object in payload not properly formulated or not related to the method' - content: - application/problem+json: - schema: - "$ref": "#/components/schemas/ProblemDetails" - - 404-NotFound: - description: 'No resource found at the URI' - content: - application/problem+json: - schema: - "$ref": "#/components/schemas/ProblemDetails" - - 405-MethodNotAllowed: - description: 'Method not allowed for the URI' - content: - application/problem+json: - schema: - "$ref": "#/components/schemas/ProblemDetails" - - 409-Conflict: - description: 'Request could not be processed in the current state of the resource' - content: - application/problem+json: - schema: - "$ref": "#/components/schemas/ProblemDetails" - - 429-TooManyRequests: - description: 'Too many requests have been sent in a given amount of time' - content: - application/problem+json: - schema: - "$ref": "#/components/schemas/ProblemDetails" - - 503-ServiceUnavailable: - description: 'The provider is currently unable to handle the request due to a temporary overload' - content: - application/problem+json: - schema: - "$ref": "#/components/schemas/ProblemDetails" - - 507-InsufficientStorage: - description: 'The method could not be performed on the resource because the provider is unable to store the representation needed to successfully complete the request' - content: - application/problem+json: - schema: - "$ref": "#/components/schemas/ProblemDetails" - - diff --git a/near-rt-ric-simulator/src/STD_1.1.3/a1.py b/near-rt-ric-simulator/src/STD_1.1.3/a1.py deleted file mode 100644 index d7169b19e81b63e076ea82243f01958005dd17aa..0000000000000000000000000000000000000000 --- a/near-rt-ric-simulator/src/STD_1.1.3/a1.py +++ /dev/null @@ -1,196 +0,0 @@ -# ============LICENSE_START=============================================== -# Copyright (C) 2020 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END================================================= -# - -import copy -import datetime -import json -import logging -import collections -import time - -from connexion import NoContent -from flask import Flask, escape, request, Response, make_response -from var_declaration import policy_instances, 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 - -#Constsants -APPL_JSON='application/json' -APPL_PROB_JSON='application/problem+json' - -# API Function: Get all policy ids -def get_all_policy_identities(): - - extract_host_name(hosts_set, request) - - if ((r := check_modified_response()) is not None): - return r - - return (list(policy_instances.keys()), 200) - -# API Function: Create or update a policy -def put_policy(policyId): - - extract_host_name(hosts_set, request) - - if ((r := check_modified_response()) is not None): - return r - - try: - data = request.data - data = json.loads(data) - except Exception: - pjson=create_problem_json(None, "The policy is corrupt or missing.", 400, None, policyId) - return Response(json.dumps(pjson), 400, mimetype=APPL_PROB_JSON) - - fp_previous=None - retcode=201 - if policyId in policy_instances.keys(): - retcode=200 - fp_previous=calcFingerprint(policy_instances[policyId]) - - fp=calcFingerprint(data) - if (fp in policy_fingerprint.keys()): - p_id=policy_fingerprint[fp] - if (p_id != policyId): - pjson=create_problem_json(None, "The policy json already exists.", 400, None, policyId) - return Response(json.dumps(pjson), 400, mimetype=APPL_PROB_JSON) - - if (fp_previous is not None): - del policy_fingerprint[fp_previous] - - policy_fingerprint[fp]=policyId - - noti=request.args.get('notificationDestination') - callbacks[policyId]=noti - - policy_instances[policyId]=data - ps={} - ps["enforceStatus"] = "UNDEFINED" - policy_status[policyId]=ps - - if (retcode == 200): - return Response(json.dumps(data), 200, mimetype=APPL_JSON) - else: - headers={} - headers['Location']='/A1-P/v1/policies/' + policyId - return Response(json.dumps(data), 201, headers=headers, mimetype=APPL_JSON) - -# API Function: Get a policy -def get_policy(policyId): - - extract_host_name(hosts_set, request) - - if ((r := check_modified_response()) is not None): - return r - - if policyId in policy_instances.keys(): - return Response(json.dumps(policy_instances[policyId]), 200, mimetype=APPL_JSON) - - pjson=create_problem_json(None, "The requested policy does not exist.", 404, None, policyId) - return Response(json.dumps(pjson), 404, mimetype=APPL_PROB_JSON) - -# API Function: Delete a policy -def delete_policy(policyId): - - extract_host_name(hosts_set, request) - - if ((r := check_modified_response()) is not None): - return r - - if policyId in policy_instances.keys(): - fp_previous=calcFingerprint(policy_instances[policyId]) - policy_fingerprint.pop(fp_previous) - policy_instances.pop(policyId) - policy_status.pop(policyId) - callbacks.pop(policyId) - return Response('', 204, mimetype=APPL_JSON) - - pjson=create_problem_json(None, "The policy identity does not exist.", 404, "No policy instance has been deleted.", policyId) - return Response(json.dumps(pjson), 404, mimetype=APPL_PROB_JSON) - -# API Function: Get status for a policy -def get_policy_status(policyId): - - extract_host_name(hosts_set, request) - - if ((r := check_modified_response()) is not None): - return r - - if policyId in policy_instances.keys(): - return Response(json.dumps(policy_status[policyId]), status=200, mimetype=APPL_JSON) - - pjson=create_problem_json(None, "The policy identity does not exist.", 404, "There is no existing policy instance with the identity: " + policyId, policyId) - return Response(json.dumps(pjson), 404, mimetype=APPL_PROB_JSON) - -# Helper: Create a response object if forced http response code is set -def get_forced_response(): - if (forced_settings['code'] is not None): - pjson=create_error_response(forced_settings['code']) - forced_settings['code']=None - return Response(json.dumps(pjson), pjson['status'], mimetype=APPL_PROB_JSON) - return None - -# Helper: Delay if delayed response code is set -def do_delay(): - if (forced_settings['delay'] is not None): - try: - val=int(forced_settings['delay']) - time.sleep(val) - except Exception: - return - -# Helper: Check if response shall be delayed or a forced response shall be sent -def check_modified_response(): - do_delay() - return get_forced_response() - -# Helper: Create a problem json object -def create_problem_json(type_of, title, status, detail, instance): - - error = {} - if type_of is not None: - error["type"] = type_of - if title is not None: - error["title"] = title - if status is not None: - error["status"] = status - if detail is not None: - error["detail"] = detail - if instance is not None: - error["instance"] = instance - return error - -# Helper: Create a problem json based on a generic http response code -def create_error_response(code): - - if code == '400': - return(create_problem_json(None, "Bad request", 400, "Object in payload not properly formulated or not related to the method", None)) - elif code == '404': - return(create_problem_json(None, "Not found", 404, "No resource found at the URI", None)) - elif code == '405': - return(create_problem_json(None, "Method not allowed", 405, "Method not allowed for the URI", None)) - elif code == '409': - return(create_problem_json(None, "Conflict", 409, "Request could not be processed in the current state of the resource", None)) - elif code == '429': - return(create_problem_json(None, "Too many requests", 429, "Too many requests have been sent in a given amount of time", None)) - elif code == '507': - return(create_problem_json(None, "Insufficient storage", 507, "The method could not be performed on the resource because the provider is unable to store the representation needed to successfully complete the request", None)) - elif code == '503': - return(create_problem_json(None, "Service unavailable", 503, "The provider is currently unable to handle the request due to a temporary overload", None)) - else: - return(create_problem_json(None, "Unknown", code, "Not implemented response code", None)) diff --git a/near-rt-ric-simulator/src/STD_1.1.3/callBack.py b/near-rt-ric-simulator/src/STD_1.1.3/callBack.py deleted file mode 100644 index 0e8e416c341f8e0b8d7218715199e6cf06b64bec..0000000000000000000000000000000000000000 --- a/near-rt-ric-simulator/src/STD_1.1.3/callBack.py +++ /dev/null @@ -1,43 +0,0 @@ -# ============LICENSE_START=============================================== -# Copyright (C) 2020 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END================================================= -# - -import json -from flask import Flask, request, Response - -app = Flask(__name__) #NOSONAR - -#Check alive function -@app.route('/', methods=['GET']) -def test(): - - return Response("OK", 200, mimetype='text/plain') - -#Receive status (only for testing callbacks) -#/statustest -@app.route('/statustest', methods=['POST', 'PUT']) -def statustest(): - try: - data = request.data - data = json.loads(data) - except Exception: - return Response("The status data is corrupt or missing.", 400, mimetype='text/plain') - - return Response(json.dumps(data), 200, mimetype='application/json') - -port_number = 2223 - -app.run(port=port_number, host="127.0.0.1", threaded=False) \ No newline at end of file diff --git a/near-rt-ric-simulator/src/STD_1.1.3/main.py b/near-rt-ric-simulator/src/STD_1.1.3/main.py deleted file mode 100644 index 5742791263a88a0994b47d49cf6e2d2e98b8a05f..0000000000000000000000000000000000000000 --- a/near-rt-ric-simulator/src/STD_1.1.3/main.py +++ /dev/null @@ -1,179 +0,0 @@ -# ============LICENSE_START=============================================== -# Copyright (C) 2020 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END================================================= -# - -import connexion -import json -import sys -import os -import requests - - -from pathlib import Path -from flask import Flask, escape, request, Response -from jsonschema import validate -from var_declaration import policy_instances, policy_status, callbacks, forced_settings, policy_fingerprint, hosts_set -from maincommon import check_apipath, apipath, get_supported_interfaces_response, extract_host_name - -#Constants -TEXT_PLAIN='text/plain' - -check_apipath() - -app = connexion.App(__name__, specification_dir=apipath) - -#Check alive function -@app.route('/', methods=['GET']) -def test(): - - return Response("OK", 200, mimetype=TEXT_PLAIN) - -#Return the current and all supported yamls for the this container -@app.route('/container_interfaces', methods=['GET']) -def container_interfaces(): - - return get_supported_interfaces_response() - -#Delete all created instances and status -@app.route('/deleteinstances', methods=['POST']) -def delete_instances(): - - policy_instances.clear() - policy_status.clear() - callbacks.clear() - forced_settings['code']=None - forced_settings['delay']=None - policy_fingerprint.clear() - return Response("All policy instances deleted", 200, mimetype=TEXT_PLAIN) - -#Delete all - all reset -#(same as delete_instances but kept to in order to use the same interface as other version of the simulator) -@app.route('/deleteall', methods=['POST']) -def delete_all(): - return delete_instances() - -#Set force response for one A1 response -#/forceresponse?code=<responsecode> -@app.route('/forceresponse', methods=['POST']) -def forceresponse(): - - try: - forced_settings['code']=request.args.get('code') - except Exception: - forced_settings['code']=None - return Response("Force response code: " + str(forced_settings['code']) + " set for one single A1 response", 200, mimetype=TEXT_PLAIN) - -#Set force delay response, in seconds, for all A1 responses -#/froceesponse?delay=<seconds> -@app.route('/forcedelay', methods=['POST']) -def forcedelay(): - - try: - forced_settings['delay']=request.args.get('delay') - except Exception: - forced_settings['delay']=None - return Response("Force delay: " + str(forced_settings['delay']) + " sec set for all A1 responses", 200, mimetype=TEXT_PLAIN) - - -#Set status and reason -#/status?policyid=<policyid>&status=<status>[&reason=<reason>] -@app.route('/status', methods=['PUT']) -def setstatus(): - - policy_id=request.args.get('policyid') - if (policy_id is None): - return Response('Parameter <policyid> missing in request', status=400, mimetype=TEXT_PLAIN) - if policy_id not in policy_instances.keys(): - return Response('Policyid: '+policy_id+' not found.', status=404, mimetype=TEXT_PLAIN) - status=request.args.get('status') - if (status is None): - return Response('Parameter <status> missing in request', status=400, mimetype=TEXT_PLAIN) - reason=request.args.get('reason') - ps = {} - ps["enforceStatus"] = status - msg="Status set to "+status - if (reason is not None): - ps["enforceReason"] = reason - msg=msg+" and "+reason - policy_status[policy_id] = ps - msg=msg+" for policy: " + policy_id - return Response(msg, 200, mimetype=TEXT_PLAIN) - -#Send status -#/status?policyid=<policyid> -@app.route('/sendstatus', methods=['POST']) -def sendstatus(): - policyid=request.args.get('policyid') - if (policyid is None): - return Response('Parameter <policyid> missing in request', status=400, mimetype=TEXT_PLAIN) - - if (policyid not in policy_status.keys()): - return Response('Policyid: '+policyid+' not found.', status=404, mimetype=TEXT_PLAIN) - - ps=policy_status[policyid] - cb=callbacks[policyid] - try: - resp=requests.post(cb,json=json.dumps(ps), verify=False) # NOSONAR - except: - return Response('Post status failed, could not send to: '+str(cb), status=500, mimetype=TEXT_PLAIN) - if (resp.status_code<199 & resp.status_code > 299): - return Response('Post status failed with code: '+resp.status_code, status=500, mimetype=TEXT_PLAIN) - - data = resp.json() - return Response(data, 200, mimetype='application/json') - -#Receive status (only for testing callbacks) -#/statustest -@app.route('/statustest', methods=['POST', 'PUT']) -def statustest(): - try: - data = request.data - data = json.loads(data) - except Exception: - return Response("The status data is corrupt or missing.", 400, mimetype=TEXT_PLAIN) - - return Response(json.dumps(data), 200, mimetype='application/json') - -#Metrics function -#Get a named counter -@app.route('/counter/<string:countername>', methods=['GET']) -def getcounter(countername): - - if (countername == "num_instances"): - return Response(str(len(policy_instances)), 200, mimetype=TEXT_PLAIN) - elif (countername == "num_types"): - return Response("0",200, mimetype=TEXT_PLAIN) - elif (countername == "interface"): - p=Path(os.getcwd()) - pp=p.parts - return Response(str(pp[len(pp)-1]),200, mimetype=TEXT_PLAIN) - elif (countername == "remote_hosts"): - hosts=",".join(hosts_set) - return str(hosts),200 - elif (countername == "datadelivery"): - return Response(str(0),200, mimetype=TEXT_PLAIN) - else: - return Response("Counter name: "+countername+" not found.",404, mimetype=TEXT_PLAIN) - -port_number = 2222 -if len(sys.argv) >= 2: - if isinstance(sys.argv[1], int): - port_number = sys.argv[1] - -app.add_api('STD_A1.yaml') - -if __name__ == '__main__': - app.run(port=port_number, host="127.0.0.1", threaded=False) \ No newline at end of file diff --git a/near-rt-ric-simulator/src/STD_1.1.3/var_declaration.py b/near-rt-ric-simulator/src/STD_1.1.3/var_declaration.py deleted file mode 100644 index 06b0031dc440d923809c810d9c10c260942d3d2e..0000000000000000000000000000000000000000 --- a/near-rt-ric-simulator/src/STD_1.1.3/var_declaration.py +++ /dev/null @@ -1,24 +0,0 @@ -# ============LICENSE_START=============================================== -# Copyright (C) 2020 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END================================================= -# -policy_instances = {} -policy_status = {} -callbacks = {} -forced_settings = {} -forced_settings['code']=None -forced_settings['delay']=None -policy_fingerprint={} -hosts_set=set() 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 deleted file mode 100644 index c4aa4ca6260d3648320b1b20bc7c712546ecaa6a..0000000000000000000000000000000000000000 --- a/near-rt-ric-simulator/src/STD_2.0.0/a1.py +++ /dev/null @@ -1,271 +0,0 @@ -# ============LICENSE_START=============================================== -# Copyright (C) 2020 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END================================================= -# - -import copy -import datetime -import json -import logging -import collections -import time - -from connexion import NoContent -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 - -#Constsants -APPL_JSON='application/json' -APPL_PROB_JSON='application/problem+json' - -# API Function: Get all policy type ids -def get_all_policy_types(): - - extract_host_name(hosts_set, request) - - if ((r := check_modified_response()) is not None): - return r - - res = list(policy_types.keys()) - return (res, 200) - -# API Function: Get a policy type -def get_policy_type(policyTypeId): - - extract_host_name(hosts_set, request) - - if ((r := check_modified_response()) is not None): - return r - - policy_type_id=str(policyTypeId) - - if (policy_type_id not in policy_types.keys()): - pjson=create_problem_json(None, "The policy type does not exist.", 404, None, policy_type_id) - return Response(json.dumps(pjson), 404, mimetype=APPL_PROB_JSON) - - return Response(json.dumps(policy_types[policy_type_id]), 200, mimetype=APPL_JSON) - -# API Function: Get all policy ids -def get_all_policy_identities(policyTypeId): - - extract_host_name(hosts_set, request) - - if ((r := check_modified_response()) is not None): - return r - - policy_type_id=str(policyTypeId) - - if (policy_type_id not in policy_types.keys()): - pjson=create_problem_json(None, "The policy type does not exist.", 404, None, policy_type_id) - return Response(json.dumps(pjson), 404, mimetype=APPL_PROB_JSON) - - return (list(policy_instances[policy_type_id].keys()), 200) - -# API Function: Create or update a policy -def put_policy(policyTypeId, policyId): - - extract_host_name(hosts_set, request) - - if ((r := check_modified_response()) is not None): - return r - - policy_type_id=str(policyTypeId) - policy_id=str(policyId) - - if (policy_type_id not in policy_types.keys()): - pjson=create_problem_json(None, "The policy type does not exist.", 404, None, policy_id) - return Response(json.dumps(pjson), 404, mimetype=APPL_PROB_JSON) - - try: - data = request.data - data = json.loads(data) - except Exception: - pjson=create_problem_json(None, "The policy is corrupt or missing.", 400, None, policy_id) - return Response(json.dumps(pjson), 400, mimetype=APPL_PROB_JSON) - - try: - validate(instance=data, schema=policy_types[policy_type_id]['policySchema']) - except Exception: - return (None, 400) - - fp_previous=None - retcode=201 - if policy_id in policy_instances[policy_type_id].keys(): - retcode=200 - fp_previous=calcFingerprint(policy_instances[policy_type_id][policy_id]) - else: - if (policy_id in policy_fingerprint.values()): - return (None, 400) - - fp=calcFingerprint(data) - if (fp in policy_fingerprint.keys()): - 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) - return Response(json.dumps(pjson), 400, mimetype=APPL_PROB_JSON) - - if (fp_previous is not None): - del policy_fingerprint[fp_previous] - - policy_fingerprint[fp]=policy_id - - noti=request.args.get('notificationDestination') - callbacks[policy_id]=noti - - policy_instances[policy_type_id][policy_id]=data - - if (policy_types[policy_type_id]['statusSchema'] is not None): - ps = {} - ps["enforceStatus"] = "" - ps["enforceReason"] = "" - policy_status[policy_id] = ps - - if (retcode == 200): - return Response(json.dumps(data), 200, mimetype=APPL_JSON) - else: - headers={} - headers['Location']='/A1-P/v2/policytypes/' + policy_type_id + '/policies/' + policy_id - return Response(json.dumps(data), 201, headers=headers, mimetype=APPL_JSON) - -# API Function: Get a policy -def get_policy(policyTypeId, policyId): - - extract_host_name(hosts_set, request) - - if ((r := check_modified_response()) is not None): - return r - - policy_type_id=str(policyTypeId) - policy_id=str(policyId) - - if (policy_type_id not in policy_types.keys()): - pjson=create_problem_json(None, "The policy type does not exist.", 404, None, policy_id) - return Response(json.dumps(pjson), 404, mimetype=APPL_PROB_JSON) - - if (policy_id not in policy_instances[policy_type_id].keys()): - 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) - - return Response(json.dumps(policy_instances[policy_type_id][policy_id]), 200, mimetype=APPL_JSON) - - -# API Function: Delete a policy -def delete_policy(policyTypeId, policyId): - - extract_host_name(hosts_set, request) - - if ((r := check_modified_response()) is not None): - return r - - policy_type_id=str(policyTypeId) - policy_id=str(policyId) - - if (policy_type_id not in policy_types.keys()): - pjson=create_problem_json(None, "The policy type does not exist.", 404, None, policy_id) - return Response(json.dumps(pjson), 404, mimetype=APPL_PROB_JSON) - - if (policy_id not in policy_instances[policy_type_id].keys()): - 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]) - policy_fingerprint.pop(fp_previous) - policy_instances[policy_type_id].pop(policy_id) - policy_status.pop(policy_id) - callbacks.pop(policy_id) - return Response('', 204, mimetype=APPL_JSON) - - -# API Function: Get status for a policy -def get_policy_status(policyTypeId, policyId): - - extract_host_name(hosts_set, request) - - if ((r := check_modified_response()) is not None): - return r - - policy_type_id=str(policyTypeId) - policy_id=str(policyId) - - if (policy_type_id not in policy_types.keys()): - pjson=create_problem_json(None, "The policy type does not exist.", 404, None, policy_id) - return Response(json.dumps(pjson), 404, mimetype=APPL_PROB_JSON) - - if (policy_id not in policy_instances[policy_type_id].keys()): - 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) - - return Response(json.dumps(policy_status[policy_id]), status=200, mimetype=APPL_JSON) - -# Helper: Create a response object if forced http response code is set -def get_forced_response(): - if (forced_settings['code'] is not None): - pjson=create_error_response(forced_settings['code']) - forced_settings['code']=None - return Response(json.dumps(pjson), pjson['status'], mimetype=APPL_PROB_JSON) - return None - -# Helper: Delay if delayed response code is set -def do_delay(): - if (forced_settings['delay'] is not None): - try: - val=int(forced_settings['delay']) - time.sleep(val) - except Exception: - return - -# Helper: Check if response shall be delayed or a forced response shall be sent -def check_modified_response(): - do_delay() - return get_forced_response() - -# Helper: Create a problem json object -def create_problem_json(type_of, title, status, detail, instance): - - error = {} - if type_of is not None: - error["type"] = type_of - if title is not None: - error["title"] = title - if status is not None: - error["status"] = status - if detail is not None: - error["detail"] = detail - if instance is not None: - error["instance"] = instance - return error - -# Helper: Create a problem json based on a generic http response code -def create_error_response(code): - - if code == '400': - return(create_problem_json(None, "Bad request", 400, "Object in payload not properly formulated or not related to the method", None)) - elif code == '404': - return(create_problem_json(None, "Not found", 404, "No resource found at the URI", None)) - elif code == '405': - return(create_problem_json(None, "Method not allowed", 405, "Method not allowed for the URI", None)) - elif code == '409': - return(create_problem_json(None, "Conflict", 409, "Request could not be processed in the current state of the resource", None)) - elif code == '429': - return(create_problem_json(None, "Too many requests", 429, "Too many requests have been sent in a given amount of time", None)) - elif code == '507': - return(create_problem_json(None, "Insufficient storage", 507, "The method could not be performed on the resource because the provider is unable to store the representation needed to successfully complete the request", None)) - elif code == '503': - return(create_problem_json(None, "Service unavailable", 503, "The provider is currently unable to handle the request due to a temporary overload", None)) - else: - return(create_problem_json(None, "Unknown", code, "Not implemented response code", None)) diff --git a/near-rt-ric-simulator/src/STD_2.0.0/callBack.py b/near-rt-ric-simulator/src/STD_2.0.0/callBack.py deleted file mode 100644 index 0e8e416c341f8e0b8d7218715199e6cf06b64bec..0000000000000000000000000000000000000000 --- a/near-rt-ric-simulator/src/STD_2.0.0/callBack.py +++ /dev/null @@ -1,43 +0,0 @@ -# ============LICENSE_START=============================================== -# Copyright (C) 2020 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END================================================= -# - -import json -from flask import Flask, request, Response - -app = Flask(__name__) #NOSONAR - -#Check alive function -@app.route('/', methods=['GET']) -def test(): - - return Response("OK", 200, mimetype='text/plain') - -#Receive status (only for testing callbacks) -#/statustest -@app.route('/statustest', methods=['POST', 'PUT']) -def statustest(): - try: - data = request.data - data = json.loads(data) - except Exception: - return Response("The status data is corrupt or missing.", 400, mimetype='text/plain') - - return Response(json.dumps(data), 200, mimetype='application/json') - -port_number = 2223 - -app.run(port=port_number, host="127.0.0.1", threaded=False) \ No newline at end of file diff --git a/near-rt-ric-simulator/src/STD_2.0.0/main.py b/near-rt-ric-simulator/src/STD_2.0.0/main.py deleted file mode 100644 index dcf835e5aa4ad497195fcfa3b76a18c5552ac028..0000000000000000000000000000000000000000 --- a/near-rt-ric-simulator/src/STD_2.0.0/main.py +++ /dev/null @@ -1,255 +0,0 @@ -# ============LICENSE_START=============================================== -# Copyright (C) 2020 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END================================================= -# - -import connexion -import json -import sys -import os -import requests - - -from pathlib import Path -from flask import Flask, escape, request, Response -from jsonschema import validate -from var_declaration import policy_instances, policy_types, policy_status, callbacks, forced_settings, policy_fingerprint, hosts_set, data_delivery_counter -from maincommon import check_apipath, apipath, get_supported_interfaces_response, extract_host_name - -#Constants -TEXT_PLAIN='text/plain' - -check_apipath() - -app = connexion.App(__name__, specification_dir=apipath) - -#Check alive function -@app.route('/', methods=['GET']) -def test(): - - return Response("OK", 200, mimetype=TEXT_PLAIN) - -#Return the current and all supported yamls for the this container -@app.route('/container_interfaces', methods=['GET']) -def container_interfaces(): - - return get_supported_interfaces_response() - -#Delete all created instances and status -@app.route('/deleteinstances', methods=['POST']) -def delete_instances(): - - for i in policy_instances.keys(): - policy_instances[i]={} - policy_status.clear() - callbacks.clear() - forced_settings['code']=None - forced_settings['delay']=None - policy_fingerprint.clear() - return Response("All policy instances deleted", 200, mimetype=TEXT_PLAIN) - -#Delete all - all reset -#(same as delete_instances but kept to in order to use the same interface as other version of the simulator) -@app.route('/deleteall', methods=['POST']) -def delete_all(): - - policy_instances.clear() - policy_types.clear() - policy_status.clear() - callbacks.clear() - forced_settings['code']=None - forced_settings['delay']=None - policy_fingerprint.clear() - return Response("All policy instances and types deleted", 200, mimetype=TEXT_PLAIN) - -#Load a policy type -@app.route('/policytype', methods=['PUT']) -def policytype(): - - policy_type_id=request.args.get('id') - if (policy_type_id is None): - return Response('Parameter <id> missing in request', status=400, mimetype=TEXT_PLAIN) - - try: - data = request.data - data = json.loads(data) - except Exception: - return Response("The policy type is corrupt or missing", 400, mimetype=TEXT_PLAIN) - - if ('policySchema' not in data.keys()): - return Response("The policy type atribute policySchema is missing", 400, mimetype=TEXT_PLAIN) - - retcode=201 - if (policy_type_id in policy_types.keys()): - retcode=200 - if (len(policy_instances[policy_type_id]) > 0): - return Response("The policy type already exists and instances exists", 400, mimetype=TEXT_PLAIN) - - policy_types[policy_type_id]=data - policy_instances[policy_type_id]={} - return Response("Policy type " + policy_type_id + " is OK.", retcode, mimetype=TEXT_PLAIN) - -#Delete a policy type -@app.route('/policytype', methods=['DELETE']) -def del_policytype(): - - policy_type_id=request.args.get('id') - if (policy_type_id is None): - return Response('Parameter <id> missing in request', status=400, mimetype=TEXT_PLAIN) - - if (policy_type_id in policy_types.keys()): - if (len(policy_instances[policy_type_id]) > 0): - return Response("The policy type already exists and instances exists", 400, mimetype=TEXT_PLAIN) - - del policy_types[policy_type_id] - del policy_instances[policy_type_id] - return Response("Policy type " + policy_type_id + " is OK.", 204, mimetype=TEXT_PLAIN) - - return Response("Policy type " + policy_type_id + " not found.", 204, mimetype=TEXT_PLAIN) - - -# Get all policy type ids -@app.route('/policytypes', methods=['GET']) -def get_policytype_ids(): - - return (json.dumps(list(policy_instances.keys())), 200) - - -#Set force response for one A1 response -#/forceresponse?code=<responsecode> -@app.route('/forceresponse', methods=['POST']) -def forceresponse(): - - try: - forced_settings['code']=request.args.get('code') - except Exception: - forced_settings['code']=None - return Response("Force response code: " + str(forced_settings['code']) + " set for one single A1 response", 200, mimetype=TEXT_PLAIN) - -#Set force delay response, in seconds, for all A1 responses -#/froceesponse?delay=<seconds> -@app.route('/forcedelay', methods=['POST']) -def forcedelay(): - - try: - forced_settings['delay']=request.args.get('delay') - except Exception: - forced_settings['delay']=None - return Response("Force delay: " + str(forced_settings['delay']) + " sec set for all A1 responses", 200, mimetype=TEXT_PLAIN) - - -#Set status and reason -#/status?policyid=<policyid>&status=<status>[&reason=<reason>] -@app.route('/status', methods=['PUT']) -def setstatus(): - - policy_id=request.args.get('policyid') - if (policy_id is None): - return Response('Parameter <policyid> missing in request', status=400, mimetype=TEXT_PLAIN) - if policy_id not in policy_status.keys(): - return Response('Policyid: '+policy_id+' not found.', status=404, mimetype=TEXT_PLAIN) - status=request.args.get('status') - if (status is None): - return Response('Parameter <status> missing in request', status=400, mimetype=TEXT_PLAIN) - reason=request.args.get('reason') - ps = {} - ps["enforceStatus"] = status - msg="Status set to "+status - if (reason is not None): - ps["enforceReason"] = reason - msg=msg+" and "+reason - policy_status[policy_id] = ps - msg=msg+" for policy: " + policy_id - return Response(msg, 200, mimetype=TEXT_PLAIN) - -#Send status -#/status?policyid=<policyid> -@app.route('/sendstatus', methods=['POST']) -def sendstatus(): - policyid=request.args.get('policyid') - if (policyid is None): - return Response('Parameter <policyid> missing in request', status=400, mimetype=TEXT_PLAIN) - - if (policyid not in policy_status.keys()): - return Response('Policyid: '+policyid+' not found.', status=404, mimetype=TEXT_PLAIN) - - ps=policy_status[policyid] - cb=callbacks[policyid] - try: - print("Callback url: " + str(cb)) - resp=requests.post(cb,json=json.dumps(ps), verify=False) # NOSONAR - except: - return Response('Post status failed, could not send to: '+str(cb), status=500, mimetype=TEXT_PLAIN) - if (resp.status_code<199 & resp.status_code > 299): - return Response('Post status failed with code: '+resp.status_code, status=500, mimetype=TEXT_PLAIN) - - data = resp.json() - return Response(data, 200, mimetype='application/json') - -#Receive status (only for testing callbacks) -#/statustest -@app.route('/statustest', methods=['POST', 'PUT']) -def statustest(): - try: - data = request.data - data = json.loads(data) - except Exception: - return Response("The status data is corrupt or missing.", 400, mimetype=TEXT_PLAIN) - - return Response(json.dumps(data), 200, mimetype='application/json') - -#Receive a data delivery package -#/datadelivery -@app.route('/datadelivery', methods=['POST']) -def datadelivery(): - global data_delivery_counter - try: - data = request.data - data = json.loads(data) - except Exception: - return Response("The data is corrupt or missing.", 400, mimetype=TEXT_PLAIN) - data_delivery_counter += 1 - return Response("", 200, mimetype=TEXT_PLAIN) - -#Metrics function -#Get a named counter -@app.route('/counter/<string:countername>', methods=['GET']) -def getcounter(countername): - - if (countername == "num_instances"): - return Response(str(len(policy_fingerprint)), 200, mimetype=TEXT_PLAIN) - elif (countername == "num_types"): - return Response(str(len(policy_instances)),200, mimetype=TEXT_PLAIN) - elif (countername == "interface"): - p=Path(os.getcwd()) - pp=p.parts - return Response(str(pp[len(pp)-1]),200, mimetype=TEXT_PLAIN) - elif (countername == "remote_hosts"): - hosts=",".join(hosts_set) - return str(hosts),200 - elif (countername == "datadelivery"): - return Response(str(data_delivery_counter),200, mimetype=TEXT_PLAIN) - else: - return Response("Counter name: "+countername+" not found.",404, mimetype=TEXT_PLAIN) - -port_number = 2222 -if len(sys.argv) >= 2: - if isinstance(sys.argv[1], int): - port_number = sys.argv[1] - -app.add_api('ORAN_A1-p_V2.0.0_api.yaml') - -if __name__ == '__main__': - app.run(port=port_number, host="127.0.0.1", threaded=False) \ No newline at end of file diff --git a/near-rt-ric-simulator/src/STD_2.0.0/var_declaration.py b/near-rt-ric-simulator/src/STD_2.0.0/var_declaration.py deleted file mode 100644 index 513640476c89926adb460a2ed9f3ee9c297571ee..0000000000000000000000000000000000000000 --- a/near-rt-ric-simulator/src/STD_2.0.0/var_declaration.py +++ /dev/null @@ -1,27 +0,0 @@ -# ============LICENSE_START=============================================== -# Copyright (C) 2020 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END================================================= -# - -policy_types={} -policy_instances = {} -policy_status = {} -callbacks = {} -forced_settings = {} -forced_settings['code']=None -forced_settings['delay']=None -policy_fingerprint={} -hosts_set=set() -data_delivery_counter=0 diff --git a/near-rt-ric-simulator/test/STD_1.1.3/basic_test.sh b/near-rt-ric-simulator/test/STD_1.1.3/basic_test.sh deleted file mode 100755 index 3a828d2f7bf30d12884497e3d201d2ffbf78caf7..0000000000000000000000000000000000000000 --- a/near-rt-ric-simulator/test/STD_1.1.3/basic_test.sh +++ /dev/null @@ -1,172 +0,0 @@ -#!/bin/bash - -# ============LICENSE_START=============================================== -# Copyright (C) 2020 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END================================================= -# - -# Script for basic test of the simulator. -# Run the build_and_start with the same arg as this script -if [ $# -ne 1 ]; then - echo "Usage: ./basic_test.sh nonsecure|secure" - exit 1 -fi -if [ "$1" != "nonsecure" ] && [ "$1" != "secure" ]; then - echo "Usage: ./basic_test.sh nonsecure|secure" - exit 1 -fi - -if [ $1 == "nonsecure" ]; then - #Default http port for the simulator - PORT=8085 - # Set http protocol - HTTPX="http" -else - #Default https port for the simulator - PORT=8185 - # Set https protocol - HTTPX="https" -fi - -. ../common/test_common.sh - - -echo "=== Simulator hello world ===" -RESULT="OK" -do_curl GET / 200 - -echo "=== Check used and implemented interfaces ===" -RESULT="Current interface: STD_1.1.3 All supported A1 interface yamls in this container: ['OSC_2.1.0', 'STD_1.1.3', 'STD_2.0.0']" -do_curl GET /container_interfaces 200 - -echo "=== Reset simulator instances ===" -RESULT="All policy instances deleted" -do_curl POST /deleteinstances 200 - -echo "=== Reset simulator, all ===" -RESULT="All policy instances deleted" -do_curl POST /deleteall 200 - -echo "=== API: Get policy instances, shall be empty==" -RESULT="json:[]" -do_curl GET /A1-P/v1/policies 200 - -echo "=== API: Create policy instance pi1 ===" -RESULT="json:{\"scope\": {\"ueId\": \"ue1\", \"groupId\": \"group1\", \"sliceId\": \"slice1\", \"qosId\": \"qos1\", \"cellId\": \"cell1\"}, \"statement\": {\"priorityLevel\": 5}}" -do_curl PUT /A1-P/v1/policies/pi1 201 jsonfiles/pi1.json - -echo "=== API: Update policy instance pi1 ===" -RESULT="json:{\"scope\": {\"ueId\": \"ue1\", \"groupId\": \"group1\", \"sliceId\": \"slice1\", \"qosId\": \"qos1\", \"cellId\": \"cell1\"}, \"statement\": {\"priorityLevel\": 6}}" -do_curl PUT /A1-P/v1/policies/pi1 200 jsonfiles/pi1_updated.json - -echo "=== API: Get policy instances, shall contain pi1==" -RESULT="json:[ \"pi1\" ]" -do_curl GET /A1-P/v1/policies 200 - -echo "=== API: Create policy instance pi2 (copy of pi1). Shall fail ===" -RESULT="json:{\"title\": \"The policy json already exists.\", \"status\": 400, \"instance\": \"pi2\"}" -do_curl PUT /A1-P/v1/policies/pi2 400 jsonfiles/pi1_updated.json - -echo "=== Set force response code 409. ===" -RESULT="*" -do_curl POST '/forceresponse?code=409' 200 - -echo "=== API: Get policy instances, shall fail ==" -RESULT="json:{\"title\": \"Conflict\", \"status\": 409, \"detail\": \"Request could not be processed in the current state of the resource\"}" -do_curl GET /A1-P/v1/policies 409 - -echo "=== API: Get policy status ===" -RESULT="json:{\"enforceStatus\": \"UNDEFINED\"}" -do_curl GET /A1-P/v1/policies/pi1/status 200 - -echo "=== API: Create policy instance pi2 ===" -RESULT="json:{\"scope\": {\"ueId\": \"ue2\", \"groupId\": \"group2\", \"sliceId\": \"slice2\", \"qosId\": \"qos2\", \"cellId\": \"cell2\"}, \"statement\": {\"priorityLevel\": 10}}" -do_curl PUT /A1-P/v1/policies/pi2 201 jsonfiles/pi2.json - -echo "=== API: Update policy instance pi2 ===" -RESULT="json:{\"scope\": {\"ueId\": \"ue2\", \"groupId\": \"group2\", \"sliceId\": \"slice2\", \"qosId\": \"qos2\", \"cellId\": \"cell2\"}, \"statement\": {\"priorityLevel\": 10}}" -do_curl PUT '/A1-P/v1/policies/pi2?notificationDestination=http://localhost:2223/statustest' 200 jsonfiles/pi2.json - -echo "=== API: Get policy instances, shall contain pi1 and pi2==" -RESULT="json:[ \"pi1\", \"pi2\" ]" -do_curl GET /A1-P/v1/policies 200 - -echo "=== Set force delay 10. ===" -RESULT="Force delay: 10 sec set for all A1 responses" -do_curl POST '/forcedelay?delay=10' 200 - -echo "=== API: Get policy instances, shall contain pi1 and pi2 and delayed 10 sec==" -RESULT="json:[ \"pi1\", \"pi2\" ]" -do_curl GET /A1-P/v1/policies 200 - -echo "=== Reset force delay. ===" -RESULT="Force delay: None sec set for all A1 responses" -do_curl POST /forcedelay 200 - -echo "=== API: GET policy instance pi1 ===" -RESULT="json:{\"scope\": {\"ueId\": \"ue1\", \"groupId\": \"group1\", \"sliceId\": \"slice1\", \"qosId\": \"qos1\", \"cellId\": \"cell1\"}, \"statement\": {\"priorityLevel\": 6}}" -do_curl GET /A1-P/v1/policies/pi1 200 - -echo "=== API: GET policy instance pi2 ===" -RESULT="json:{\"scope\": {\"ueId\": \"ue2\", \"groupId\": \"group2\", \"sliceId\": \"slice2\", \"qosId\": \"qos2\", \"cellId\": \"cell2\"}, \"statement\": {\"priorityLevel\": 10}}" -do_curl GET /A1-P/v1/policies/pi2 200 - -echo "=== API: DELETE policy instance pi1 ===" -RESULT="" -do_curl DELETE /A1-P/v1/policies/pi1 204 - -echo "=== API: Get policy status for pi1, shall fail===" -RESULT="json:{\"title\": \"The policy identity does not exist.\", \"status\": 404, \"detail\": \"There is no existing policy instance with the identity: pi1\", \"instance\": \"pi1\"}" -do_curl GET /A1-P/v1/policies/pi1/status 404 - -echo "=== Set status for policy instance pi2 ===" -RESULT="Status set to OK for policy: pi2" -do_curl PUT '/status?policyid=pi2&status=OK' 200 - -echo "=== API: Get policy status for pi2===" -RESULT="json:{\"enforceStatus\": \"OK\"}" -do_curl GET /A1-P/v1/policies/pi2/status 200 - -echo "=== Set status for policy instance pi2 ===" -RESULT="Status set to NOTOK and notok_reason for policy: pi2" -do_curl PUT '/status?policyid=pi2&status=NOTOK&reason=notok_reason' 200 - -echo "=== API: Get policy status for pi2 ===" -RESULT="json:{\"enforceStatus\": \"NOTOK\", \"enforceReason\": \"notok_reason\"}" -do_curl GET /A1-P/v1/policies/pi2/status 200 - -echo "=== Send status for pi2===" -RESULT="json:{\"enforceStatus\": \"NOTOK\", \"enforceReason\": \"notok_reason\"}" -do_curl POST '/sendstatus?policyid=pi2' 200 - -echo "=== Get counter: intstance ===" -RESULT="1" -do_curl GET /counter/num_instances 200 - -echo "=== Get counter: types (shall be 0)===" -RESULT="0" -do_curl GET /counter/num_types 200 - -echo "=== Get counter: interface ===" -RESULT="STD_1.1.3" -do_curl GET /counter/interface 200 - -echo "=== Get counter: remote hosts ===" -RESULT="*" -do_curl GET '/counter/remote_hosts' 200 - -echo "********************" -echo "*** All tests ok ***" -echo "********************" diff --git a/near-rt-ric-simulator/test/STD_1.1.3/build_and_start.sh b/near-rt-ric-simulator/test/STD_1.1.3/build_and_start.sh deleted file mode 100755 index 1d56487dbd817b97d3e610f77c8e6ea84aadedc8..0000000000000000000000000000000000000000 --- a/near-rt-ric-simulator/test/STD_1.1.3/build_and_start.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -# ============LICENSE_START=============================================== -# Copyright (C) 2020 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END================================================= -# - -# Script to build and start the container - -echo "Building image" -cd ../../ - -#Build the image -docker build -t a1test . - -docker stop a1StdSimulator > /dev/null 2>&1 -docker rm -f a1StdSimulator > /dev/null 2>&1 - -echo "Starting ric-sim" -#Run the container in interactive mode, unsecure port 8085, secure port 8185 -docker run -it -p 8085:8085 -p 8185:8185 -e A1_VERSION=STD_1.1.3 -e ALLOW_HTTP=true -e REMOTE_HOSTS_LOGGING=1 --volume "$PWD/certificate:/usr/src/app/cert" --name a1StdSimulator a1test diff --git a/near-rt-ric-simulator/test/STD_1.1.3/jsonfiles/pi1.json b/near-rt-ric-simulator/test/STD_1.1.3/jsonfiles/pi1.json deleted file mode 100644 index 74f22c75e8d8c667b06beed9a6aa5de427a8d294..0000000000000000000000000000000000000000 --- a/near-rt-ric-simulator/test/STD_1.1.3/jsonfiles/pi1.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "scope": { - "ueId": "ue1", - "groupId": "group1", - "sliceId": "slice1", - "qosId": "qos1", - "cellId": "cell1" - }, - "statement": { - "priorityLevel": 5 - } -} - diff --git a/near-rt-ric-simulator/test/STD_1.1.3/jsonfiles/pi1_updated.json b/near-rt-ric-simulator/test/STD_1.1.3/jsonfiles/pi1_updated.json deleted file mode 100644 index c6970ef51ad294011286425ac1002f71f53413a0..0000000000000000000000000000000000000000 --- a/near-rt-ric-simulator/test/STD_1.1.3/jsonfiles/pi1_updated.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "scope": { - "ueId": "ue1", - "groupId": "group1", - "sliceId": "slice1", - "qosId": "qos1", - "cellId": "cell1" - }, - "statement": { - "priorityLevel": 6 - } -} - diff --git a/near-rt-ric-simulator/test/STD_1.1.3/jsonfiles/pi2.json b/near-rt-ric-simulator/test/STD_1.1.3/jsonfiles/pi2.json deleted file mode 100644 index f86f1bc93dac1db114fef5648d786820fa397323..0000000000000000000000000000000000000000 --- a/near-rt-ric-simulator/test/STD_1.1.3/jsonfiles/pi2.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "scope": { - "ueId": "ue2", - "groupId": "group2", - "sliceId": "slice2", - "qosId": "qos2", - "cellId": "cell2" - }, - "statement": { - "priorityLevel": 10 - } -} \ No newline at end of file diff --git a/near-rt-ric-simulator/test/STD_2.0.0/.p.json b/near-rt-ric-simulator/test/STD_2.0.0/.p.json deleted file mode 100644 index 0967ef424bce6791893e9a57bb952f80fd536e93..0000000000000000000000000000000000000000 --- a/near-rt-ric-simulator/test/STD_2.0.0/.p.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/near-rt-ric-simulator/test/STD_2.0.0/basic_test.sh b/near-rt-ric-simulator/test/STD_2.0.0/basic_test.sh deleted file mode 100755 index 576bd5ed28fdda0864bdc0c98422cd69299baea0..0000000000000000000000000000000000000000 --- a/near-rt-ric-simulator/test/STD_2.0.0/basic_test.sh +++ /dev/null @@ -1,288 +0,0 @@ -#!/bin/bash - -# ============LICENSE_START=============================================== -# Copyright (C) 2020 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END================================================= -# - -# Script for basic test of the simulator. -# Run the build_and_start with the same arg as this script -if [ $# -ne 1 ]; then - echo "Usage: ./basic_test.sh nonsecure|secure" - exit 1 -fi -if [ "$1" != "nonsecure" ] && [ "$1" != "secure" ]; then - echo "Usage: ./basic_test.sh nonsecure|secure" - exit 1 -fi - -if [ $1 == "nonsecure" ]; then - #Default http port for the simulator - PORT=8085 - # Set http protocol - HTTPX="http" -else - #Default https port for the simulator - PORT=8185 - # Set https protocol - HTTPX="https" -fi - -. ../common/test_common.sh - - -echo "=== Simulator hello world ===" -RESULT="OK" -do_curl GET / 200 - -echo "=== Check used and implemented interfaces ===" -RESULT="Current interface: STD_2.0.0 All supported A1 interface yamls in this container: ['OSC_2.1.0', 'STD_1.1.3', 'STD_2.0.0']" -do_curl GET /container_interfaces 200 - -echo "=== Reset simulator instances ===" -RESULT="All policy instances deleted" -do_curl POST /deleteinstances 200 - -echo "=== Reset simulator, all ===" -RESULT="All policy instances and types deleted" -do_curl POST /deleteall 200 - -echo "=== Get counter: interface ===" -RESULT="STD_2.0.0" -do_curl GET /counter/interface 200 - -echo "=== Get counter: remote hosts ===" -RESULT="*" -do_curl GET /counter/remote_hosts 200 - -echo "=== Get counter: intstance ===" -RESULT="0" -do_curl GET /counter/num_instances 200 - -echo "=== Get counter: types (shall be 0)===" -RESULT="0" -do_curl GET /counter/num_types 200 - -echo "=== API: Get policy types, shall be empty array ==" -RESULT="json:[]" -do_curl GET /A1-P/v2/policytypes 200 - -echo "=== API: Get policy instances for type 1, type not found==" -RESULT="json:{\"title\": \"The policy type does not exist.\", \"status\": 404, \"instance\": \"1\"}" -do_curl GET /A1-P/v2/policytypes/1/policies 404 - -echo "=== API: Get policy instances, type not found==" -RESULT="json:{\"title\": \"The policy type does not exist.\", \"status\": 404, \"instance\": \"test\"}" -do_curl GET /A1-P/v2/policytypes/test/policies 404 - -echo "=== Put a policy type: STD_1 ===" -RESULT="Policy type STD_1 is OK." -do_curl PUT '/policytype?id=STD_1' 201 jsonfiles/std_1.json - -echo "=== Put a policy type: STD_1, again ===" -RESULT="Policy type STD_1 is OK." -do_curl PUT '/policytype?id=STD_1' 200 jsonfiles/std_1.json - -echo "=== API: Get policy type ids, shall contain type STD_1 ==" -RESULT="json:[ \"STD_1\" ]" -do_curl GET /A1-P/v2/policytypes 200 - -echo "=== Delete a policy type: STD_1 ===" -RESULT="" -do_curl DELETE '/policytype?id=STD_1' 204 - -echo "=== API: Get policy type ids, shall be empty ==" -RESULT="json:[]" -do_curl GET /A1-P/v2/policytypes 200 - -echo "=== Put a policy type: STD_1 ===" -RESULT="Policy type STD_1 is OK." -do_curl PUT '/policytype?id=STD_1' 201 jsonfiles/std_1.json - -echo "=== API: Get policy type ids, shall contain type STD_1 ==" -RESULT="json:[ \"STD_1\" ]" -do_curl GET /A1-P/v2/policytypes 200 - -echo "=== Get counter: types (shall be 1)===" -RESULT="1" -do_curl GET /counter/num_types 200 - -echo "=== API: Get policy type: STD_1 ===" -res=$(cat jsonfiles/std_1.json) -RESULT="json:$res" -do_curl GET /A1-P/v2/policytypes/STD_1 200 - -echo "=== API: Get policy instances, shall be empty==" -RESULT="json:[ ]" -do_curl GET /A1-P/v2/policytypes/STD_1/policies 200 - -echo "=== API: Create policy instance pi1 of type: STD_1 ===" -res=$(cat jsonfiles/pi1.json) -RESULT="json:$res" -do_curl PUT /A1-P/v2/policytypes/STD_1/policies/pi1 201 jsonfiles/pi1.json - -echo "=== API: Get policy instance pi1 of type: STD_1 ===" -res=$(cat jsonfiles/pi1.json) -RESULT="json:$res" -do_curl GET /A1-P/v2/policytypes/STD_1/policies/pi1 200 - -echo "=== API: Update policy instance pi1 of type: STD_1===" -res=$(cat jsonfiles/pi1.json) -RESULT="json:$res" -do_curl PUT /A1-P/v2/policytypes/STD_1/policies/pi1 200 jsonfiles/pi1.json - -echo "=== API: Update policy instance pi1 of type: STD_1===" -res=$(cat jsonfiles/pi1_updated.json) -RESULT="json:$res" -do_curl PUT /A1-P/v2/policytypes/STD_1/policies/pi1 200 jsonfiles/pi1_updated.json - -echo "=== API: Duplicate policy instance pi2 of type: STD_1===" -res=$(cat jsonfiles/pi1_updated.json) -RESULT="json:{\"title\": \"Duplicate, the policy json already exists.\", \"status\": 400, \"instance\": \"pi2\"}" -do_curl PUT /A1-P/v2/policytypes/STD_1/policies/pi2 400 jsonfiles/pi1_updated.json - -echo "=== API: Get policy instances, shall contain pi1==" -RESULT="json:[ \"pi1\" ]" -do_curl GET /A1-P/v2/policytypes/STD_1/policies 200 - -echo "=== Get counter: types (shall be 1)===" -RESULT="1" -do_curl GET /counter/num_types 200 - -echo "=== Get counter: intstance ===" -RESULT="1" -do_curl GET /counter/num_instances 200 - - -echo "=== Set force response code 409. ===" -RESULT="*" -do_curl POST '/forceresponse?code=409' 200 - -echo "=== API: Get policy instances, shall fail with 409 ==" -RESULT="json:{\"title\": \"Conflict\", \"status\": 409, \"detail\": \"Request could not be processed in the current state of the resource\"}" -do_curl GET /A1-P/v2/policytypes/STD_1/policies 409 - -echo "=== API: Get policy status ===" -RESULT="json:{\"enforceStatus\": \"\", \"enforceReason\": \"\"}" -do_curl GET /A1-P/v2/policytypes/STD_1/policies/pi1/status 200 - -echo "=== API: Create policy instance pi2 of type: STD_1 ===" -res=$(cat jsonfiles/pi2.json) -RESULT="json:$res" -do_curl PUT /A1-P/v2/policytypes/STD_1/policies/pi2 201 jsonfiles/pi2.json - -echo "=== API: Update policy instance pi2 of type: STD_1 ===" -res=$(cat jsonfiles/pi2.json) -RESULT="json:$res" -do_curl PUT '/A1-P/v2/policytypes/STD_1/policies/pi2?notificationDestination=http://localhost:2223/statustest' 200 jsonfiles/pi2.json - -echo "=== API: Get policy instances, shall contain pi1 and pi2==" -RESULT="json:[ \"pi1\", \"pi2\" ]" -do_curl GET /A1-P/v2/policytypes/STD_1/policies 200 - -echo "=== Get counter: types (shall be 1)===" -RESULT="1" -do_curl GET /counter/num_types 200 - -echo "=== Get counter: intstance ===" -RESULT="2" -do_curl GET /counter/num_instances 200 - -echo "=== Set force delay 10. ===" -RESULT="Force delay: 10 sec set for all A1 responses" -do_curl POST '/forcedelay?delay=10' 200 - -echo "=== API: Get policy instances, shall contain pi1 and pi2==" -RESULT="json:[ \"pi1\", \"pi2\" ]" -do_curl GET /A1-P/v2/policytypes/STD_1/policies 200 - -echo "=== Reset force delay. ===" -RESULT="Force delay: None sec set for all A1 responses" -do_curl POST /forcedelay 200 - -echo "=== API: Get policy instance pi1 of type: STD_1 ===" -res=$(cat jsonfiles/pi1_updated.json) -RESULT="json:$res" -do_curl GET /A1-P/v2/policytypes/STD_1/policies/pi1 200 - -echo "=== API: Get policy instance pi2 of type: STD_1 ===" -res=$(cat jsonfiles/pi2.json) -RESULT="json:$res" -do_curl GET /A1-P/v2/policytypes/STD_1/policies/pi2 200 - -echo "=== API: DELETE policy instance pi1 ===" -RESULT="" -do_curl DELETE /A1-P/v2/policytypes/STD_1/policies/pi1 204 - -echo "=== API: Get policy instances, shall contain pi1 and pi2==" -RESULT="json:[ \"pi2\" ]" -do_curl GET /A1-P/v2/policytypes/STD_1/policies 200 - -echo "=== API: Get policy status ===" -RESULT="json:{\"enforceStatus\": \"\", \"enforceReason\": \"\"}" -do_curl GET /A1-P/v2/policytypes/STD_1/policies/pi2/status 200 - -echo "=== Set status for policy instance pi2 ===" -RESULT="Status set to OK for policy: pi2" -do_curl PUT '/status?policyid=pi2&status=OK' 200 - -echo "=== API: Get policy status ===" -RESULT="json:{\"enforceStatus\": \"OK\"}" -do_curl GET /A1-P/v2/policytypes/STD_1/policies/pi2/status 200 - -echo "=== Set status for policy instance pi2 ===" -RESULT="Status set to NOTOK and notok_reason for policy: pi2" -do_curl PUT '/status?policyid=pi2&status=NOTOK&reason=notok_reason' 200 - -echo "=== API: Get policy status ===" -RESULT="json:{\"enforceStatus\": \"NOTOK\", \"enforceReason\":\"notok_reason\"}" -do_curl GET /A1-P/v2/policytypes/STD_1/policies/pi2/status 200 - -echo "=== Send status for pi2===" -RESULT="json:{\"enforceStatus\": \"NOTOK\", \"enforceReason\": \"notok_reason\"}" -do_curl POST '/sendstatus?policyid=pi2' 200 - -echo "=== Get counter: datadelivery ===" -RESULT="0" -do_curl GET /counter/datadelivery 200 - -echo "=== Send data ===" -echo "{}" > .p.json -RESULT="" -do_curl POST /datadelivery 200 .p.json - -echo "=== Get counter: datadelivery ===" -RESULT="1" -do_curl GET /counter/datadelivery 200 - -echo "=== Get counter: intstance ===" -RESULT="1" -do_curl GET /counter/num_instances 200 - -echo "=== Get counter: types (shall be 0)===" -RESULT="1" -do_curl GET /counter/num_types 200 - -echo "=== Get counter: interface ===" -RESULT="STD_2.0.0" -do_curl GET /counter/interface 200 - -echo "=== Get counter: remote hosts ===" -RESULT="*" -do_curl GET /counter/remote_hosts 200 - -echo "********************" -echo "*** All tests ok ***" -echo "********************" diff --git a/near-rt-ric-simulator/test/STD_2.0.0/build_and_start.sh b/near-rt-ric-simulator/test/STD_2.0.0/build_and_start.sh deleted file mode 100755 index 2cba8c1b46410ff603f3a5c225878f50d9f1e1e1..0000000000000000000000000000000000000000 --- a/near-rt-ric-simulator/test/STD_2.0.0/build_and_start.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -# ============LICENSE_START=============================================== -# Copyright (C) 2020 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END================================================= -# - -# Script to build and start the container - -echo "Building image" -cd ../../ - -#Build the image -docker build -t a1test . - -docker stop a1StdSimulator > /dev/null 2>&1 -docker rm -f a1StdSimulator > /dev/null 2>&1 - -echo "Starting ric-sim" -#Run the container in interactive mode, unsecure port 8085, secure port 8185 -docker run -it -p 8085:8085 -p 8185:8185 -e A1_VERSION=STD_2.0.0 -e ALLOW_HTTP=true -e REMOTE_HOSTS_LOGGING=1 --volume "$PWD/certificate:/usr/src/app/cert" --name a1StdSimulator a1test diff --git a/near-rt-ric-simulator/test/STD_2.0.0/jsonfiles/pi1.json b/near-rt-ric-simulator/test/STD_2.0.0/jsonfiles/pi1.json deleted file mode 100644 index 25247a1b276ddeaa5b0e8b69e1c9c724593eb50a..0000000000000000000000000000000000000000 --- a/near-rt-ric-simulator/test/STD_2.0.0/jsonfiles/pi1.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "scope": { - "ueId": "ue1", - "qosId": "qos1" - }, - "statement": { - "priorityLevel": 5 - } -} - diff --git a/near-rt-ric-simulator/test/STD_2.0.0/jsonfiles/pi1_updated.json b/near-rt-ric-simulator/test/STD_2.0.0/jsonfiles/pi1_updated.json deleted file mode 100644 index 7b4ada78b2b95803e97c9cb3b11896f618a6ec37..0000000000000000000000000000000000000000 --- a/near-rt-ric-simulator/test/STD_2.0.0/jsonfiles/pi1_updated.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "scope": { - "ueId": "ue1", - "qosId": "qos1" - }, - "statement": { - "priorityLevel": 6 - } -} - diff --git a/near-rt-ric-simulator/test/STD_2.0.0/jsonfiles/pi2.json b/near-rt-ric-simulator/test/STD_2.0.0/jsonfiles/pi2.json deleted file mode 100644 index 441a9cf15679a3000583ce8798e038f3148da010..0000000000000000000000000000000000000000 --- a/near-rt-ric-simulator/test/STD_2.0.0/jsonfiles/pi2.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "scope": { - "ueId": "ue2", - "qosId": "qos2" - }, - "statement": { - "priorityLevel": 5 - } -} - diff --git a/near-rt-ric-simulator/test/STD_2.0.0/jsonfiles/std_1.json b/near-rt-ric-simulator/test/STD_2.0.0/jsonfiles/std_1.json deleted file mode 100644 index 9b0c302de2af4efd920c458be0cfbbe2fb6616b2..0000000000000000000000000000000000000000 --- a/near-rt-ric-simulator/test/STD_2.0.0/jsonfiles/std_1.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "policySchema": { - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "STD_1_0.2.0", - "description": "STD 1 policy type", - "type": "object", - "properties": { - "scope": { - "type": "object", - "properties": { - "ueId": { - "type": "string" - }, - "qosId": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "ueId", - "qosId" - ] - }, - "statement": { - "type": "object", - "properties": { - "priorityLevel": { - "type": "number" - } - }, - "additionalProperties": false, - "required": [ - "priorityLevel" - ] - } - } - }, - "statusSchema": { - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "STD_1_0.2.0", - "description": "STD 1 policy type status", - "type": "object", - "properties": { - "enforceStatus": { - "type": "string" - }, - "enforceReason": { - "type": "string" - }, - "additionalProperties": false, - "required": [ - "enforceStatus" - ] - } - } -} \ No newline at end of file diff --git a/near-rt-ric-simulator/test/common/.gitignore b/near-rt-ric-simulator/test/common/.gitignore deleted file mode 100644 index bee8a64b79a99590d5303307144172cfe824fbf7..0000000000000000000000000000000000000000 --- a/near-rt-ric-simulator/test/common/.gitignore +++ /dev/null @@ -1 +0,0 @@ -__pycache__ diff --git a/near-rt-ric-simulator/tests/.gitignore b/near-rt-ric-simulator/tests/.gitignore deleted file mode 100644 index bee8a64b79a99590d5303307144172cfe824fbf7..0000000000000000000000000000000000000000 --- a/near-rt-ric-simulator/tests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -__pycache__ diff --git a/near-rt-ric-simulator/tests/test_std_1_1_3.py b/near-rt-ric-simulator/tests/test_std_1_1_3.py deleted file mode 100644 index 721d7a68e9228f67575809ba21d6e9fff191e3ce..0000000000000000000000000000000000000000 --- a/near-rt-ric-simulator/tests/test_std_1_1_3.py +++ /dev/null @@ -1,459 +0,0 @@ -# ============LICENSE_START=============================================== -# Copyright (C) 2020 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END================================================= -# - -# This test case test the STD_1.1.3 version of the simulator - -import json - -#Version of simulator -INTERFACE_VERSION="STD_1.1.3" - -from unittest_setup import SERVER_URL, HOST_IP, PORT_NUMBER, setup_env, client - -#Setup env and import paths -setup_env(INTERFACE_VERSION) - -from compare_json import compare - -def test_apis(client): - - # Simulator hello world - response=client.get(SERVER_URL) - assert response.status_code == 200 - - # Check used and implemented interfaces - response=client.get(SERVER_URL+'container_interfaces') - assert response.status_code == 200 - assert response.data == b"Current interface: STD_1.1.3 All supported A1 interface yamls in this container: ['OSC_2.1.0', 'STD_1.1.3', 'STD_2.0.0']" - - # Reset simulator instances - response=client.post(SERVER_URL+'deleteinstances') - assert response.status_code == 200 - - # Reset simulator, all - response=client.post(SERVER_URL+'deleteall') - assert response.status_code == 200 - - # API: Get policy instances, shall be empty - data_policy_get = [ ] - response=client.get(SERVER_URL+'A1-P/v1/policies') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_policy_get, result) - assert res == True - - #API: Create policy instance pi1 - data_pi1 = { - "scope": { - "ueId": "ue1", - "groupId": "group1", - "sliceId": "slice1", - "qosId": "qos1", - "cellId": "cell1" - }, - "statement": { - "priorityLevel": 5 - } - } - # header for json payload - header = { - "Content-Type" : "application/json" - } - response=client.put(SERVER_URL+'A1-P/v1/policies/pi1', headers=header, data=json.dumps(data_pi1)) - assert response.status_code == 201 - result=json.loads(response.data) - res=compare(data_pi1, result) - assert res == True - - #API: Update policy instance pi1 - data_pi1_updated = { - "scope": { - "ueId": "ue1", - "groupId": "group1", - "sliceId": "slice1", - "qosId": "qos1", - "cellId": "cell1" - }, - "statement": { - "priorityLevel": 6 - } - } - response=client.put(SERVER_URL+'A1-P/v1/policies/pi1', headers=header, data=json.dumps(data_pi1_updated)) - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_pi1_updated, result) - assert res == True - - #API: Create policy instance pi9, bad json - response=client.put(SERVER_URL+'A1-P/v1/policies/pi9', headers=header, data="test") - assert response.status_code == 400 - - # API: Get policy instances, shall contain pi1 - data_policy_get = [ "pi1" ] - response=client.get(SERVER_URL+'A1-P/v1/policies') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_policy_get, result) - assert res == True - - # API: Create policy instance pi2 (copy of pi1). Shall fail - data_create_errror_pi1 = { - "title" : "The policy json already exists.", - "status" : 400, - "instance" : "pi2" - } - response=client.put(SERVER_URL+'A1-P/v1/policies/pi2', headers=header, data=json.dumps(data_pi1_updated)) - assert response.status_code == 400 - result=json.loads(response.data) - res=compare(data_create_errror_pi1, result) - assert res == True - - # Set force response code 409. ===" - response=client.post(SERVER_URL+'forceresponse?code=409') - assert response.status_code == 200 - - # API: Get policy instances, shall fail - data_get_errror = { - "title" : "Conflict", - "status" : 409, - "detail" : "Request could not be processed in the current state of the resource" - } - response=client.get(SERVER_URL+'A1-P/v1/policies') - assert response.status_code == 409 - result=json.loads(response.data) - res=compare(data_get_errror, result) - assert res == True - - # Reset force response - response=client.post(SERVER_URL+'forceresponse') - assert response.status_code == 200 - assert response.data == b"Force response code: None set for one single A1 response" - - ### - ### Repeating the above two test for code coverage - ### - # Set force response code 400 - response=client.post(SERVER_URL+'forceresponse?code=400') - assert response.status_code == 200 - - #API: Create policy instance pi3, shall fail - data_pi3 = { - "scope": { - "ueId": "ue3" - }, - "statement": { - "priorityLevel": 5 - } - } - data_get_errror = { - "title" : "Bad request", - "status" : 400, - "detail" : "Object in payload not properly formulated or not related to the method" - } - response=client.put(SERVER_URL+'A1-P/v1/policies/pi3', headers=header, data=json.dumps(data_pi3)) - assert response.status_code == 400 - result=json.loads(response.data) - res=compare(data_get_errror, result) - assert res == True - - # Set force response code 404 - response=client.post(SERVER_URL+'forceresponse?code=404') - assert response.status_code == 200 - - # API: Get policy instance pi1, shall fail ==" - data_get_errror = { - "title" : "Not found", - "status" : 404, - "detail" : "No resource found at the URI" - } - response=client.get(SERVER_URL+'A1-P/v1/policies/pi1') - assert response.status_code == 404 - result=json.loads(response.data) - res=compare(data_get_errror, result) - assert res == True - - # Set force response code 405 - response=client.post(SERVER_URL+'forceresponse?code=405') - assert response.status_code == 200 - - # API: Delete policy instances pi1, shall fail ==" - data_get_errror = { - "title" : "Method not allowed", - "status" : 405, - "detail" : "Method not allowed for the URI" - } - response=client.delete(SERVER_URL+'A1-P/v1/policies/pi1') - assert response.status_code == 405 - result=json.loads(response.data) - res=compare(data_get_errror, result) - assert res == True - - # Set force response code 429 - response=client.post(SERVER_URL+'forceresponse?code=429') - assert response.status_code == 200 - - # API: Get policy status pi3, shall fail ==" - data_get_errror = { - "title" : "Too many requests", - "status" : 429, - "detail" : "Too many requests have been sent in a given amount of time" - } - response=client.get(SERVER_URL+'A1-P/v1/policies/pi3/status') - assert response.status_code == 429 - result=json.loads(response.data) - res=compare(data_get_errror, result) - assert res == True - - # Set force response code 507 - response=client.post(SERVER_URL+'forceresponse?code=507') - assert response.status_code == 200 - - # API: Get policy instances, shall fail - data_get_errror = { - "title" : "Insufficient storage", - "status" : 507, - "detail" : "The method could not be performed on the resource because the provider is unable to store the representation needed to successfully complete the request" - } - response=client.get(SERVER_URL+'A1-P/v1/policies') - assert response.status_code == 507 - result=json.loads(response.data) - res=compare(data_get_errror, result) - assert res == True - - # Set force response code 503. ===" - response=client.post(SERVER_URL+'forceresponse?code=503') - assert response.status_code == 200 - - # API: Get policy instances, shall fail - data_get_errror = { - "title" : "Service unavailable", - "status" : 503, - "detail" : "The provider is currently unable to handle the request due to a temporary overload" - } - response=client.get(SERVER_URL+'A1-P/v1/policies') - assert response.status_code == 503 - result=json.loads(response.data) - res=compare(data_get_errror, result) - assert res == True - - # Set force response code 555. ===" - response=client.post(SERVER_URL+'forceresponse?code=555') - assert response.status_code == 200 - - # API: Get policy instances, shall fail - data_get_errror = { - "title" : "Unknown", - "status" : "555", - "detail" : "Not implemented response code" - } - response=client.get(SERVER_URL+'A1-P/v1/policies') - assert response.status_code == 555 - result=json.loads(response.data) - res=compare(data_get_errror, result) - assert res == True - - ### - ### End of repeated test - ### - - - # API: Get policy status - data_policy_status = { - "enforceStatus" : "UNDEFINED" - } - response=client.get(SERVER_URL+'A1-P/v1/policies/pi1/status') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_policy_status, result) - assert res == True - - # API: Create policy instance pi2 - data_pi2 = { - "scope": { - "ueId": "ue2", - "groupId": "group2", - "sliceId": "slice2", - "qosId": "qos2", - "cellId": "cell2" - }, - "statement": { - "priorityLevel": 10 - } - } - response=client.put(SERVER_URL+'A1-P/v1/policies/pi2', headers=header, data=json.dumps(data_pi2)) - assert response.status_code == 201 - result=json.loads(response.data) - res=compare(data_pi2, result) - assert res == True - - - # API: Update policy instance pi2 - # Reuse same policy data - response=client.put(SERVER_URL+'A1-P/v1/policies/pi2?notificationDestination=http://'+HOST_IP+':'+PORT_NUMBER+'/statustest', headers=header, data=json.dumps(data_pi2)) - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_pi2, result) - assert res == True - - # API: Get policy instances, shall contain pi1 and pi2 - data_policy_get = [ "pi1", "pi2" ] - response=client.get(SERVER_URL+'A1-P/v1/policies') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_policy_get, result) - assert res == True - - # Set force delay 10 - response=client.post(SERVER_URL+'forcedelay?delay=10') - assert response.status_code == 200 - assert response.data == b"Force delay: 10 sec set for all A1 responses" - - # API: Get policy instances, shall contain pi1 and pi2 and delayed 10 sec - data_policy_get = [ "pi1", "pi2" ] - response=client.get(SERVER_URL+'A1-P/v1/policies') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_policy_get, result) - assert res == True - - # Reset force delay - response=client.post(SERVER_URL+'forcedelay') - assert response.status_code == 200 - assert response.data == b"Force delay: None sec set for all A1 responses" - - # API: GET policy instance pi1 - response=client.get(SERVER_URL+'A1-P/v1/policies/pi1') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_pi1_updated, result) - assert res == True - - # API: GET policy instance pi2 - response=client.get(SERVER_URL+'A1-P/v1/policies/pi2') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_pi2, result) - assert res == True - - # API: GET policy instance pi9, shall fail - response=client.get(SERVER_URL+'A1-P/v1/policies/pi9') - assert response.status_code == 404 - - # API: DELETE policy instance pi1 - response=client.delete(SERVER_URL+'A1-P/v1/policies/pi1') - assert response.status_code == 204 - - # API: DELETE policy instance pi9, shall fail - response=client.delete(SERVER_URL+'A1-P/v1/policies/pi9') - assert response.status_code == 404 - - # API: Get policy status for pi1, shall fail - data_get_errror = { - "title" : "The policy identity does not exist.", - "status" : 404, - "detail" : "There is no existing policy instance with the identity: pi1", - "instance" : "pi1" - } - response=client.get(SERVER_URL+'A1-P/v1/policies/pi1/status') - assert response.status_code == 404 - result=json.loads(response.data) - res=compare(data_get_errror, result) - assert res == True - - # Set status for policy instance pi2 - response=client.put(SERVER_URL+'status?policyid=pi2&status=OK') - assert response.status_code == 200 - - # API: Get policy status for pi2 - data_get_status = { - "enforceStatus" : "OK" - } - response=client.get(SERVER_URL+'A1-P/v1/policies/pi2/status') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_get_status, result) - assert res == True - - # Set status for policy instance pi2 - response=client.put(SERVER_URL+'status?policyid=pi2&status=NOTOK&reason=notok_reason') - assert response.status_code == 200 - - # API: Get policy status for pi2 - data_get_status = { - "enforceStatus" : "NOTOK", - "enforceReason" : "notok_reason" - } - response=client.get(SERVER_URL+'A1-P/v1/policies/pi2/status') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_get_status, result) - assert res == True - - #Found no way to test these functions - #'sendstatus' will send a http request that will fail - #since no server will receive the call - #These function is instead tested when running the bash script in the 'test' dir - # # Send status for pi2 - # response=client.post(SERVER_URL+'sendstatus?policyid=pi2') - # assert response.status_code == 200 - # result=json.loads(response.data) - # res=compare(data_get_status, result) - # assert res == True - - # # Send status, shall fail - # response=client.post(SERVER_URL+'sendstatus') - # assert response.status_code == 400 - - # # Send status pi9, shall fail - # response=client.post(SERVER_URL+'sendstatus?policyid=pi9') - # assert response.status_code == 404 - - # Set status for policy instance , shall fail - response=client.put(SERVER_URL+'status') - assert response.status_code == 400 - - # Set status for policy instance pi9, shall fail - response=client.put(SERVER_URL+'status?policyid=pi9') - assert response.status_code == 404 - - # Set status for policy instance pi2, shall fail - response=client.put(SERVER_URL+'status?policyid=pi2') - assert response.status_code == 400 - - - # Get counter: intstance - response=client.get(SERVER_URL+'counter/num_instances') - assert response.status_code == 200 - assert response.data == b"1" - - # Get counter: types (shall be 0) - response=client.get(SERVER_URL+'counter/num_types') - assert response.status_code == 200 - assert response.data == b"0" - - # Get counter: interface - response=client.get(SERVER_URL+'counter/interface') - assert response.status_code == 200 - assert response.data == b"STD_1.1.3" - - # Get counter: remote hosts - response=client.get(SERVER_URL+'counter/remote_hosts') - assert response.status_code == 200 - - # Get counter: test, shall fail - response=client.get(SERVER_URL+'counter/test') - assert response.status_code == 404 diff --git a/near-rt-ric-simulator/tests/test_std_2_0_0.py b/near-rt-ric-simulator/tests/test_std_2_0_0.py deleted file mode 100644 index d63d4c349a25148338976bb171cad1109ad578e6..0000000000000000000000000000000000000000 --- a/near-rt-ric-simulator/tests/test_std_2_0_0.py +++ /dev/null @@ -1,436 +0,0 @@ -# ============LICENSE_START=============================================== -# Copyright (C) 2020 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END================================================= -# - -# This test case test the STD_2.0.0 version of the simulator - -import json -import time - -#Version of simulator -INTERFACE_VERSION="STD_2.0.0" - -from unittest_setup import SERVER_URL, HOST_IP, PORT_NUMBER, setup_env, get_testdata_dir, client - -#Setup env and import paths -setup_env(INTERFACE_VERSION) - -from compare_json import compare - -def test_apis(client): - - testdata=get_testdata_dir() - - # Header for json payload - header = { - "Content-Type" : "application/json" - } - - # Simulator hello world - response=client.get(SERVER_URL) - assert response.status_code == 200 - - # Check used and implemented interfaces - response=client.get(SERVER_URL+'container_interfaces') - assert response.status_code == 200 - assert response.data == b"Current interface: STD_2.0.0 All supported A1 interface yamls in this container: ['OSC_2.1.0', 'STD_1.1.3', 'STD_2.0.0']" - - # Reset simulator instances - response=client.post(SERVER_URL+'deleteinstances') - assert response.status_code == 200 - - # Reset simulator, all - response=client.post(SERVER_URL+'deleteall') - assert response.status_code == 200 - - # Get counter: interface - response=client.get(SERVER_URL+'counter/interface') - assert response.status_code == 200 - assert response.data == b"STD_2.0.0" - - # Get counter: remote hosts - response=client.get(SERVER_URL+'counter/remote_hosts') - assert response.status_code == 200 - - # Get counter: intstance - response=client.get(SERVER_URL+'counter/num_instances') - assert response.status_code == 200 - assert response.data == b"0" - - # Get counter: types - response=client.get(SERVER_URL+'counter/num_types') - assert response.status_code == 200 - assert response.data == b"0" - - # API: Get policy type, shall be empty - data_response = [ ] - response=client.get(SERVER_URL+'A1-P/v2/policytypes') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_response, result) - assert res == True - - # API: Get policy instances for type 1, type not found - data_response = {"title": "The policy type does not exist.", "status": 404, "instance": "1"} - response=client.get(SERVER_URL+'A1-P/v2/policytypes/1/policies') - assert response.status_code == 404 - result=json.loads(response.data) - res=compare(data_response, result) - assert res == True - - # API: Get policy instances, type not found - data_response = {"title": "The policy type does not exist.", "status": 404, "instance": "test"} - response=client.get(SERVER_URL+'A1-P/v2/policytypes/test/policies') - assert response.status_code == 404 - result=json.loads(response.data) - res=compare(data_response, result) - assert res == True - - # Put a policy type: STD_1 - with open(testdata+'std_1.json') as json_file: - data_response = b"Policy type STD_1 is OK." - json_payload=json.load(json_file) - response=client.put(SERVER_URL+'policytype?id=STD_1', headers=header, data=json.dumps(json_payload)) - assert response.status_code == 201 - assert data_response == response.data - - # Put a policy type: STD_1, again - with open(testdata+'std_1.json') as json_file: - data_response = b"Policy type STD_1 is OK." - json_payload=json.load(json_file) - response=client.put(SERVER_URL+'policytype?id=STD_1', headers=header, data=json.dumps(json_payload)) - assert response.status_code == 200 - assert data_response == response.data - - # API: Get policy type ids, shall contain type STD_1 - data_response = [ "STD_1" ] - response=client.get(SERVER_URL+'A1-P/v2/policytypes') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_response, result) - assert res == True - - # Delete a policy type: STD_1 - data_response = b"" - response=client.delete(SERVER_URL+'policytype?id=STD_1') - assert response.status_code == 204 - assert data_response == response.data - - # API: Get policy type ids, shall be empty - data_response = [ ] - response=client.get(SERVER_URL+'A1-P/v2/policytypes') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_response, result) - assert res == True - - # Put a policy type: STD_1 - with open(testdata+'std_1.json') as json_file: - data_response = b"Policy type STD_1 is OK." - json_payload=json.load(json_file) - response=client.put(SERVER_URL+'policytype?id=STD_1', headers=header, data=json.dumps(json_payload)) - assert response.status_code == 201 - assert data_response == response.data - - # API: Get policy type ids, shall contain type STD_1 - data_response = [ "STD_1" ] - response=client.get(SERVER_URL+'A1-P/v2/policytypes') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_response, result) - assert res == True - - # Get counter: types (shall be 1) - response=client.get(SERVER_URL+'counter/num_types') - assert response.status_code == 200 - assert response.data == b"1" - - # API: Get policy type: STD_1 - with open(testdata+'std_1.json') as json_file: - data_response = json.load(json_file) - response=client.get(SERVER_URL+'A1-P/v2/policytypes/STD_1') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_response, result) - assert res == True - - # API: API: Get policy instances, shall be empty - data_response = [] - response=client.get(SERVER_URL+'A1-P/v2/policytypes/STD_1/policies') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_response, result) - assert res == True - - # API: Create policy instance pi1 of type: STD_1 - with open(testdata+'pi1.json') as json_file: - json_payload=json.load(json_file) - response=client.put(SERVER_URL+'A1-P/v2/policytypes/STD_1/policies/pi1', headers=header, data=json.dumps(json_payload)) - assert response.status_code == 201 - result=json.loads(response.data) - res=compare(json_payload, result) - assert res == True - - # API: API: Get policy instance pi1 of type: STD_1 - with open(testdata+'pi1.json') as json_file: - data_response = json.load(json_file) - response=client.get(SERVER_URL+'A1-P/v2/policytypes/STD_1/policies/pi1') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_response, result) - assert res == True - - # API: Update policy instance pi1 of type: STD_1 - with open(testdata+'pi1.json') as json_file: - json_payload=json.load(json_file) - response=client.put(SERVER_URL+'A1-P/v2/policytypes/STD_1/policies/pi1', headers=header, data=json.dumps(json_payload)) - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(json_payload, result) - assert res == True - - # API: Update policy instance pi1 of type: STD_1 - with open(testdata+'pi1_updated.json') as json_file: - json_payload=json.load(json_file) - response=client.put(SERVER_URL+'A1-P/v2/policytypes/STD_1/policies/pi1', headers=header, data=json.dumps(json_payload)) - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(json_payload, result) - assert res == True - - # API: Duplicate policy instance pi2 of type: STD_1 - with open(testdata+'pi1_updated.json') as json_file: - data_response = {"title": "Duplicate, the policy json already exists.", "status": 400, "instance": "pi2"} - json_payload=json.load(json_file) - response=client.put(SERVER_URL+'A1-P/v2/policytypes/STD_1/policies/pi2', headers=header, data=json.dumps(json_payload)) - assert response.status_code == 400 - result=json.loads(response.data) - res=compare(data_response, result) - assert res == True - - # API: Get policy instances, shall contain pi1 - data_response = ["pi1"] - response=client.get(SERVER_URL+'A1-P/v2/policytypes/STD_1/policies') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_response, result) - assert res == True - - # Get counter: intstance - response=client.get(SERVER_URL+'counter/num_instances') - assert response.status_code == 200 - assert response.data == b"1" - - # Get counter: types - response=client.get(SERVER_URL+'counter/num_types') - assert response.status_code == 200 - assert response.data == b"1" - - # Set force response code 409. ===" - response=client.post(SERVER_URL+'forceresponse?code=409') - assert response.status_code == 200 - - # API: Get policy instances, shall fail - data_response = {"title" : "Conflict", "status" : 409, "detail" : "Request could not be processed in the current state of the resource"} - response=client.get(SERVER_URL+'A1-P/v2/policytypes/STD_1/policies') - assert response.status_code == 409 - result=json.loads(response.data) - res=compare(data_response, result) - assert res == True - - # API: API: Get policy status - data_response = {"enforceStatus" : "", "enforceReason" : ""} - response=client.get(SERVER_URL+'A1-P/v2/policytypes/STD_1/policies/pi1/status') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_response, result) - assert res == True - - # API: Create policy instance pi2 of type: STD_1 - with open(testdata+'pi2.json') as json_file: - json_payload=json.load(json_file) - response=client.put(SERVER_URL+'A1-P/v2/policytypes/STD_1/policies/pi2', headers=header, data=json.dumps(json_payload)) - assert response.status_code == 201 - result=json.loads(response.data) - res=compare(json_payload, result) - assert res == True - - # API: Update policy instance pi2 of type: STD_1 - with open(testdata+'pi2.json') as json_file: - json_payload=json.load(json_file) - response=client.put(SERVER_URL+'A1-P/v2/policytypes/STD_1/policies/pi2', headers=header, data=json.dumps(json_payload)) - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(json_payload, result) - assert res == True - - # API: Get policy instances, shall contain pi1 and pi2 - data_response = ["pi1","pi2"] - response=client.get(SERVER_URL+'A1-P/v2/policytypes/STD_1/policies') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_response, result) - assert res == True - - # Get counter: intstance - response=client.get(SERVER_URL+'counter/num_instances') - assert response.status_code == 200 - assert response.data == b"2" - - # Get counter: types - response=client.get(SERVER_URL+'counter/num_types') - assert response.status_code == 200 - assert response.data == b"1" - - # Set force delay 10 - response=client.post(SERVER_URL+'forcedelay?delay=10') - assert response.status_code == 200 - assert response.data == b"Force delay: 10 sec set for all A1 responses" - - #start time stamp - start=time.time() - - # API: Get policy instances, shall contain pi1 and pi2 and delayed 10 sec - data_response = ["pi1","pi2"] - response=client.get(SERVER_URL+'A1-P/v2/policytypes/STD_1/policies') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_response, result) - assert res == True - - end=time.time() - - assert (end-start) > 9 - - # Reset force delay - response=client.post(SERVER_URL+'forcedelay') - assert response.status_code == 200 - assert response.data == b"Force delay: None sec set for all A1 responses" - - # API: API: Get policy instance pi1 of type: STD_1 - with open(testdata+'pi1_updated.json') as json_file: - data_response = json.load(json_file) - response=client.get(SERVER_URL+'A1-P/v2/policytypes/STD_1/policies/pi1') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_response, result) - assert res == True - - # API: API: Get policy instance pi2 of type: STD_1 - with open(testdata+'pi2.json') as json_file: - data_response = json.load(json_file) - response=client.get(SERVER_URL+'A1-P/v2/policytypes/STD_1/policies/pi2') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_response, result) - assert res == True - - # API: DELETE policy instance pi1 - data_response = b"" - response=client.delete(SERVER_URL+'A1-P/v2/policytypes/STD_1/policies/pi1') - assert response.status_code == 204 - assert data_response == response.data - - # API: Get policy instances, shall contain pi2 - data_response = ["pi2"] - response=client.get(SERVER_URL+'A1-P/v2/policytypes/STD_1/policies') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_response, result) - assert res == True - - # API: API: Get policy status - data_response = {"enforceStatus" : "", "enforceReason" : ""} - response=client.get(SERVER_URL+'A1-P/v2/policytypes/STD_1/policies/pi2/status') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_response, result) - assert res == True - - # Set status for policy instance pi2 - response=client.put(SERVER_URL+'status?policyid=pi2&status=OK') - assert response.status_code == 200 - - # API: API: Get policy status - data_response = {"enforceStatus" : "OK"} - response=client.get(SERVER_URL+'A1-P/v2/policytypes/STD_1/policies/pi2/status') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_response, result) - print(response.data) - assert res == True - - # Set status for policy instance pi2 - response=client.put(SERVER_URL+'status?policyid=pi2&status=NOTOK&reason=notok_reason') - assert response.status_code == 200 - - # API: API: Get policy status - data_response = {"enforceStatus" : "NOTOK", "enforceReason" : "notok_reason"} - response=client.get(SERVER_URL+'A1-P/v2/policytypes/STD_1/policies/pi2/status') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_response, result) - assert res == True - - - # #Found no way to test these functions - # #'sendstatus' will send a http request that will fail - # #since no server will receive the call - # #These function is instead tested when running the bash script in the 'test' dir - # # # Send status for pi2 - # # response=client.post(SERVER_URL+'sendstatus?policyid=pi2') - # # assert response.status_code == 200 - # # result=json.loads(response.data) - # # res=compare(data_get_status, result) - # # assert res == True - - # # # Send status, shall fail - # # response=client.post(SERVER_URL+'sendstatus') - # # assert response.status_code == 400 - - # Get counter: data_delivery - response=client.get(SERVER_URL+'counter/datadelivery') - assert response.status_code == 200 - assert response.data == b"0" - - # Send data - json_payload={} - response=client.post(SERVER_URL+'datadelivery', headers=header, data=json.dumps(json_payload)) - assert response.status_code == 200 - - # Get counter: data_delivery - response=client.get(SERVER_URL+'counter/datadelivery') - assert response.status_code == 200 - assert response.data == b"1" - - # Get counter: interface - response=client.get(SERVER_URL+'counter/interface') - assert response.status_code == 200 - assert response.data == b"STD_2.0.0" - - # Get counter: remote hosts - response=client.get(SERVER_URL+'counter/remote_hosts') - assert response.status_code == 200 - - # Get counter: intstance - response=client.get(SERVER_URL+'counter/num_instances') - assert response.status_code == 200 - assert response.data == b"1" - - # Get counter: types - response=client.get(SERVER_URL+'counter/num_types') - assert response.status_code == 200 - assert response.data == b"1" \ No newline at end of file diff --git a/near-rt-ric-simulator/.gitattributes b/near-rt-ric/.gitattributes similarity index 100% rename from near-rt-ric-simulator/.gitattributes rename to near-rt-ric/.gitattributes diff --git a/near-rt-ric-simulator/.gitignore b/near-rt-ric/.gitignore similarity index 100% rename from near-rt-ric-simulator/.gitignore rename to near-rt-ric/.gitignore diff --git a/near-rt-ric-simulator/Dockerfile b/near-rt-ric/Dockerfile similarity index 100% rename from near-rt-ric-simulator/Dockerfile rename to near-rt-ric/Dockerfile diff --git a/near-rt-ric-simulator/LICENSES.txt b/near-rt-ric/LICENSES.txt similarity index 100% rename from near-rt-ric-simulator/LICENSES.txt rename to near-rt-ric/LICENSES.txt diff --git a/near-rt-ric-simulator/README.md b/near-rt-ric/README.md similarity index 100% rename from near-rt-ric-simulator/README.md rename to near-rt-ric/README.md diff --git a/near-rt-ric-simulator/api/OSC_2.1.0/openapi.yaml b/near-rt-ric/api/OSC_2.1.0/openapi.yaml similarity index 90% rename from near-rt-ric-simulator/api/OSC_2.1.0/openapi.yaml rename to near-rt-ric/api/OSC_2.1.0/openapi.yaml index 828a6bf79d335688e2590c181865226174f5bd2f..32a3afd87996e04f2950bb34bf2771d0b8be6ca1 100644 --- a/near-rt-ric-simulator/api/OSC_2.1.0/openapi.yaml +++ b/near-rt-ric/api/OSC_2.1.0/openapi.yaml @@ -17,15 +17,28 @@ # ================================================================================== openapi: 3.0.0 info: - version: 2.1.0 - title: RIC A1 + title: Near RT-RIC A1 Mediator for Policy Management Services. + version: 2.1.1 + description: | + API for A1-P Policy Management Service Near RT-RIC. + © 2023, S. Kumar Chaudhary. + All rights reserved. +externalDocs: + description: 'As per ORAN Specification version-1, A1 interface Application protocol' + url: 'https://orandownloadsweb.azurewebsites.net/specifications' +servers: + - url: '{apiRoot}/A1AP/v2' + variables: + apiRoot: + default: 'https://example.com' + description: 'apiRoot as defined in clause 4.2.1 in ORAN-WG2.A1.AP' paths: '/a1-p/healthcheck': get: description: > - Perform a healthcheck on a1 + Perform a healthcheck on A1 interface tags: - - A1 Mediator + - A1 Mediator-Healthcheck Interface operationId: a1.get_healthcheck responses: 200: @@ -37,7 +50,7 @@ paths: get: description: "Get a list of all registered policy type ids" tags: - - A1 Mediator + - A1 Mediator- Get All Policy Types Interface operationId: a1.get_all_policy_types responses: 200: @@ -63,7 +76,7 @@ paths: description: > Get this policy type tags: - - A1 Mediator + - A1 Mediator- Individual Policy Type Interfaces operationId: a1.get_policy_type responses: '200': @@ -81,7 +94,7 @@ paths: description: > Delete this policy type. Can only be performed if there are no instances of this type tags: - - A1 Mediator + - A1 Mediator- Individual Policy Type Interfaces operationId: a1.delete_policy_type responses: '204': @@ -102,7 +115,7 @@ paths: Replace is not currently allowed; to replace, for now do a DELETE and then a PUT again. tags: - - A1 Mediator + - A1 Mediator- Individual Policy Type Interfaces operationId: a1.create_policy_type requestBody: content: @@ -157,7 +170,7 @@ paths: get: description: "get a list of all policy instance ids for this policy type id" tags: - - A1 Mediator + - A1 Mediator- Individual Policy Type Instance Interface operationId: a1.get_all_policy_identities responses: 200: @@ -192,7 +205,7 @@ paths: Retrieve the policy instance tags: - - A1 Mediator + - A1 Mediator- Individual Policy Type Instance Interfaces operationId: a1.get_policy_instance responses: '200': @@ -214,7 +227,7 @@ paths: Delete this policy instance tags: - - A1 Mediator + - A1 Mediator- Individual Policy Type Instance Interfaces operationId: a1.delete_policy_instance responses: '202': @@ -232,7 +245,7 @@ paths: The schema of the PUT body is defined by the create_schema field of the policy type. tags: - - A1 Mediator + - A1 Mediator- Individual Policy Type Instance Interfaces operationId: a1.create_or_replace_policy_instance requestBody: content: @@ -282,7 +295,7 @@ paths: NOT IN EFFECT is returned otherwise If a policy instance is successfully deleted, this endpoint will return a 404 (not a 200) tags: - - A1 Mediator + - A1 Mediator- Individual Policy Type Instances Services Status operationId: a1.get_policy_instance_status responses: '200': diff --git a/near-rt-ric-simulator/certificate/cert.crt b/near-rt-ric/certificate/cert.crt similarity index 100% rename from near-rt-ric-simulator/certificate/cert.crt rename to near-rt-ric/certificate/cert.crt diff --git a/near-rt-ric-simulator/certificate/generate_cert_and_key.sh b/near-rt-ric/certificate/generate_cert_and_key.sh similarity index 100% rename from near-rt-ric-simulator/certificate/generate_cert_and_key.sh rename to near-rt-ric/certificate/generate_cert_and_key.sh diff --git a/near-rt-ric-simulator/certificate/key.crt b/near-rt-ric/certificate/key.crt similarity index 100% rename from near-rt-ric-simulator/certificate/key.crt rename to near-rt-ric/certificate/key.crt diff --git a/near-rt-ric-simulator/certificate/pass b/near-rt-ric/certificate/pass similarity index 100% rename from near-rt-ric-simulator/certificate/pass rename to near-rt-ric/certificate/pass diff --git a/near-rt-ric-simulator/container-tag.yaml b/near-rt-ric/container-tag.yaml similarity index 100% rename from near-rt-ric-simulator/container-tag.yaml rename to near-rt-ric/container-tag.yaml diff --git a/near-rt-ric-simulator/nginx.conf b/near-rt-ric/nginx.conf similarity index 100% rename from near-rt-ric-simulator/nginx.conf rename to near-rt-ric/nginx.conf diff --git a/near-rt-ric-simulator/src/OSC_2.1.0/.gitignore b/near-rt-ric/src/OSC_2.1.0/.gitignore similarity index 100% rename from near-rt-ric-simulator/src/OSC_2.1.0/.gitignore rename to near-rt-ric/src/OSC_2.1.0/.gitignore diff --git a/near-rt-ric-simulator/src/OSC_2.1.0/a1.py b/near-rt-ric/src/OSC_2.1.0/a1.py similarity index 100% rename from near-rt-ric-simulator/src/OSC_2.1.0/a1.py rename to near-rt-ric/src/OSC_2.1.0/a1.py diff --git a/near-rt-ric-simulator/src/OSC_2.1.0/main.py b/near-rt-ric/src/OSC_2.1.0/main.py similarity index 99% rename from near-rt-ric-simulator/src/OSC_2.1.0/main.py rename to near-rt-ric/src/OSC_2.1.0/main.py index e0766d86468f965a3993a8a3aae817d720073c88..e0be6e2f5f5c42255aa37b0894e75bf7c5293aac 100644 --- a/near-rt-ric-simulator/src/OSC_2.1.0/main.py +++ b/near-rt-ric/src/OSC_2.1.0/main.py @@ -132,7 +132,6 @@ def del_policytype(): return Response("Policy type " + policy_type_id + " not found.", 204, mimetype=TEXT_PLAIN) - # Get all policy type ids @app.route('/policytypes', methods=['GET']) def get_policytype_ids(): diff --git a/near-rt-ric-simulator/src/OSC_2.1.0/var_declaration.py b/near-rt-ric/src/OSC_2.1.0/var_declaration.py similarity index 100% rename from near-rt-ric-simulator/src/OSC_2.1.0/var_declaration.py rename to near-rt-ric/src/OSC_2.1.0/var_declaration.py diff --git a/near-rt-ric-simulator/src/STD_1.1.3/.gitignore b/near-rt-ric/src/common/.gitignore similarity index 100% rename from near-rt-ric-simulator/src/STD_1.1.3/.gitignore rename to near-rt-ric/src/common/.gitignore diff --git a/near-rt-ric-simulator/src/common/maincommon.py b/near-rt-ric/src/common/maincommon.py similarity index 100% rename from near-rt-ric-simulator/src/common/maincommon.py rename to near-rt-ric/src/common/maincommon.py diff --git a/near-rt-ric-simulator/src/common/utils.py b/near-rt-ric/src/common/utils.py similarity index 100% rename from near-rt-ric-simulator/src/common/utils.py rename to near-rt-ric/src/common/utils.py diff --git a/near-rt-ric-simulator/src/start.sh b/near-rt-ric/src/start.sh similarity index 100% rename from near-rt-ric-simulator/src/start.sh rename to near-rt-ric/src/start.sh diff --git a/near-rt-ric-simulator/test/OSC_2.1.0/basic_test.sh b/near-rt-ric/test/a1_2.1.1/basic_test.sh similarity index 78% rename from near-rt-ric-simulator/test/OSC_2.1.0/basic_test.sh rename to near-rt-ric/test/a1_2.1.1/basic_test.sh index bc2413d17c1a6c49751e995deb937a3950f942f1..e86178a6db4c9046b3cda76c6e9a142bee688195 100755 --- a/near-rt-ric-simulator/test/OSC_2.1.0/basic_test.sh +++ b/near-rt-ric/test/a1_2.1.1/basic_test.sh @@ -47,7 +47,7 @@ RESULT="OK" do_curl GET / 200 echo "=== Check used and implemented interfaces ===" -RESULT="Current interface: OSC_2.1.0 All supported A1 interface yamls in this container: ['OSC_2.1.0', 'STD_1.1.3', 'STD_2.0.0']" +RESULT="Current interface: OSC_2.1.0 All supported A1 interface yamls in this container: ['OSC_2.1.0']" do_curl GET /container_interfaces 200 echo "=== Reset simulator instances ===" @@ -60,67 +60,67 @@ do_curl POST /deleteall 200 echo "=== API: Healthcheck ===" RESULT="" -do_curl GET /a1-p/healthcheck 200 +do_curl GET /A1AP/v2/a1-p/healthcheck 200 echo "=== API: Get policy types, shall be empty array ==" RESULT="json:[]" -do_curl GET /a1-p/policytypes 200 +do_curl GET /A1AP/v2/a1-p/policytypes 200 echo "=== API: Delete a policy type, shall fail ==" RESULT="" -do_curl DELETE /a1-p/policytypes/1 404 +do_curl DELETE /A1AP/v2/a1-p/policytypes/1 404 echo "=== API: Get policy instances for type 1, shall fail ==" RESULT="" -do_curl GET /a1-p/policytypes/1/policies 404 +do_curl GET /A1AP/v2/a1-p/policytypes/1/policies 404 echo "=== API: Put a policy type: 1 ===" RESULT="" -do_curl PUT /a1-p/policytypes/1 201 jsonfiles/pt1.json +do_curl PUT /A1AP/v2/a1-p/policytypes/1 201 jsonfiles/pt1.json echo "=== API: Put a policy type: 1, again ===" RESULT="" -do_curl PUT /a1-p/policytypes/1 201 jsonfiles/pt1.json +do_curl PUT /A1AP/v2/a1-p/policytypes/1 201 jsonfiles/pt1.json echo "=== API: Delete a policy type: 1 ===" RESULT="" -do_curl DELETE /a1-p/policytypes/1 204 +do_curl DELETE /A1AP/v2/a1-p/policytypes/1 204 echo "=== API: Get policy type ids, shall be empty ==" RESULT="json:[]" -do_curl GET /a1-p/policytypes 200 +do_curl GET /A1AP/v2/a1-p/policytypes 200 echo "=== API: Load a policy type: 1 ===" RESULT="" -do_curl PUT /a1-p/policytypes/1 201 jsonfiles/pt1.json +do_curl PUT /A1AP/v2/a1-p/policytypes/1 201 jsonfiles/pt1.json echo "=== API: Get policy type ids, shall contain type 1 ==" RESULT="json:[ 1 ]" -do_curl GET /a1-p/policytypes 200 +do_curl GET /A1AP/v2/a1-p/policytypes 200 echo "=== API: Get instances for type 1, shall be empty ===" RESULT="json:[]" -do_curl GET '/a1-p/policytypes/1/policies' 200 +do_curl GET '/A1AP/v2/a1-p/policytypes/1/policies' 200 echo "=== API: Create policy instance pi1 of type: 1 ===" RESULT="" -do_curl PUT '/a1-p/policytypes/1/policies/pi1' 202 jsonfiles/pi1.json +do_curl PUT '/A1AP/v2/a1-p/policytypes/1/policies/pi1' 202 jsonfiles/pi1.json echo "=== API: Update policy instance pi1 of type: 1 ===" RESULT="" -do_curl PUT '/a1-p/policytypes/1/policies/pi1' 202 jsonfiles/pi1.json +do_curl PUT '/A1AP/v2/a1-p/policytypes/1/policies/pi1' 202 jsonfiles/pi1.json echo "=== API: Load a policy type: 1, shall fail ===" RESULT="" -do_curl PUT /a1-p/policytypes/1 400 jsonfiles/pt1.json +do_curl PUT /A1AP/v2/a1-p/policytypes/1 400 jsonfiles/pt1.json echo "=== API: Get instances for type 1, shall contain pi1 ===" RESULT="json:[ \"pi1\" ]" -do_curl GET '/a1-p/policytypes/1/policies' 200 +do_curl GET '/A1AP/v2/a1-p/policytypes/1/policies' 200 echo "=== API: Create policy instance pi2 (copy of pi1) of type: 1. Shall fail ===" RESULT="" -do_curl PUT '/a1-p/policytypes/1/policies/pi2' 400 jsonfiles/pi1.json +do_curl PUT '/A1AP/v2/a1-p/policytypes/1/policies/pi2' 400 jsonfiles/pi1.json echo "=== Set force response code 401. ===" RESULT="*" @@ -128,11 +128,11 @@ do_curl POST '/forceresponse?code=401' 200 echo "=== API: Get policy type 1. Shall fail with forced code ===" RESULT="" -do_curl GET '/a1-p/policytypes/1' 401 +do_curl GET '/A1AP/v2/a1-p/policytypes/1' 401 echo "=== API: Get policy status ===" RESULT="json:{\"instance_status\": \"NOT IN EFFECT\", \"has_been_deleted\": \"false\", \"created_at\": \"????\"}" -do_curl GET '/a1-p/policytypes/1/policies/pi1/status' 200 +do_curl GET '/A1AP/v2/a1-p/policytypes/1/policies/pi1/status' 200 echo "=== Load a policy type: 2 ===" RESULT="Policy type 2 is OK." @@ -144,7 +144,7 @@ do_curl PUT '/policytype?id=2' 200 jsonfiles/pt2.json echo "=== API: Get policy type ids, shall contain type 1 and 2 ==" RESULT="json:[ 1, 2 ]" -do_curl GET /a1-p/policytypes 200 +do_curl GET /A1AP/v2/a1-p/policytypes 200 echo "=== Get policy type ids, shall contain type 1 and 2 ==" RESULT="json:[\"1\", \"2\"]" @@ -152,7 +152,7 @@ do_curl GET /policytypes 200 echo "=== API: Get policy type 2 ==" RESULT="json:{\"name\": \"pt2\", \"description\": \"pt2 policy type\", \"policy_type_id\": 2, \"create_schema\": {\"\$schema\": \"http://json-schema.org/draft-07/schema#\", \"title\": \"STD_QoSNudging_0.2.0\", \"description\": \"QoS policy type\", \"type\": \"object\", \"properties\": {\"scope\": {\"type\": \"object\", \"properties\": {\"ueId\": {\"type\": \"string\"}, \"qosId\": {\"type\": \"string\"}}, \"additionalProperties\": false, \"required\": [\"ueId\", \"qosId\"]}, \"statement\": {\"type\": \"object\", \"properties\": {\"priorityLevel\": {\"type\": \"number\"}}, \"additionalProperties\": false, \"required\": [\"priorityLevel\"]}}}}" -do_curl GET /a1-p/policytypes/2 200 +do_curl GET /A1AP/v2/a1-p/policytypes/2 200 echo "=== Delete policy type: 2 ===" RESULT="" @@ -160,7 +160,7 @@ do_curl DELETE '/policytype?id=2' 204 jsonfiles/pt2.json echo "=== API: Get policy type ids, shall contain type 1 ==" RESULT="json:[ 1 ]" -do_curl GET /a1-p/policytypes 200 +do_curl GET /A1AP/v2/a1-p/policytypes 200 echo "=== Load a policy type: 2 ===" RESULT="Policy type 2 is OK." @@ -168,39 +168,39 @@ do_curl PUT '/policytype?id=2' 201 jsonfiles/pt2.json echo "=== API: Get policy type 2 ==" RESULT="json:{\"name\": \"pt2\", \"description\": \"pt2 policy type\", \"policy_type_id\": 2, \"create_schema\": {\"\$schema\": \"http://json-schema.org/draft-07/schema#\", \"title\": \"STD_QoSNudging_0.2.0\", \"description\": \"QoS policy type\", \"type\": \"object\", \"properties\": {\"scope\": {\"type\": \"object\", \"properties\": {\"ueId\": {\"type\": \"string\"}, \"qosId\": {\"type\": \"string\"}}, \"additionalProperties\": false, \"required\": [\"ueId\", \"qosId\"]}, \"statement\": {\"type\": \"object\", \"properties\": {\"priorityLevel\": {\"type\": \"number\"}}, \"additionalProperties\": false, \"required\": [\"priorityLevel\"]}}}}" -do_curl GET /a1-p/policytypes/2 200 +do_curl GET /A1AP/v2/a1-p/policytypes/2 200 echo "=== API: Get instances for type 2, shall be empty ===" RESULT="json:[]" -do_curl GET '/a1-p/policytypes/2/policies' 200 +do_curl GET '/A1AP/v2/a1-p/policytypes/2/policies' 200 echo "=== API: Create policy instance pi1 of type: 2, shall fail===" RESULT="" -do_curl PUT '/a1-p/policytypes/2/policies/pi1' 400 jsonfiles/pi1.json +do_curl PUT '/A1AP/v2/a1-p/policytypes/2/policies/pi1' 400 jsonfiles/pi1.json echo "=== API: Create policy instance pi2 of type: 2. Missing param, shall fail. ===" RESULT="" -do_curl PUT '/a1-p/policytypes/2/policies/pi2' 400 jsonfiles/pi2_missing_param.json +do_curl PUT '/A1AP/v2/a1-p/policytypes/2/policies/pi2' 400 jsonfiles/pi2_missing_param.json echo "=== API: Create policy instance pi2 of type: 2 ===" RESULT="" -do_curl PUT '/a1-p/policytypes/2/policies/pi2' 202 jsonfiles/pi2.json +do_curl PUT '/A1AP/v2/a1-p/policytypes/2/policies/pi2' 202 jsonfiles/pi2.json echo "=== API: Update policy instance pi2 of type: 2 ===" RESULT="" -do_curl PUT '/a1-p/policytypes/2/policies/pi2' 202 jsonfiles/pi2.json +do_curl PUT '/A1AP/v2/a1-p/policytypes/2/policies/pi2' 202 jsonfiles/pi2.json echo "=== API: Get instances for type 1, shall contain pi1 ===" RESULT="json:[ \"pi1\" ]" -do_curl GET '/a1-p/policytypes/1/policies' jsonfiles/200 +do_curl GET '/A1AP/v2/a1-p/policytypes/1/policies' jsonfiles/200 echo "=== API: Get instances for type 2, shall contain pi2 ===" RESULT="json:[ \"pi2\" ]" -do_curl GET '/a1-p/policytypes/2/policies' 200 +do_curl GET '/A1AP/v2/a1-p/policytypes/2/policies' 200 echo "=== API: Create policy instance pi11 (copy of pi1) of type: 1. Shall fail ===" RESULT="" -do_curl PUT '/a1-p/policytypes/1/policies/pi11' 400 jsonfiles/pi1.json +do_curl PUT '/A1AP/v2/a1-p/policytypes/1/policies/pi11' 400 jsonfiles/pi1.json echo "=== Set force response code 401. ===" RESULT="*" @@ -208,7 +208,7 @@ do_curl POST '/forceresponse?code=401' 200 echo "=== API: Get policy status for pi1, shall fail ===" RESULT="" -do_curl GET '/a1-p/policytypes/1/policies/pi1/status' 401 +do_curl GET '/A1AP/v2/a1-p/policytypes/1/policies/pi1/status' 401 echo "=== Set force delay 10. ===" RESULT="Force delay: 10 sec set for all A1 responses" @@ -216,7 +216,7 @@ do_curl POST '/forcedelay?delay=10' 200 echo "=== API: Get policy status for pi1. Shall delay 10 sec ===" RESULT="json:{\"instance_status\": \"NOT IN EFFECT\", \"has_been_deleted\": \"false\", \"created_at\": \"????\"}" -do_curl GET '/a1-p/policytypes/1/policies/pi1/status' 200 +do_curl GET '/A1AP/v2/a1-p/policytypes/1/policies/pi1/status' 200 echo "=== Reset force delay. ===" RESULT="Force delay: None sec set for all A1 responses" @@ -228,7 +228,7 @@ do_curl PUT '/status?policyid=pi1&status=IN%20EFFECT' 200 echo "=== API: Get policy status for pi1 ===" RESULT="json:{\"instance_status\": \"IN EFFECT\", \"has_been_deleted\": \"false\", \"created_at\": \"????\"}" -do_curl GET '/a1-p/policytypes/1/policies/pi1/status' 200 +do_curl GET '/A1AP/v2/a1-p/policytypes/1/policies/pi1/status' 200 echo "=== Set status for pi1 ===" RESULT="Status set to IN EFFECT and has_been_deleted set to true and created_at set to 2020-03-30 12:00:00 for policy: pi1" @@ -236,7 +236,7 @@ do_curl PUT '/status?policyid=pi1&status=IN%20EFFECT&deleted=true&created_at=202 echo "=== API: Get policy status for pi1 ===" RESULT="json:{\"instance_status\": \"IN EFFECT\", \"has_been_deleted\": \"true\", \"created_at\": \"2020-03-30 12:00:00\"}" -do_curl GET '/a1-p/policytypes/1/policies/pi1/status' 200 +do_curl GET '/A1AP/v2/a1-p/policytypes/1/policies/pi1/status' 200 echo "=== Get counter: instances ===" RESULT="2" @@ -256,15 +256,15 @@ do_curl GET '/counter/remote_hosts' 200 echo "=== DELETE policy pi1 ===" RESULT="" -do_curl DELETE /a1-p/policytypes/1/policies/pi1 202 +do_curl DELETE /A1AP/v2/a1-p/policytypes/1/policies/pi1 202 echo "=== API: Get instances for type 1, shall be empty ===" RESULT="[]" -do_curl GET /a1-p/policytypes/1/policies 200 +do_curl GET /A1AP/v2/a1-p/policytypes/1/policies 200 echo "=== API: Get instances for type 2, shall contain pi2 ===" RESULT="[ \"pi2\" ]" -do_curl GET /a1-p/policytypes/2/policies 200 +do_curl GET /A1AP/v2/a1-p/policytypes/2/policies 200 echo "=== Get counter: instances ===" RESULT="1" diff --git a/near-rt-ric-simulator/test/OSC_2.1.0/build_and_start.sh b/near-rt-ric/test/a1_2.1.1/build_and_start.sh similarity index 100% rename from near-rt-ric-simulator/test/OSC_2.1.0/build_and_start.sh rename to near-rt-ric/test/a1_2.1.1/build_and_start.sh diff --git a/near-rt-ric-simulator/test/OSC_2.1.0/jsonfiles/pi1.json b/near-rt-ric/test/a1_2.1.1/jsonfiles/pi1.json similarity index 100% rename from near-rt-ric-simulator/test/OSC_2.1.0/jsonfiles/pi1.json rename to near-rt-ric/test/a1_2.1.1/jsonfiles/pi1.json diff --git a/near-rt-ric-simulator/test/OSC_2.1.0/jsonfiles/pi2.json b/near-rt-ric/test/a1_2.1.1/jsonfiles/pi2.json similarity index 100% rename from near-rt-ric-simulator/test/OSC_2.1.0/jsonfiles/pi2.json rename to near-rt-ric/test/a1_2.1.1/jsonfiles/pi2.json diff --git a/near-rt-ric-simulator/test/OSC_2.1.0/jsonfiles/pi2_missing_param.json b/near-rt-ric/test/a1_2.1.1/jsonfiles/pi2_missing_param.json similarity index 100% rename from near-rt-ric-simulator/test/OSC_2.1.0/jsonfiles/pi2_missing_param.json rename to near-rt-ric/test/a1_2.1.1/jsonfiles/pi2_missing_param.json diff --git a/near-rt-ric-simulator/test/OSC_2.1.0/jsonfiles/pt1.json b/near-rt-ric/test/a1_2.1.1/jsonfiles/pt1.json similarity index 100% rename from near-rt-ric-simulator/test/OSC_2.1.0/jsonfiles/pt1.json rename to near-rt-ric/test/a1_2.1.1/jsonfiles/pt1.json diff --git a/near-rt-ric-simulator/test/OSC_2.1.0/jsonfiles/pt2.json b/near-rt-ric/test/a1_2.1.1/jsonfiles/pt2.json similarity index 100% rename from near-rt-ric-simulator/test/OSC_2.1.0/jsonfiles/pt2.json rename to near-rt-ric/test/a1_2.1.1/jsonfiles/pt2.json diff --git a/near-rt-ric-simulator/src/STD_2.0.0/.gitignore b/near-rt-ric/test/common/.gitignore similarity index 100% rename from near-rt-ric-simulator/src/STD_2.0.0/.gitignore rename to near-rt-ric/test/common/.gitignore diff --git a/near-rt-ric-simulator/test/common/compare_json.py b/near-rt-ric/test/common/compare_json.py similarity index 100% rename from near-rt-ric-simulator/test/common/compare_json.py rename to near-rt-ric/test/common/compare_json.py diff --git a/near-rt-ric-simulator/test/common/test_common.sh b/near-rt-ric/test/common/test_common.sh similarity index 100% rename from near-rt-ric-simulator/test/common/test_common.sh rename to near-rt-ric/test/common/test_common.sh diff --git a/near-rt-ric-simulator/src/common/.gitignore b/near-rt-ric/tests/.gitignore similarity index 100% rename from near-rt-ric-simulator/src/common/.gitignore rename to near-rt-ric/tests/.gitignore diff --git a/near-rt-ric-simulator/tests/test_osc_2_1_0.py b/near-rt-ric/tests/test_osc_2_1_0.py similarity index 100% rename from near-rt-ric-simulator/tests/test_osc_2_1_0.py rename to near-rt-ric/tests/test_osc_2_1_0.py diff --git a/near-rt-ric-simulator/tests/unittest_setup.py b/near-rt-ric/tests/unittest_setup.py similarity index 100% rename from near-rt-ric-simulator/tests/unittest_setup.py rename to near-rt-ric/tests/unittest_setup.py