From: elinuxhenrik Date: Mon, 4 Apr 2022 11:07:36 +0000 (+0200) Subject: Seed code X-Git-Tag: 2.4.0~7 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F26%2F8026%2F1;p=nonrtric%2Fplt%2Fa1policymanagementservice.git Seed code Issue-ID: NONRTRIC-712 Signed-off-by: elinuxhenrik Change-Id: I064f034842fafe0fe59f5cce8f5389a619583616 --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5915080 --- /dev/null +++ b/.gitignore @@ -0,0 +1,22 @@ +# Documentation +.idea/ +.tox +docs/_build/ +.DS_STORE +.swagger* +docs/offeredapis/swagger/README.md + +# Eclipse +.checkstyle +.classpath +target/ +.sts4-cache +.project +.settings +.pydevproject +infer-out/ + +.vscode +.factorypath + +coverage.* diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..5056419 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "onap/oran"] + path = onap/oran + url = https://gerrit.onap.org/r/ccsdk/oran diff --git a/.readthedocs.yaml b/.readthedocs.yaml new file mode 100644 index 0000000..095222a --- /dev/null +++ b/.readthedocs.yaml @@ -0,0 +1,16 @@ +--- +version: 2 + +formats: + - htmlzip + +build: + image: latest + +python: + version: 3.7 + install: + - requirements: docs/requirements-docs.txt + +sphinx: + configuration: docs/conf.py diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6f8387e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,48 @@ +# +# ============LICENSE_START======================================================= +# Copyright (C) 2019 Nordix Foundation. +# ================================================================================ +# 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. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= +# +FROM openjdk:11-jre-slim + +ARG JAR + +EXPOSE 8081 8433 + + +WORKDIR /opt/app/policy-agent +RUN mkdir -p /var/log/policy-agent +RUN mkdir -p /opt/app/policy-agent/etc/cert/ +EXPOSE 8081 8433 + +ADD /config/application.yaml /opt/app/policy-agent/config/application.yaml +ADD /config/application_configuration.json /opt/app/policy-agent/data/application_configuration.json_example +ADD /config/keystore.jks /opt/app/policy-agent/etc/cert/keystore.jks +ADD /config/truststore.jks /opt/app/policy-agent/etc/cert/truststore.jks + +ARG user=nonrtric +ARG group=nonrtric + +RUN groupadd $user && \ + useradd -r -g $group $user +RUN chown -R $user:$group /opt/app/policy-agent +RUN chown -R $user:$group /var/log/policy-agent + +USER ${user} + +ADD target/${JAR} /opt/app/policy-agent/policy-agent.jar +CMD ["java", "-jar", "/opt/app/policy-agent/policy-agent.jar"] \ No newline at end of file diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..96589bf --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/README.md b/README.md new file mode 100644 index 0000000..d660df9 --- /dev/null +++ b/README.md @@ -0,0 +1,93 @@ +# O-RAN-SC Non-RT RIC Policy Agent + +The O-RAN Non-RT RIC PolicyAgent provides a REST API for management of policices. +It provides support for: + -Supervision of clients (R-APPs) to eliminate stray policies in case of failure + -Consistency monitoring of the SMO view of policies and the actual situation in the RICs + -Consistency monitoring of RIC capabilities (policy types) + -Policy configuration. This includes: + -One REST API towards all RICs in the network + -Query functions that can find all policies in a RIC, all policies owned by a service (R-APP), + all policies of a type etc. + -Maps O1 resources (ManagedElement) as defined in O1 to the controlling RIC + +The Policy Agent uses the default keystore and truststore that are built into the container. The paths and passwords for these stores are located in a yaml file: +nonrtric/policy-agent/config/application.yaml + +The default truststore includes a1simulator cert as a trusted cert which is located here: +https://gerrit.o-ran-sc.org/r/gitweb?p=sim/a1-interface.git;a=tree;f=near-rt-ric-simulator/certificate;h=172c1e5aacd52d760e4416288dc5648a5817ce65;hb=HEAD + +The default truststore also includes a1controller cert as a trusted cert which is located here (keystore.jks file): +https://gerrit.o-ran-sc.org/r/gitweb?p=nonrtric.git;a=tree;f=sdnc-a1-controller/oam/installation/sdnc-a1/src/main/resources;h=17fdf6cecc7a866c5ce10a35672b742a9f0c4acf;hb=HEAD + +There is also Policy Agent's own cert in the default truststore for mocking purposes and unit-testing (ApplicationTest.java). + +The default keystore, truststore, and application.yaml files can be overridden by mounting new files using the "volumes" field of docker-compose or docker run command. + +Assuming that the keystore, truststore, and application.yaml files are located in the same directory as docker-compose, the volumes field should have these entries: + +volumes: + - ./new_keystore.jks:/opt/app/policy-agent/etc/cert/keystore.jks:ro + - ./new_truststore.jks:/opt/app/policy-agent/etc/cert/truststore.jks:ro + - ./new_application.yaml:/opt/app/policy-agent/config/application.yaml:ro + +The target paths in the container should not be modified. + +Example docker run command for mounting new files (assuming they are located in the current directory): +docker run -p 8081:8081 -p 8433:8433 --name=policy-agent-container --network=nonrtric-docker-net --volume "$PWD/new_keystore.jks:/opt/app/policy-agent/etc/cert/keystore.jks" --volume "$PWD/new_truststore.jks:/opt/app/policy-agent/etc/cert/truststore.jks" --volume "$PWD/new_application.yaml:/opt/app/policy-agent/config/application.yaml" o-ran-sc/nonrtric-policy-agent:2.2.0-SNAPSHOT + + +To Run Policy Agent in Local: +In the folder /opt/app/policy-agent/config/, create a soft link with below command, +ln -s application_configuration.json + +To Run Policy Agent in Local with the DMaaP polling turned on: +In the folder /opt/app/policy-agent/config/, create a soft link with below command, +ln -s application_configuration.json + +The agent can be run stand alone in a simulated test mode. Then it simulates RICs. +The REST API is published on port 8081 and it is started by command: +mvn -Dtest=MockPolicyAgent test + +The backend server publishes live API documentation at the +URL `http://your-host-name-here:8081/swagger-ui.html` + +PolicyAgent uses A1-POLICY-AGENT-READ & A1-POLICY-AGENT-WRITE topic for subscribe & Publish to the DMaap. +Sample Request Message to DMaaP: +{ + "type": "request", + "target": "policy-agent", + "timestamp": "2019-05-14T11:44:51.36Z", + "operation": "GET", + "correlationId": "c09ac7d1-de62-0016-2000-e63701125557-201", + "apiVersion": "1.0", + "originatorId": "849e6c6b420", + "requestId": "23343221", + "url": "/policies?type=type1&ric=ric1&service=service1" +} + +Sample Response Message to DMaaP: +{ + "type": "response", + "timestamp": "2019-05-14T11:44:51.36Z", + "correlationId": "c09ac7d1-de62-0016-2000-e63701125557-201", + "originatorId": "849e6c6b420", + "requestId": "23343221", + "status": "200 OK", + "message": [] +} + +## License + +Copyright (C) 2019 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. diff --git a/config/README b/config/README new file mode 100644 index 0000000..b54a675 --- /dev/null +++ b/config/README @@ -0,0 +1,42 @@ +The keystore.jks and truststore.jks files are created by using the following commands (note that this is an example): + +1) Create a CA certificate and a private key: + +openssl genrsa -des3 -out CA-key.pem 2048 +openssl req -new -key CA-key.pem -x509 -days 1000 -out CA-cert.pem + +2) Create a keystore with a private key entry that is signed by the CA: + +keytool -genkeypair -alias policy_agent -keyalg RSA -keysize 2048 -keystore keystore.jks -validity 3650 -storepass policy_agent +keytool -certreq -alias policy_agent -file request.csr -keystore keystore.jks -ext san=dns:your.domain.com -storepass policy_agent +openssl x509 -req -days 365 -in request.csr -CA CA-cert.pem -CAkey CA-key.pem -CAcreateserial -out ca_signed-cert.pem +keytool -importcert -alias ca_cert -file CA-cert.pem -keystore keystore.jks -trustcacerts -storepass policy_agent +keytool -importcert -alias policy_agent -file ca_signed-cert.pem -keystore keystore.jks -trustcacerts -storepass policy_agent + + +3) Create a trust store containing the CA cert (to trust all certs signed by the CA): + +keytool -genkeypair -alias not_used -keyalg RSA -keysize 2048 -keystore truststore.jks -validity 3650 -storepass policy_agent +keytool -importcert -alias ca_cert -file CA-cert.pem -keystore truststore.jks -trustcacerts -storepass policy_agent + + +4) Command for listing of the contents of jks files, examples: +keytool -list -v -keystore keystore.jks -storepass policy_agent +keytool -list -v -keystore truststore.jks -storepass policy_agent + +## License + +ONAP : ccsdk oran +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. + diff --git a/config/application.yaml b/config/application.yaml new file mode 100644 index 0000000..5684c46 --- /dev/null +++ b/config/application.yaml @@ -0,0 +1,80 @@ +# +# ============LICENSE_START======================================================= +# ONAP : ccsdk oran +# ================================================================================ +# 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. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= +# +spring: + profiles: + active: prod + main: + allow-bean-definition-overriding: true + aop: + auto: false +management: + endpoints: + web: + exposure: + # Enabling of springboot actuator features. See springboot documentation. + include: "loggers,logfile,health,info,metrics,threaddump,heapdump" +springdoc: + show-actuator: true +logging: + # Configuration of logging + level: + ROOT: ERROR + org.springframework: ERROR + org.springframework.data: ERROR + org.springframework.web.reactive.function.client.ExchangeFunctions: ERROR + org.onap.ccsdk.oran.a1policymanagementservice: INFO + # org.onap.ccsdk.oran.a1policymanagementservice.tasks: TRACE + file: + name: /var/log/policy-agent/application.log +server: + # Configuration of the HTTP/REST server. The parameters are defined and handeled by the springboot framework. + # See springboot documentation. + port : 8433 + http-port: 8081 + ssl: + key-store-type: JKS + key-store-password: policy_agent + key-store: /opt/app/policy-agent/etc/cert/keystore.jks + key-password: policy_agent + key-alias: policy_agent +app: + # Location of the component configuration file. + filepath: /opt/app/policy-agent/data/application_configuration.json + webclient: + # Configuration of the trust store used for the HTTP client (outgoing requests) + # The file location and the password for the truststore is only relevant if trust-store-used == true + # Note that the same keystore as for the server is used. + trust-store-used: false + trust-store-password: policy_agent + trust-store: /opt/app/policy-agent/etc/cert/truststore.jks + # Configuration of usage of HTTP Proxy for the southbound accesses. + # The HTTP proxy (if configured) will only be used for accessing NearRT RIC:s + # proxy-type can be either HTTP, SOCKS4 or SOCKS5 + http.proxy-host: + http.proxy-port: 0 + http.proxy-type: HTTP + # path where the service can store data + vardata-directory: /var/policy-management-service + # the config-file-schema-path referres to a location in the jar file. If this property is empty or missing, + # no schema validation will be executed. + config-file-schema-path: /application_configuration_schema.json + diff --git a/config/application_configuration.json b/config/application_configuration.json new file mode 100644 index 0000000..6187c86 --- /dev/null +++ b/config/application_configuration.json @@ -0,0 +1,24 @@ +{ + "description": "Application configuration", + "config": { + "controller": [ + { + "name": "controller1", + "baseUrl": "http://a1controller:8282", + "userName": "admin", + "password": "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U" + } + ], + "ric": [ + { + "name": "ric1", + "baseUrl": "http://ric1:8085/", + "controller": "controller1", + "managedElementIds": [ + "kista_1", + "kista_2" + ] + } + ] + } +} diff --git a/config/keystore.jks b/config/keystore.jks new file mode 100644 index 0000000..48c3b33 Binary files /dev/null and b/config/keystore.jks differ diff --git a/config/truststore.jks b/config/truststore.jks new file mode 100644 index 0000000..760261e Binary files /dev/null and b/config/truststore.jks differ diff --git a/docs/_static/logo.png b/docs/_static/logo.png new file mode 100644 index 0000000..c3b6ce5 Binary files /dev/null and b/docs/_static/logo.png differ diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..94affba --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,19 @@ +from docs_conf.conf import * + +#branch configuration + +branch = 'latest' + +linkcheck_ignore = [ + 'http://localhost.*', + 'http://127.0.0.1.*', + 'https://gerrit.o-ran-sc.org.*' +] + +extensions = ['sphinx.ext.intersphinx',] + +#intershpinx mapping with other projects +intersphinx_mapping = {} + +intersphinx_mapping['nonrtric-controlpanel'] = ('https://docs.o-ran-sc.org/projects/o-ran-sc-portal-nonrtric-controlpanel/en/%s' % branch, None) +intersphinx_mapping['sim-a1-interface'] = ('https://docs.o-ran-sc.org/projects/o-ran-sc-sim-a1-interface/en/%s' % branch, None) diff --git a/docs/conf.yaml b/docs/conf.yaml new file mode 100644 index 0000000..f730bc0 --- /dev/null +++ b/docs/conf.yaml @@ -0,0 +1,3 @@ +--- +project_cfg: oran +project: nonrtric-plt-a1policymanagementservice diff --git a/docs/developer-guide.rst b/docs/developer-guide.rst new file mode 100644 index 0000000..d3bb426 --- /dev/null +++ b/docs/developer-guide.rst @@ -0,0 +1,24 @@ +.. This work is licensed under a Creative Commons Attribution 4.0 International License. +.. SPDX-License-Identifier: CC-BY-4.0 +.. Copyright (C) 2021 Nordix + +=============== +Developer Guide +=============== + +This document provides a quickstart for developers of the Non-RT RIC A1 Policy Managent Service. + +The A1 Policy Management Service is implemented in ONAP. For documentation see `ONAP CCSDK documentation `_. +and `wiki `_. + +Kubernetes deployment +===================== + +Non-RT RIC can be also deployed in a Kubernetes cluster, `it/dep repository `_. +hosts deployment and integration artifacts. Instructions and helm charts to deploy the Non-RT-RIC functions in the +OSC NONRTRIC integrated test environment can be found in the *./nonrtric* directory. + +For more information on installation of NonRT-RIC in Kubernetes, see `Deploy NONRTRIC in Kubernetes `_. + +For more information see `Integration and Testing documentation on the O-RAN-SC wiki `_. + diff --git a/docs/favicon.ico b/docs/favicon.ico new file mode 100644 index 0000000..00b0fd0 Binary files /dev/null and b/docs/favicon.ico differ diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..d1438e3 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,17 @@ +.. This work is licensed under a Creative Commons Attribution 4.0 International License. +.. SPDX-License-Identifier: CC-BY-4.0 +.. Copyright (C) 2021 Nordix + +Non-RT RIC A1 Policy Managent Service +===================================== + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + ./overview.rst + ./developer-guide.rst + ./installation-guide.rst + ./release-notes.rst + +* :ref:`search` diff --git a/docs/installation-guide.rst b/docs/installation-guide.rst new file mode 100644 index 0000000..1837152 --- /dev/null +++ b/docs/installation-guide.rst @@ -0,0 +1,41 @@ +.. This work is licensed under a Creative Commons Attribution 4.0 International License. +.. http://creativecommons.org/licenses/by/4.0 +.. Copyright (C) 2021 Nordix + +Installation Guide +================== + +Abstract +-------- + +This document describes how to install the Non-RT RIC components, their dependencies and required system resources. + +Software Installation and Deployment +------------------------------------ + +Install with Docker ++++++++++++++++++++ + +Docker compose files are provided, in the "docker-compose" folder, to install the components. Run the following +command to start the components: + + .. code-block:: bash + + docker-compose -f docker-compose.yaml + -f policy-service/docker-compose.yaml + -f ics/docker-compose.yaml + +The example above is just an example to start some of the components. +For more information on running and configuring the functions can be found in the README file in the "`docker-compose `__" folder, and on the `wiki page `_ + +Install with Helm ++++++++++++++++++ + +Helm charts and an example recipe are provided in the `it/dep repo `_, +under "nonrtric". By modifying the variables named "installXXX" in the beginning of the example recipe file, which +components that will be installed can be controlled. Then the components can be installed and started by running the +following command: + + .. code-block:: bash + + bin/deploy-nonrtric -f nonrtric/RECIPE_EXAMPLE/example_recipe.yaml diff --git a/docs/overview.rst b/docs/overview.rst new file mode 100644 index 0000000..773b872 --- /dev/null +++ b/docs/overview.rst @@ -0,0 +1,32 @@ +.. This work is licensed under a Creative Commons Attribution 4.0 International License. +.. SPDX-License-Identifier: CC-BY-4.0 +.. Copyright (C) 2021 Nordix + +A1 Policy Management Service (from ONAP CCSDK) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +A1 Controller Service above A1 Controller/Adaptor that provides: + +* Unified REST & DMaaP NBI APIs for managing A1 Policies in all near-RT-RICs. + + + Query A1 Policy Types in near-RT-RICs. + + Create/Query/Update/Delete A1 Policy Instances in near-RT-RICs. + + Query Status for A1 Policy Instances. + +* Maintains (persistent) cache of RAN's A1 Policy information. + + * Support RAN-wide view of A1 Policy information. + * Streamline A1 traffic. + * Enable (optional) re-synchronization after inconsistencies / near-RT-RIC restarts. + * Supports a large number of near-RT-RICs (& multi-version support). + +* Converged ONAP & O-RAN-SC A1 Adapter/Controller functions in ONAP SDNC/CCSDK (Optionally deploy without A1 Adaptor to connect direct to near-RT-RICs). +* Support for different Southbound connectors per near-RT-RIC - e.g. different A1 versions, different near-RT-RIC version, different A1 adapter/controllers supports different or proprietary A1 controllers/EMSs. + +See also: `A1 Policy Management Service in ONAP `_ . + +Implementation: + +* Implemented as a Java Spring Boot application. + + diff --git a/docs/release-notes.rst b/docs/release-notes.rst new file mode 100644 index 0000000..39111bd --- /dev/null +++ b/docs/release-notes.rst @@ -0,0 +1,185 @@ +.. This work is licensed under a Creative Commons Attribution 4.0 International License. +.. http://creativecommons.org/licenses/by/4.0 +.. Copyright (C) 2021 Nordix + +============= +Release-Notes +============= + + +This document provides the release notes for the release of the Non-RT RIC A1 Policy Management Service. + + +Version history A1 Policy Management Service (A1 Policy Agent) +============================================================== + ++------------+----------+------------------+--------------------+ +| **Date** | **Ver.** | **Author** | **Comment** | +| | | | | ++------------+----------+------------------+--------------------+ +| 2020-02-03 | 1.0.0 | Henrik Andersson | First version | +| | | | Amber Maintenance | +| | | | Release | ++------------+----------+------------------+--------------------+ +| 2020-06-18 | 2.0.0 | Henrik Andersson | Bronze Release | +| | | | | ++------------+----------+------------------+--------------------+ +| 2020-07-29 | 2.0.1 | Henrik Andersson | Bronze Maintenance | +| | | | Release | +| | | | | ++------------+----------+------------------+--------------------+ +| 2020-12-03 | 2.1.0 | Henrik Andersson | Cherry Release | +| | | | | ++------------+----------+------------------+--------------------+ +| 2021-06-23 | 2.2.0 | Henrik Andersson | D Release | +| | | | | ++------------+----------+------------------+--------------------+ +| 2021-08-10 | 2.2.1 | Henrik Andersson | D Maintenance | +| | | | Release | +| | | | | ++------------+----------+------------------+--------------------+ +| 2021-12-13 | 2.3.0 | Henrik Andersson | E Release | +| | | | Renamed and minor | +| | | | improvements | ++------------+----------+------------------+--------------------+ +| 2022-02-07 | 2.3.1 | Henrik Andersson | E Maintenance | +| | | | Release | +| | | | Non root user in | +| | | | Docker | ++------------+----------+------------------+--------------------+ + +Release Data +============ + +Bronze +------ ++-----------------------------+---------------------------------------------------+ +| **Project** | Non-RT RIC | +| | | ++-----------------------------+---------------------------------------------------+ +| **Repo/commit-ID** | nonrtric/2466f9d370214b578efedd1d3e38b1de17e6ca1c | +| | | ++-----------------------------+---------------------------------------------------+ +| **Release designation** | Bronze | +| | | ++-----------------------------+---------------------------------------------------+ +| **Release date** | 2020-06-18 | +| | | ++-----------------------------+---------------------------------------------------+ +| **Purpose of the delivery** | Improved stability | +| | | ++-----------------------------+---------------------------------------------------+ + +Bronze Maintenance +------------------ ++-----------------------------+---------------------------------------------------+ +| **Project** | Non-RT RIC | +| | | ++-----------------------------+---------------------------------------------------+ +| **Repo/commit-ID** | nonrtric/5d4f252a530a0d9abbf2a363354c5e56e8f2f33e | +| | | ++-----------------------------+---------------------------------------------------+ +| **Release designation** | Bronze | +| | | ++-----------------------------+---------------------------------------------------+ +| **Release date** | 2020-07-29 | +| | | ++-----------------------------+---------------------------------------------------+ +| **Purpose of the delivery** | Introduce configuration of certificates | +| | | ++-----------------------------+---------------------------------------------------+ + +Cherry +------ ++-----------------------------+---------------------------------------------------+ +| **Project** | Non-RT RIC | +| | | ++-----------------------------+---------------------------------------------------+ +| **Repo/commit-ID** | nonrtric/90ce16238dd6970153e1c0fbddb15e32c68c504f | +| | | ++-----------------------------+---------------------------------------------------+ +| **Release designation** | Cherry | +| | | ++-----------------------------+---------------------------------------------------+ +| **Release date** | 2020-12-03 | +| | | ++-----------------------------+---------------------------------------------------+ +| **Purpose of the delivery** | | +| | | ++-----------------------------+---------------------------------------------------+ + +D +- ++-----------------------------+---------------------------------------------------+ +| **Project** | Non-RT RIC | +| | | ++-----------------------------+---------------------------------------------------+ +| **Repo/commit-ID** | nonrtric/dd3ebfd784e96919a00ddd745826f8a8e074c66f | +| | | ++-----------------------------+---------------------------------------------------+ +| **Release designation** | D | +| | | ++-----------------------------+---------------------------------------------------+ +| **Release date** | 2021-06-23 | +| | | ++-----------------------------+---------------------------------------------------+ +| **Purpose of the delivery** | Improvements | +| | | ++-----------------------------+---------------------------------------------------+ + +D Maintenance +------------- ++-----------------------------+---------------------------------------------------+ +| **Project** | Non-RT RIC | +| | | ++-----------------------------+---------------------------------------------------+ +| **Repo/commit-ID** | nonrtric/973ae56894fb29a929fba9e344cae42e7607087b | +| | | ++-----------------------------+---------------------------------------------------+ +| **Release designation** | D | +| | | ++-----------------------------+---------------------------------------------------+ +| **Release date** | 2021-08-10 | +| | | ++-----------------------------+---------------------------------------------------+ +| **Purpose of the delivery** | Minor bug fixes | ++-----------------------------+---------------------------------------------------+ + +E Release +--------- ++-----------------------------+---------------------------------------------------+ +| **Project** | Non-RT RIC | +| | | ++-----------------------------+---------------------------------------------------+ +| **Repo/commit-ID** | nonrtric/b472c167413a55a42fc7bfa08d2138f967a204fb | +| | | ++-----------------------------+---------------------------------------------------+ +| **Release designation** | E | +| | | ++-----------------------------+---------------------------------------------------+ +| **Release date** | 2021-12-13 | +| | | ++-----------------------------+---------------------------------------------------+ +| **Purpose of the delivery** | Improvements and renaming. | +| | | ++-----------------------------+---------------------------------------------------+ + +E Maintenance Release +--------------------- ++-----------------------------+---------------------------------------------------+ +| **Project** | Non-RT RIC | +| | | ++-----------------------------+---------------------------------------------------+ +| **Repo/commit-ID** | nonrtric/4df1f9ca4cd1ebc21e0c5ea57bcb0b7ef096d067 | +| | | ++-----------------------------+---------------------------------------------------+ +| **Release designation** | E | +| | | ++-----------------------------+---------------------------------------------------+ +| **Release date** | 2022-02-09 | +| | | ++-----------------------------+---------------------------------------------------+ +| **Purpose of the delivery** | Improvements and bug fixes | +| | | ++-----------------------------+---------------------------------------------------+ + diff --git a/docs/requirements-docs.txt b/docs/requirements-docs.txt new file mode 100644 index 0000000..692a79f --- /dev/null +++ b/docs/requirements-docs.txt @@ -0,0 +1,12 @@ +tox +Sphinx +doc8 +docutils +setuptools +six +sphinx_rtd_theme +sphinxcontrib-needs +sphinxcontrib-swaggerdoc +sphinx_bootstrap_theme +sphinxcontrib-redoc +lfdocs-conf \ No newline at end of file diff --git a/dpo/blueprints/k8s-policy-agent.yaml b/dpo/blueprints/k8s-policy-agent.yaml new file mode 100644 index 0000000..aa09ff3 --- /dev/null +++ b/dpo/blueprints/k8s-policy-agent.yaml @@ -0,0 +1,111 @@ + +#description: Docker application of Policy Agent managing policies +#blueprint_version: 1.0.0 +--- +tosca_definitions_version: cloudify_dsl_1_3 +description: Docker application to collect log file from PNF +imports: + - http://www.getcloudify.org/spec/cloudify/4.3.1/types.yaml + - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R5/k8splugin/1.6.0/k8splugin_types.yaml + - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.ccsdk.platform.plugins/type_files/dmaap/dmaap.yaml +inputs: + policy-agent_cpu_limit: + type: string + default: "250m" + policy-agent_cpu_request: + type: string + default: "250m" + policy-agent_memory_limit: + type: string + default: "256Mi" + policy-agent_memory_request: + type: string + default: "256Mi" + envs: + default: {} + external_port: + type: string + default: ":0" + publish_topic_name: + type: string + default: "A1-POLICY-AGENT-WRITE" + subscribe_topic_name: + type: string + default: "A1-POLICY-AGENT-READ" + consumer_group: + type: string + default: "users" + consumer_id: + type: string + default: "policy-agent" + log_directory: + type: string + default: "/var/log/policy-agent" + replicas: + type: integer + description: number of instances + default: 1 + tag_version: + type: string + default: "nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-policy-agent:1.0.0" +node_templates: + policy-agent: + type: dcae.nodes.ContainerizedServiceComponentUsingDmaap + interfaces: + cloudify.interfaces.lifecycle: + start: + inputs: + envs: + get_input: envs + properties: + application_config: + streams_publishes: + dmaap_publisher: + dmaap_info: + topic_url: { concat: ['https://message-router:3905/events/',{ get_input: publish_topic_name }] } + type: message_router + streams_subscribes: + dmaap_subscriber: + dmaap_info: + topic_url: { concat: ['https://message-router:3905/events/',{ get_input: subscribe_topic_name }, '/', { get_input: consumer_group }, "/", { get_input: consumer_id }, "?timeout=15000&limit=100"] } + type: message_router + ric: + - name: ric1 + baseUrl: http://localhost:8083/ + managedElementIds: + - kista_1 + - kista_2 + - name: ric2 + baseUrl: http://localhost:8085/ + managedElementIds: + - kista_3 + - kista_4 + docker_config: + healthcheck: + interval: 15s + timeout: 1s + type: http + endpoint: /status + ports: + - concat: ["8081", {get_input: external_port}] + image: + get_input: tag_version + service_component_type: policy-agent + log_info: + log_directory: + get_input: log_directory + replicas: + get_input: replicas + resource_config: + limits: + cpu: + get_input: policy-agent_cpu_limit + memory: + get_input: policy-agent_memory_limit + requests: + cpu: + get_input: policy-agent_cpu_request + memory: + get_input: policy-agent_memory_request + + diff --git a/onap/oran b/onap/oran new file mode 160000 index 0000000..4b62052 --- /dev/null +++ b/onap/oran @@ -0,0 +1 @@ +Subproject commit 4b6205245fd4839e4449e26aa4e3000ddb30ecc1 diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..12b8ecd --- /dev/null +++ b/pom.xml @@ -0,0 +1,377 @@ + + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.6.6 + + + org.o-ran-sc.nonrtric + nonrtric-plt-a1policymanagementservice + 2.4.0-SNAPSHOT + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + + + + + onap-releases + onap-releases + https://nexus.onap.org/content/repositories/releases/ + + + + 11 + 3.0.0 + 2.8.2 + 2.1.13 + 20211205 + 3.8.0 + 2.12.2 + 1.18.0 + 0.30.0 + 2.1.1 + 3.7.0.1746 + 0.8.5 + 3.0.0 + + + + commons-io + commons-io + 2.11.0 + + + com.google.guava + guava + 31.0.1-jre + + + org.springdoc + springdoc-openapi-ui + 1.6.6 + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-thymeleaf + + + org.springframework.boot + spring-boot-starter-webflux + + + org.springframework.boot + spring-boot-starter-aop + + + org.springframework.boot + spring-boot-devtools + true + + + org.springframework + spring-webflux + + + io.swagger.core.v3 + swagger-jaxrs2 + ${swagger.version} + + + io.swagger.core.v3 + swagger-jaxrs2-servlet-initializer + ${swagger.version} + + + javax.xml.bind + jaxb-api + + + org.immutables + value + ${immutable.version} + provided + + + org.immutables + gson + ${immutable.version} + + + org.json + json + ${json.version} + + + org.springframework.boot + spring-boot-configuration-processor + true + + + org.projectlombok + lombok + provided + + + javax.ws.rs + javax.ws.rs-api + ${javax.ws.rs-api.version} + + + org.glassfish.jersey.inject + jersey-hk2 + + + + org.springframework.boot + spring-boot-starter-actuator + + + + io.springfox + springfox-swagger2 + ${springfox.version} + + + io.springfox + springfox-swagger-ui + ${springfox.version} + + + + org.springframework.boot + spring-boot-starter-test + test + + + org.awaitility + awaitility + test + + + io.projectreactor + reactor-test + test + + + org.junit.jupiter + junit-jupiter-engine + test + + + org.mockito + mockito-junit-jupiter + test + + + org.mockito + mockito-core + test + + + com.squareup.okhttp3 + mockwebserver + test + + + + com.github.erosb + everit-json-schema + 1.13.0 + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + org.apache.maven.plugins + maven-surefire-plugin + + false + + + + maven-failsafe-plugin + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-source + generate-sources + + add-source + + + + ${project.build.directory}/generated-sources/annotations/ + + + + + + + org.jacoco + jacoco-maven-plugin + ${jacoco-maven-plugin.version} + + + default-prepare-agent + + prepare-agent + + + + default-report + prepare-package + + report + + + + + + io.fabric8 + docker-maven-plugin + ${docker-maven-plugin} + false + + + generate-a1policymanagementservice-image + package + + build + + + ${env.CONTAINER_PULL_REGISTRY} + + + o-ran-sc/nonrtric-plt-a1policymanagementservice:${project.version} + + try + ${basedir} + Dockerfile + + ${project.build.finalName}.jar + + + ${project.version} + + + + + + + + push-a1policymanagementservice-image + + build + push + + + ${env.CONTAINER_PULL_REGISTRY} + ${env.CONTAINER_PUSH_REGISTRY} + + + o-ran-sc/nonrtric-plt-a1policymanagementservice:${project.version} + + ${basedir} + Dockerfile + + ${project.build.finalName}.jar + + + ${project.version} + latest + + + + + + + + + + + org.sonarsource.scanner.maven + sonar-maven-plugin + ${sonar-maven-plugin.version} + + + org.codehaus.mojo + exec-maven-plugin + ${exec-maven-plugin.version} + + + git submodule update + initialize + + git + + submodule + update + --init + --recursive + + + + exec + + + + copy configuration + initialize + + cp + + -r + onap/oran/a1-policy-management/config + . + + + + exec + + + + + + + + JIRA + https://jira.o-ran-sc.org/ + + diff --git a/src b/src new file mode 120000 index 0000000..5e0adbf --- /dev/null +++ b/src @@ -0,0 +1 @@ +onap/oran/a1-policy-management/src \ No newline at end of file diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..2705e16 --- /dev/null +++ b/tox.ini @@ -0,0 +1,37 @@ +# ================================================================================== +# Copyright (c) 2020 Nordix +# +# 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. +# ================================================================================== + +# documentation only +[tox] +minversion = 2.0 +envlist = + docs, + docs-linkcheck, +skipsdist = true + +[testenv:docs] +basepython = python3 +deps = -r{toxinidir}/docs/requirements-docs.txt + +commands = + sphinx-build -W -b html -n -d {envtmpdir}/docs/doctrees ./docs/ {toxinidir}/docs/_build/html + echo "Generated docs available in {toxinidir}/docs/_build/html" +whitelist_externals = echo + +[testenv:docs-linkcheck] +basepython = python3 +deps = -r{toxinidir}/docs/requirements-docs.txt +commands = sphinx-build -W -b linkcheck -d {envtmpdir}/doctrees ./docs/ {toxinidir}/docs/_build/linkcheck