Add ORAN Python SDK first draft 69/7169/1
authorsebdet <sebastien.determe@intl.att.com>
Wed, 1 Dec 2021 18:14:17 +0000 (19:14 +0100)
committersebdet <sebastien.determe@intl.att.com>
Wed, 1 Dec 2021 18:14:17 +0000 (19:14 +0100)
This add the draft of the ORAN python SDK based on the ONAP python SDK,
it adds already a test usecase for A1.

Issue-ID: NONRTRIC-669
Signed-off-by: sebdet <sebastien.determe@intl.att.com>
Signed-off-by: xuegao <xue.gao@intl.att.com>
Change-Id: Iee213bf83830728bc7572b4ef39ce3605e6311f7

58 files changed:
smo-install/README.md
smo-install/test/apex-policy-test/apex-policy-test.sh
smo-install/test/pythonsdk/.gitignore [new file with mode: 0644]
smo-install/test/pythonsdk/README.md [new file with mode: 0644]
smo-install/test/pythonsdk/src/oransdk/__init__.py [new file with mode: 0644]
smo-install/test/pythonsdk/src/oransdk/a1policymanagement/__init__.py [new file with mode: 0644]
smo-install/test/pythonsdk/src/oransdk/a1policymanagement/a1policymanagement.py [new file with mode: 0644]
smo-install/test/pythonsdk/src/oransdk/a1sim/a1sim.py
smo-install/test/pythonsdk/src/oransdk/a1sim/templates/OSC/policy_type.json.j2 [new file with mode: 0644]
smo-install/test/pythonsdk/src/oransdk/a1sim/templates/v2/policy_osc.json.j2 [new file with mode: 0644]
smo-install/test/pythonsdk/src/oransdk/a1sim/templates/v2/policy_std_v2.json.j2 [new file with mode: 0644]
smo-install/test/pythonsdk/src/oransdk/a1sim/templates/v2/policy_type.json.j2 [new file with mode: 0644]
smo-install/test/pythonsdk/src/oransdk/a1sim/templates/v2/service.json.j2 [new file with mode: 0644]
smo-install/test/pythonsdk/src/oransdk/configuration/__init__.py [new file with mode: 0644]
smo-install/test/pythonsdk/src/oransdk/configuration/global_settings.py [new file with mode: 0644]
smo-install/test/pythonsdk/src/oransdk/dmaap/dmaap.py [new file with mode: 0644]
smo-install/test/pythonsdk/src/oransdk/dmaap/templates/LinkFailureEvent.json.j2 [new file with mode: 0644]
smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v1/dmaap-msg-pms-status.json.j2 [new file with mode: 0644]
smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v1/dmaap-msg-policy-create.json.j2 [new file with mode: 0644]
smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v1/dmaap-msg-policy-delete.json.j2 [new file with mode: 0644]
smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v1/dmaap-msg-policy-get.json.j2 [new file with mode: 0644]
smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v1/dmaap-msg-policy-schemas-get.json.j2 [new file with mode: 0644]
smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v1/dmaap-msg-rics-get.json.j2 [new file with mode: 0644]
smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v1/dmaap-msg-service-create.json.j2 [new file with mode: 0644]
smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v1/dmaap-msg-services-get.json.j2 [new file with mode: 0644]
smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v2/dmaap-msg-pms-status.json.j2 [new file with mode: 0644]
smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v2/dmaap-msg-policy-create.json.j2 [new file with mode: 0644]
smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v2/dmaap-msg-policy-delete.json.j2 [new file with mode: 0644]
smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v2/dmaap-msg-policy-get.json.j2 [new file with mode: 0644]
smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v2/dmaap-msg-policy-schemas-get.json.j2 [new file with mode: 0644]
smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v2/dmaap-msg-rics-get.json.j2 [new file with mode: 0644]
smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v2/dmaap-msg-service-create.json.j2 [new file with mode: 0644]
smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v2/dmaap-msg-services-get.json.j2 [new file with mode: 0644]
smo-install/test/pythonsdk/src/oransdk/enrichmentservice/__init__.py [new file with mode: 0644]
smo-install/test/pythonsdk/src/oransdk/enrichmentservice/enrichmentservice.py [new file with mode: 0644]
smo-install/test/pythonsdk/src/oransdk/enrichmentservice/templates/EiJob.json.j2 [new file with mode: 0644]
smo-install/test/pythonsdk/src/oransdk/enrichmentservice/templates/EiProducer.json.j2 [new file with mode: 0644]
smo-install/test/pythonsdk/src/oransdk/enrichmentservice/templates/EiType.json.j2 [new file with mode: 0644]
smo-install/test/pythonsdk/src/oransdk/policy/__init__.py [new file with mode: 0644]
smo-install/test/pythonsdk/src/oransdk/policy/policy.py [new file with mode: 0644]
smo-install/test/pythonsdk/src/oransdk/policy/templates/DeployPolicyPAP.json.j2 [new file with mode: 0644]
smo-install/test/pythonsdk/src/oransdk/policy/templates/ToscaPolicy.json.j2 [new file with mode: 0644]
smo-install/test/pythonsdk/src/oransdk/sdnc/__init__.py [new file with mode: 0644]
smo-install/test/pythonsdk/src/oransdk/sdnc/sdnc.py [new file with mode: 0644]
smo-install/test/pythonsdk/src/oransdk/utils/jinja.py [new file with mode: 0644]
smo-install/test/pythonsdk/src/oransdk/version.py [new file with mode: 0644]
smo-install/test/pythonsdk/src/orantests/configuration/settings.py [new file with mode: 0644]
smo-install/test/pythonsdk/src/orantests/test_apex_policy.py [new file with mode: 0644]
smo-install/test/pythonsdk/src/orantests/test_dmaap.py [new file with mode: 0644]
smo-install/test/pythonsdk/tox.ini [new file with mode: 0644]
smo-install/test/pythonsdk/unit-tests/__init__.py [new file with mode: 0644]
smo-install/test/pythonsdk/unit-tests/test_a1policymanagement.py [new file with mode: 0644]
smo-install/test/pythonsdk/unit-tests/test_a1sim.py [new file with mode: 0644]
smo-install/test/pythonsdk/unit-tests/test_dmaap.py [new file with mode: 0644]
smo-install/test/pythonsdk/unit-tests/test_enrichmentservice.py [new file with mode: 0644]
smo-install/test/pythonsdk/unit-tests/test_policy.py [new file with mode: 0644]
smo-install/test/pythonsdk/unit-tests/test_sdnc.py [new file with mode: 0644]
smo-install/test/pythonsdk/unit-tests/test_version.py [new file with mode: 0644]

index 391a255..7c76d09 100644 (file)
@@ -33,6 +33,31 @@ It has been created out of the ONAP vfirewall usecase.
        
        ```./dep/smo-install/scripts/layer-2/2-install-simulators.sh```
 
+## Quick Installation on existing kubernetes
+* Ensure you have at least 20GB Memory, 6VCPU, 60GB of diskspace.
+* Execute the following commands being logged as root:
+
+        ```git clone --recursive "https://gerrit.o-ran-sc.org/r/it/dep"```
+
+        ```./oran-deployment/scripts/layer-0/0-setup-charts-museum.sh```
+
+        ```./oran-deployment/scripts/layer-0/0-setup-helm3.sh```
+
+        ```./oran-deployment/scripts/layer-1/1-build-all-charts.sh```
+
+        ```./oran-deployment/scripts/layer-2/2-install-oran.sh```
+
+        Verify pods:
+
+        ```kubectl get pods -n onap && kubectl get pods -n nonrtric```
+
+        When all pods in "onap" and "nonrtric" namespaces are well up & running:
+
+        ```./oran-deployment/scripts/layer-2/2-install-simulators.sh```
+
+
+
+
 ## Structure
 The user entry point is located in the <strong>scripts</strong> folder
 
@@ -77,6 +102,7 @@ The user entry point is located in the <strong>scripts</strong> folder
 │   │   └── 0-setup-kud-node.sh                  <--- Setup K8S node with ONAP Multicloud KUD installation
 │   │   └── 0-setup-microk8s.sh          <--- Setup K8S node with MicroK8S installation
 │   │   └── 0-setup-helm3.sh                     <--- Setup HELM3
+│   │   └── 0-setup-tests-env.sh                <--- Setup Python SDK tools
 │   ├── layer-1                              <--- Scripts to prepare for the SMO installation
 │   │   └── 1-build-all-charts.sh                <--- Build all HELM charts and upload them to ChartMuseum
 │   ├── layer-2                              <--- Scripts to install SMO package
@@ -84,6 +110,7 @@ The user entry point is located in the <strong>scripts</strong> folder
 │   │   ├── 2-install-oran-cnf.sh                <--- Install SMO full with ONAP CNF features
 │   │   ├── 2-install-oran.sh                    <--- Install SMO minimal 
 │   │   └── 2-install-simulators.sh              <--- Install Network simulator (RU/DU/Topology Server)
+│   │   └── 2-upgrade-simulators.sh             <--- Upgrade the simulators install at runtime when changes are done on override files
 │   ├── sub-scripts                  <--- Sub-Scripts used by the main layer-0, layer-1, layer-2
 │   │   ├── clean-up.sh
 │   │   ├── install-nonrtric.sh
@@ -101,9 +128,18 @@ The user entry point is located in the <strong>scripts</strong> folder
     ├── apex-policy-test         <--- Test apex policy (https://wiki.o-ran-sc.org/pages/viewpage.action?pageId=35881325, it requires simulators to be up)
     │   ├── apex-policy-test.sh
     │   └── data
-    └── enable-sim-fault-report          <--- Enable the fault reporting of the network simulators by SDNC
-        ├── data
-        └── enable-network-sim-fault-reporting.sh
+    ├── enable-sim-fault-report          <--- Enable the fault reporting of the network simulators by SDNC
+    │   ├── data
+    │   └── enable-network-sim-fault-reporting.sh
+    └── pythonsdk                       <--- Test based on ONAP Python SDK to validate O1 and A1
+        ├── oran-tests.xml
+        ├── Pipfile.lock
+        ├── README.md
+        ├── src
+        ├── test.json
+        ├── tox.ini
+        └── unit-tests
+
 
 ```
 ## Download:
@@ -141,9 +177,8 @@ Use git clone to get it on your server:
        - Install chartmuseum manually on port 18080 (https://chartmuseum.com/#Instructions, https://github.com/helm/chartmuseum)
     
 ## Configuration:
-In the ./helm-override/ folder the helm config that are used by the SMO installation. 
-<p>Different flavors are preconfigured, and should NOT be changed EXCEPT for the simulators (due to current DNS limitations in the simulators)
-in ./helm-override/simulators-override.yaml, the <strong>"sdnControllerIp"</strong> and <strong>"vesEndpointIp"</strong> must be set to the server external IP</p>
+In the ./helm-override/ folder the helm config that are used by the SMO installation.
+<p>Different flavors are preconfigured, and should NOT be changed unless you intentionally want to updates some configurations.
 
 ## Installation:
 * Build ONAP/ORAN charts 
@@ -181,9 +216,9 @@ in ./helm-override/simulators-override.yaml, the <strong>"sdnControllerIp"</stro
        
 ## Platform access points:
 * SDNR WEB: 
-       https://<K8SServerIP>:30205/odlux/index.html
+       https://K8SServerIP:30205/odlux/index.html
 * NONRTRIC Dashboard: 
-       http://<K8SServerIP>:30091/
+       http://K8SServerIP:30091/
   More to come ...
 
 ## Uninstallation:
index 0bfaee6..cd92629 100755 (executable)
@@ -39,113 +39,3 @@ echo "Dmaap url: $dmaap_url"
 sdnc_url=`kubectl get services -n onap | grep sdnc-oam | awk  '{print $3}'`:$sdnc_port
 echo "SDNC url: $sdnc_url"
 echo -e "\n"
-
-verifyApexPolicyStatus(){
-    for i in {1..60}; do
-        curl  -s -o /dev/null -X POST -H accept:application/json -H Content-Type:application/json "http://$dmaap_url/events/unauthenticated.SEC_FAULT_OUTPUT/" -d @./data/LinkFailureEvent.json
-        sleep 3
-        res=`kubectl logs onap-policy-apex-pdp-0 -n onap | grep "Task Selection Execution: 'LinkMonitorPolicy:0.0.1:NULL:LinkFailureOrClearedState'" | wc -l`
-        if [[ $res != 0 ]]; then
-            echo -e "LinkFailureEvent sent to Dmaap\n"
-            break;
-        else
-            sleep 2
-        fi
-    done
-}
-
-checkStatus(){
-        echo "res:$1"
-        if [ "$1" == "$2" ]; then
-            echo -e "$3\n"
-        else
-            echo -e "Result is not as expected: $2\n"
-            exit;
-        fi
-}
-
-checkPolicyStatus(){
-    for i in {1..60}; do
-        res=$(curl -sk -u 'healthcheck:zb!XztG34' -X GET "https://$pap_url/policy/pap/v1/components/healthcheck")
-        apex_info=$(echo $res| cut -d'{' -f 4)
-
-        echo "Verify policy Pap"
-        if [[ $res == *"url\":\"https://$1:6969/policy/pap/v1/healthcheck\",\"healthy\":true"* ]]; then
-          echo "Policy Pap is ready"
-          echo "Verify policy api"
-          if [[ $res == *"url\":\"https://$2:6969/policy/api/v1/healthcheck\",\"healthy\":true"* ]]; then
-            echo "Policy API is ready"
-            echo "Verify policy Apex pdp"
-            if [[ $apex_info == *"instanceId\":\"apex"*  && $apex_info == *"healthy\":\"HEALTHY"* ]]; then
-              echo "Policy APEX pdp is ready"
-              break;
-            else
-              echo "Policy Apex pdp not ready yet. Wait for a while and retry."
-              sleep $i
-            fi
-          else
-            echo "Policy api not ready yet. Wait for a while and retry."
-            sleep $i
-          fi
-        else
-          echo "Policy Pap not ready yet. Wait for a while and retry."
-          sleep $i
-        fi
-    done
-}
-
-checkPolicyDeployment (){
-  res=$(curl -sk -u 'healthcheck:zb!XztG34' -X GET "https://$pap_url/policy/pap/v1/policies/status")
-  str1="onap.policies.native.apex.LinkMonitor\",\"version\":\"1.0.0\"},\"policyType\":{\"name\":\"onap.policies.native.Apex\",\"version\":\"1.0.0\"},\"deploy\":true"
-        if [[ $res == *"$str1"* ]]; then
-          echo "Policy successfully deployed"
-        else
-          echo "Policy deployment failed"
-          exit;
-        fi
-}
-
-echo "Create topic:"
-curl -sk -X POST "http://$dmaap_url/topics/create" -H  "accept: application/json" -H  "Content-Type: application/json" -d "{  \"topicName\": \"unauthenticated.SEC_FAULT_OUTPUT\",  \"topicDescription\": \"test topic\",  \"partitionCount\": 1,  \"replicationCnCount\": 1,  \"transactionEnabled\": \"false\"}"
-echo "Get topics:"
-curl -sk http://$dmaap_url/topics/listAll
-echo -e "\n"
-
-echo "Policy component healthcheck:"
-pap_pod=`kubectl get pods -n onap | grep onap-policy-pap | awk  '{print $1}'`
-api_pod=`kubectl get pods -n onap | grep onap-policy-api | awk  '{print $1}'`
-checkPolicyStatus $pap_pod $api_pod
-echo -e "\n"
-
-echo "Create policy:"
-res=`curl -sk -u 'healthcheck:zb!XztG34' -X POST "https://$api_url/policy/api/v1/policytypes/onap.policies.native.Apex/versions/1.0.0/policies" -H "Accept: application/json" -H "Content-Type: application/json" -d @./data/ToscaPolicy.json`
-res2=`curl -sk -u 'healthcheck:zb!XztG34' -X GET "https://$api_url/policy/api/v1/policytypes/onap.policies.native.Apex/versions/1.0.0/policies/onap.policies.native.apex.LinkMonitor/versions/1.0.0"`
-if [[ $res2 ]]; then
-    echo "Policy created successfully"
-fi
-echo -e "\n"
-
-echo "Deploy the policy to apex-pdp via Policy PAP:"
-curl -sk -u 'healthcheck:zb!XztG34' -X POST "https://$pap_url/policy/pap/v1/pdps/policies" -H "Accept: application/json" -H "Content-Type: application/json" -d @./data/DeployPolicyPAP.json
-echo -e "\n"
-
-echo "Verify policy deployed:"
-checkPolicyDeployment
-echo -e "\n"
-
-echo "Check O-du/O-ru status"
-res=$(curl -sk -H "Authorization: Basic YWRtaW46S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ==" -X GET "http://$sdnc_url/rests/data/network-topology:network-topology/topology=topology-netconf/node=o-du-1122/yang-ext:mount/o-ran-sc-du-hello-world:network-function/du-to-ru-connection=o-ru-11221")
-expected="{\"o-ran-sc-du-hello-world:du-to-ru-connection\":[{\"name\":\"o-ru-11221\",\"operational-state\":\"ENABLED\",\"administrative-state\":\"LOCKED\",\"status\":\"disconnected\"}]}"
-checkStatus $res $expected "O-ru has status LOCKED"
-
-echo -e "\n"
-echo "Wait for a while for Apex engine to be ready before sending Dmaap event"
-verifyApexPolicyStatus
-
-echo -e "\n"
-echo "Wait for a while and check O-du/O-ru status again"
-sleep 5
-res=$(curl -sk -H "Authorization: Basic YWRtaW46S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ==" -X GET "http://$sdnc_url/rests/data/network-topology:network-topology/topology=topology-netconf/node=o-du-1122/yang-ext:mount/o-ran-sc-du-hello-world:network-function/du-to-ru-connection=o-ru-11221")
-expected="{\"o-ran-sc-du-hello-world:du-to-ru-connection\":[{\"name\":\"o-ru-11221\",\"operational-state\":\"ENABLED\",\"administrative-state\":\"UNLOCKED\",\"status\":\"disconnected\"}]}"
-checkStatus $res $expected "O-ru has status UNLOCKED"
-
diff --git a/smo-install/test/pythonsdk/.gitignore b/smo-install/test/pythonsdk/.gitignore
new file mode 100644 (file)
index 0000000..e6ef4a4
--- /dev/null
@@ -0,0 +1,4 @@
+**/__pycache__/**
+unit-tests.xml
+oran-tests.xml
+*.log
diff --git a/smo-install/test/pythonsdk/README.md b/smo-install/test/pythonsdk/README.md
new file mode 100644 (file)
index 0000000..6e440c7
--- /dev/null
@@ -0,0 +1,57 @@
+# Python ORAN SDK
+
+an extension of ONAP SDK, to use ORAN and ONAP components programmatically with Python code
+
+
+## Description
+
+ORAN SDK is an extension of ONAP SDK. Please check [doc](https://python-onapsdk.readthedocs.io/en/latest/index.html) site to find out all the features about ONAP SDK.
+
+This project aims to provide a consistent and complete set of interactions with ORAN’s many services.
+
+Using few python commands, you should be able to run different tests with different components from ONAP and ORAN.
+
+### Setting up development environment
+
+Ensure you have executed the script located in ... scripts/layer-0/0-setup-tests-env.sh
+This will setup eveything for you.
+
+### Testing
+
+This project uses tox to run all the tests and do lint and docstyle checks.
+
+```
+$ tox
+```
+
+#### Unit testing
+To run only the unit test:
+
+```
+$ tox -e unit-tests
+```
+
+#### Integration testing
+
+To run the integration tests, start all the needed ONAP and ORAN components & network simulators first on kubernetes.
+
+Go to *scripts/layer-2* directory and start all the needed components with the scripts.
+
+Then execute the integration tests with command:
+
+```
+$ tox -e oran-tests
+```
+
+#### Code analyse and check style checking
+To run code analyse and check check styles:
+
+```
+$ tox -e pylint
+```
+
+To check compliance with Python docstring conventions:
+
+```
+$ tox -e pydocstyle
+```
diff --git a/smo-install/test/pythonsdk/src/oransdk/__init__.py b/smo-install/test/pythonsdk/src/oransdk/__init__.py
new file mode 100644 (file)
index 0000000..5997462
--- /dev/null
@@ -0,0 +1,4 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# SPDX-License-Identifier: Apache-2.0
+"""ORAN SDK master package."""
diff --git a/smo-install/test/pythonsdk/src/oransdk/a1policymanagement/__init__.py b/smo-install/test/pythonsdk/src/oransdk/a1policymanagement/__init__.py
new file mode 100644 (file)
index 0000000..8ebb67e
--- /dev/null
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: Apache-2.0
+"""ONAP A1 policy management package."""
diff --git a/smo-install/test/pythonsdk/src/oransdk/a1policymanagement/a1policymanagement.py b/smo-install/test/pythonsdk/src/oransdk/a1policymanagement/a1policymanagement.py
new file mode 100644 (file)
index 0000000..25458c6
--- /dev/null
@@ -0,0 +1,112 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# SPDX-License-Identifier: Apache-2.0
+"""ONAP A1 Policy Management."""
+
+from typing import Dict
+from oransdk.configuration import settings
+from onapsdk.onap_service import OnapService
+
+class A1policymanagement(OnapService):
+    """A1 Policy Management library."""
+
+    base_url = settings.A1_POLICY_MANAGEMENT_URL
+    header = {"Accept":"application/json", "Content-Type":"application/json"}
+
+    @classmethod
+    def check_status(cls) -> str:
+        """
+        Get the status of the A1 policy management component.
+
+        Returns:
+            the status of the A1 policy management component
+
+        """
+        url = f"{cls.base_url}/status"
+        status = cls.send_message('GET',
+                                  'Get A1 policy management status',
+                                  url)
+        return status
+
+    @classmethod
+    def get_policy_types(cls) -> Dict:
+        """
+        Get all the policy types.
+
+        Returns:
+            the list of policy types
+
+        """
+        url = f"{cls.base_url}/policy_types"
+        policy_types = cls.send_message_json('GET',
+                                             'Get all the policy types',
+                                             url)
+        return policy_types
+
+    @classmethod
+    def get_policy_type_agent(cls) -> Dict:
+        """
+        Get all the policy types from policy agent.
+
+        Returns:
+            the list of policy types
+
+        """
+        url = f"{cls.base_url}/a1-policy/v2/policy-types"
+        policy_types = cls.send_message_json('GET',
+                                             'Get all the policy types from policy agent',
+                                             url)
+        return policy_types
+
+    @classmethod
+    def get_policy(cls, policy_id) -> Dict:
+        """
+        Get policy.
+
+        Args:
+           type: the policy id
+
+        Returns:
+            the details of the policy
+
+        """
+        url = f"{cls.base_url}/a1-policy/v2/policies/{policy_id}"
+        policy = cls.send_message_json('GET',
+                                       'Get the policy with policy id',
+                                       url)
+        return policy
+
+
+    @classmethod
+    def create_service(cls,
+                       service_data) -> None:
+        """
+        Create service.
+
+        Args:
+           service_data: the service data in binary format
+
+        """
+        url = f"{cls.base_url}/a1-policy/v2/services"
+        cls.send_message('PUT',
+                         'Create Service',
+                         url,
+                         data=service_data,
+                         headers=cls.header)
+
+    @classmethod
+    def create_policy(cls,
+                      policy_data) -> None:
+        """
+        Create policy.
+
+        Args:
+           policy_data: the policy data in binary format
+
+        """
+        url = f"{cls.base_url}/a1-policy/v2/policies"
+        cls.send_message('PUT',
+                         'Create Policy',
+                         url,
+                         data=policy_data,
+                         headers=cls.header)
index 19bbe6b..f5c6239 100644 (file)
@@ -6,18 +6,79 @@
 from onapsdk.onap_service import OnapService
 
 class A1sim(OnapService):
+    """Oran A1 Simulator library."""
 
     @classmethod
-    def check_version(cls, url) -> str:
+    def check_version(cls, base_url) -> str:
         """
         Return ric version.
 
+        Args:
+           base_url: the base url of the ric
+
         Returns:
             the ric version
 
         """
-        url = f"{url}/counter/interface"
+        url = f"{base_url}/counter/interface"
         version = cls.send_message('GET',
                                    'Get ric version',
-                                    url)
+                                   url)
         return version
+
+    @classmethod
+    def check_status(cls, url) -> str:
+        """
+        Return ric status.
+
+        Args:
+           url: the url of the ric
+
+        Returns:
+            the ric status
+
+        """
+        url = f"{url}"
+        status = cls.send_message('GET',
+                                  'Get ric status',
+                                  url)
+        return status
+
+    @classmethod
+    def get_policy_number(cls, url) -> str:
+        """
+        Policy numbers for ric.
+
+        Args:
+           url: the url of the ric
+
+        Returns:
+            the policy numbers for ric
+
+        """
+        url = f"{url}/counter/num_instances"
+        policy_number = cls.send_message('GET',
+                                         'Get policy numbers for ric',
+                                         url)
+        return policy_number
+
+    @classmethod
+    def create_policy_type(cls,
+                           url,
+                           policy_type_id,
+                           policy_type_data) -> None:
+        """
+        Create topic in Dmaap.
+
+        Args:
+           url: the url of the ric
+           policy_type_num: the policy type id
+           policy_type_data: the policy type data in binary format
+
+        """
+        url = f"{url}/policytype?id={policy_type_id}"
+        cls.send_message('PUT',
+                         'Create Policy Type',
+                         url,
+                         data=policy_type_data,
+                         headers={"Accept":"application/json", "Content-Type":"application/json"})
diff --git a/smo-install/test/pythonsdk/src/oransdk/a1sim/templates/OSC/policy_type.json.j2 b/smo-install/test/pythonsdk/src/oransdk/a1sim/templates/OSC/policy_type.json.j2
new file mode 100644 (file)
index 0000000..aeea773
--- /dev/null
@@ -0,0 +1,45 @@
+{
+  "name": "pt1",
+  "description": "pt1 policy type",
+  "policy_type_id": 1,
+  "create_schema": {
+    "$schema": "http://json-schema.org/draft-07/schema#",
+    "title": "OSC_Type1_1.0.0",
+    "description": "Type 1 policy type",
+    "type": "object",
+    "properties": {
+      "scope": {
+        "type": "object",
+        "properties": {
+          "ueId": {
+            "type": "string"
+          },
+          "qosId": {
+            "type": "string"
+          }
+        },
+        "additionalProperties": false,
+        "required": [
+          "ueId",
+          "qosId"
+        ]
+      },
+      "qosObjectives": {
+        "type": "object",
+        "properties": {
+          "priorityLevel": {
+            "type": "number"
+          }
+        },
+        "additionalProperties": false,
+        "required": [
+          "priorityLevel"
+        ]
+      }
+    },
+    "additionalProperties": false,
+    "required": [
+      "scope", "qosObjectives"
+    ]
+  }
+}
diff --git a/smo-install/test/pythonsdk/src/oransdk/a1sim/templates/v2/policy_osc.json.j2 b/smo-install/test/pythonsdk/src/oransdk/a1sim/templates/v2/policy_osc.json.j2
new file mode 100644 (file)
index 0000000..902f911
--- /dev/null
@@ -0,0 +1,16 @@
+{
+    "ric_id": "ric1",
+    "policy_id": "aa8feaa88d944d919ef0e83f2172a5100",
+    "service_id": "controlpanel",
+    "policytype_id": "1",
+    "status_notification_uri": "http://callback-receiver:8090/callbacks/test",
+    "policy_data": {
+        "scope": {
+            "ueId": "ue5100",
+            "qosId": "qos5100"
+        },
+        "qosObjectives": {
+            "priorityLevel": 5100
+        }
+    }
+}
\ No newline at end of file
diff --git a/smo-install/test/pythonsdk/src/oransdk/a1sim/templates/v2/policy_std_v2.json.j2 b/smo-install/test/pythonsdk/src/oransdk/a1sim/templates/v2/policy_std_v2.json.j2
new file mode 100644 (file)
index 0000000..ff5056c
--- /dev/null
@@ -0,0 +1,16 @@
+{
+    "ric_id": "ric5",
+    "policy_id": "aa8feaa88d944d919ef0e83f2172a5000",
+    "service_id": "controlpanel",
+    "policytype_id": "2",
+    "status_notification_uri": "http://callback-receiver:8090/callbacks/test",
+    "policy_data": {
+        "scope": {
+            "ueId": "ue5000",
+            "qosId": "qos5000"
+        },
+        "qosObjectives": {
+            "priorityLevel": 5000
+        }
+    }
+}
\ No newline at end of file
diff --git a/smo-install/test/pythonsdk/src/oransdk/a1sim/templates/v2/policy_type.json.j2 b/smo-install/test/pythonsdk/src/oransdk/a1sim/templates/v2/policy_type.json.j2
new file mode 100644 (file)
index 0000000..931498c
--- /dev/null
@@ -0,0 +1,56 @@
+{
+    "policySchema": {
+      "$schema": "http://json-schema.org/draft-07/schema#",
+      "title": "STD_QOS_0_2_0",
+      "description": "STD QOS policy type",
+      "type": "object",
+      "properties": {
+        "scope": {
+          "type": "object",
+          "properties": {
+            "ueId": {
+              "type": "string"
+            },
+            "qosId": {
+              "type": "string"
+            }
+          },
+          "additionalProperties": false,
+          "required": [
+            "ueId",
+            "qosId"
+          ]
+        },
+        "qosObjectives": {
+          "type": "object",
+          "properties": {
+            "priorityLevel": {
+              "type": "number"
+            }
+          },
+          "additionalProperties": false,
+          "required": [
+            "priorityLevel"
+          ]
+        }
+      }
+    },
+    "statusSchema": {
+      "$schema": "http://json-schema.org/draft-07/schema#",
+      "title": "STD_QOS_0.2.0",
+      "description": "STD QOS 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/smo-install/test/pythonsdk/src/oransdk/a1sim/templates/v2/service.json.j2 b/smo-install/test/pythonsdk/src/oransdk/a1sim/templates/v2/service.json.j2
new file mode 100644 (file)
index 0000000..d984cba
--- /dev/null
@@ -0,0 +1,5 @@
+{
+    "callback_url": "http://callback-receiver:8090/callbacks/ric-registration",
+    "keep_alive_interval_seconds": "0",
+    "service_id": "ric-registration"
+}
\ No newline at end of file
diff --git a/smo-install/test/pythonsdk/src/oransdk/configuration/__init__.py b/smo-install/test/pythonsdk/src/oransdk/configuration/__init__.py
new file mode 100644 (file)
index 0000000..6d08e60
--- /dev/null
@@ -0,0 +1,4 @@
+"""Configuration module."""
+from onapsdk.configuration.loader import SettingsLoader
+
+settings = SettingsLoader()
diff --git a/smo-install/test/pythonsdk/src/oransdk/configuration/global_settings.py b/smo-install/test/pythonsdk/src/oransdk/configuration/global_settings.py
new file mode 100644 (file)
index 0000000..39e85e3
--- /dev/null
@@ -0,0 +1,12 @@
+"""Global settings module."""  # pylint: disable=bad-whitespace
+######################
+#                    #
+# ORAN SERVICES URLS #
+#                    #
+######################
+A1_POLICY_MANAGEMENT_URL        = "http://localhost:8081"
+DMAAP_URL                       = "http://localhost:3904"
+POLICY_PAP_URL                  = "https://localhost:6969"
+POLICY_API_URL                  = "https://localhost:6969"
+SDNC_URL                        = "http://localhost:8282"
+EMS_URL                         = "http://localhost:8083"
diff --git a/smo-install/test/pythonsdk/src/oransdk/dmaap/dmaap.py b/smo-install/test/pythonsdk/src/oransdk/dmaap/dmaap.py
new file mode 100644 (file)
index 0000000..6affd4e
--- /dev/null
@@ -0,0 +1,84 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# SPDX-License-Identifier: Apache-2.0
+"""Oran Dmaap module."""
+
+from oransdk.configuration import settings
+from onapsdk.dmaap.dmaap import Dmaap
+
+class OranDmaap(Dmaap):
+    """Dmaap library provides functions for getting events from Dmaap."""
+
+    base_url = settings.DMAAP_URL
+    get_all_topics_url = f"{base_url}/topics/listAll"
+    header = {"accept": "application/json", "Content-Type": "application/json"}
+
+    @classmethod
+    def create_topic(cls,
+                     topic) -> None:
+        """
+        Create topic in Dmaap.
+
+        Args:
+           topic: the topic to create, in json format
+           basic_auth: (Dict[str, str]) for example:{ 'username': 'bob', 'password': 'secret' }
+
+        """
+        url = f"{cls.base_url}/topics/create"
+        cls.send_message('POST',
+                         'Create Dmaap Topic',
+                         url,
+                         data=topic,
+                         headers=cls.header)
+
+    @classmethod
+    def create_service(cls,
+                       service_data) -> None:
+        """
+        Create Service to policy agent via Dmaap.
+
+        Args:
+           service_data: the service data in binary format
+
+        """
+        OranDmaap._send_event("A1-POLICY-AGENT-READ", service_data, "Create Service via Dmaap")
+
+    @classmethod
+    def send_link_failure_event(cls,
+                                event) -> None:
+        """
+        Send link failure event.
+
+        Args:
+           event: the event to sent, in binary format
+
+        """
+        OranDmaap._send_event("unauthenticated.SEC_FAULT_OUTPUT", event, "Send link failure event")
+
+    @classmethod
+    def get_result(cls) -> str:
+        """
+        Get result from previous request.
+
+        Returns:
+            the result
+
+        """
+        topic = "A1-POLICY-AGENT-WRITE"
+        url = f"{cls.base_url}/events/{topic}/users/policy-agent?timeout=15000&limit=100"
+        result = cls.send_message('GET',
+                                  'Get result from previous request',
+                                  url)
+        return result
+
+    @classmethod
+    def _send_event(cls,
+                    topic,
+                    event_data,
+                    description) -> None:
+        url = f"{cls.base_url}/events/{topic}/"
+        cls.send_message('POST',
+                         description,
+                         url,
+                         data=event_data,
+                         headers=cls.header)
diff --git a/smo-install/test/pythonsdk/src/oransdk/dmaap/templates/LinkFailureEvent.json.j2 b/smo-install/test/pythonsdk/src/oransdk/dmaap/templates/LinkFailureEvent.json.j2
new file mode 100644 (file)
index 0000000..fe1e4bf
--- /dev/null
@@ -0,0 +1,38 @@
+{
+    "event": {
+        "commonEventHeader": {
+            "domain": "fault",
+            "eventId": "nt:network-topology/nt:topology/nt:node/nt:node-id",
+            "eventName": "fault_O-RAN-RU-Fault_Alarms_CUS_Link_Failure",
+            "eventType": "O-RAN-RU-Fault",
+            "sequence": 0,
+            "priority": "Normal",
+            "reportingEntityId": "SDNR",
+            "reportingEntityName": "@controllerName@",
+            "sourceId": "",
+            "sourceName": "o-ru-11221",
+            "startEpochMicrosec": "@timestamp@",
+            "lastEpochMicrosec": "@timestamp@",
+            "nfNamingCode": "",
+            "nfVendorName": "ietf-hardware (RFC8348) /hardware/component[not(parent)][1]/mfg-name",
+            "timeZoneOffset": "+00:00",
+            "version": "4.1",
+            "vesEventListenerVersion": "7.2.1"
+        },
+        "faultFields": {
+            "faultFieldsVersion": "4.0",
+            "alarmCondition": "28",
+            "alarmInterfaceA": "o-ran-fm:alarm-notif/fault-source",
+            "eventSourceType": "ietf-hardware (RFC8348) /hardware/component[not(parent)][1]/mfg-model or \"O-RU\"",
+            "specificProblem": "",
+            "eventSeverity": "CRITICAL",
+            "vfStatus": "Active",
+            "alarmAdditionalInformation": {
+                "eventTime": "@eventTime@",
+                "equipType": "@type@",
+                "vendor": "@vendor@",
+                "model": "@model@"
+            }
+        }
+    }
+}
diff --git a/smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v1/dmaap-msg-pms-status.json.j2 b/smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v1/dmaap-msg-pms-status.json.j2
new file mode 100644 (file)
index 0000000..5c7968e
--- /dev/null
@@ -0,0 +1,14 @@
+[
+    {
+        "apiVersion": "1.0",
+        "operation": "GET",
+        "correlationId": "1596363451067769100",
+        "originatorId": "849e6c6b420",
+        "payload": {},
+        "requestId": "23343221",
+        "target": "policy-agent",
+        "timestamp": "2020-08-02 10:17:31.067784",
+        "type": "request",
+        "url": "/status"
+    }
+]
\ No newline at end of file
diff --git a/smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v1/dmaap-msg-policy-create.json.j2 b/smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v1/dmaap-msg-policy-create.json.j2
new file mode 100644 (file)
index 0000000..23d7bed
--- /dev/null
@@ -0,0 +1,102 @@
+[
+    {
+        "apiVersion": "1.0",
+        "operation": "PUT",
+        "correlationId": "1596304565904621535",
+        "originatorId": "849e6c6b420",
+        "payload": {
+            "scope": {
+                "ueId": "ue3000",
+                "qosId": "qos3000"
+            },
+            "qosObjectives": {
+                "priorityLevel": 3000
+            }
+        },
+        "requestId": "23343221",
+        "target": "policy-agent",
+        "timestamp": "2020-08-01 17:56:05.905035",
+        "type": "request",
+        "url": "/policy?id=0f7bb041e1584b1fa17e87520d70a3000&ric=ric1&service=service1&type=1"
+    },
+    {
+        "apiVersion": "1.0",
+        "operation": "PUT",
+        "correlationId": "1596304566656253556",
+        "originatorId": "849e6c6b420",
+        "payload": {
+            "scope": {
+                "ueId": "ue3100",
+                "qosId": "qos3100"
+            },
+            "qosObjectives": {
+                "priorityLevel": 3100
+            }
+        },
+        "requestId": "23343221",
+        "target": "policy-agent",
+        "timestamp": "2020-08-01 17:56:06.656949",
+        "type": "request",
+        "url": "/policy?id=0f7bb041e1584b1fa17e87520d70a3100&ric=ric1&service=service1&type=1"
+    },
+    {
+        "apiVersion": "1.0",
+        "operation": "PUT",
+        "correlationId": "1596304566656253557",
+        "originatorId": "849e6c6b420",
+        "payload": {
+            "scope": {
+                "ueId": "ue3100",
+                "qosId": "qos3100"
+            },
+            "qosObjectives": {
+                "priorityLevel": 3200
+            }
+        },
+        "requestId": "23343221",
+        "target": "policy-agent",
+        "timestamp": "2020-08-01 17:56:06.656949",
+        "type": "request",
+        "url": "/policy?id=0f7bb041e1584b1fa17e87520d70a3101&ric=ric1&service=service1&type=1"
+    },
+    {
+        "apiVersion": "1.0",
+        "operation": "PUT",
+        "correlationId": "1596304566656253558",
+        "originatorId": "849e6c6b420",
+        "payload": {
+            "scope": {
+                "ueId": "ue3102",
+                "qosId": "qos3102"
+            },
+            "qosObjectives": {
+                "priorityLevel": 3201
+            }
+        },
+        "requestId": "23343221",
+        "target": "policy-agent",
+        "timestamp": "2020-08-01 17:56:06.656949",
+        "type": "request",
+        "url": "/policy?id=0f7bb041e1584b1fa17e87520d70a3102&ric=ric2&service=service1"
+    },
+    {
+        "apiVersion": "1.0",
+        "operation": "PUT",
+        "correlationId": "1596304566656253558",
+        "originatorId": "849e6c6b420",
+        "payload": {
+            "scope": {
+                "ueId": "ue3103",
+                "qosId": "qos3103"
+            },
+            "qosObjectives": {
+                "priorityLevel": 3203
+            }
+        },
+        "requestId": "23343221",
+        "target": "policy-agent",
+        "timestamp": "2020-08-01 17:56:06.656949",
+        "type": "request",
+        "url": "/policy?id=0f7bb041e1584b1fa17e87520d70a3103&ric=ric3&service=service1&type=2"
+    }
+]
\ No newline at end of file
diff --git a/smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v1/dmaap-msg-policy-delete.json.j2 b/smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v1/dmaap-msg-policy-delete.json.j2
new file mode 100644 (file)
index 0000000..6065af3
--- /dev/null
@@ -0,0 +1,50 @@
+[
+    {
+        "apiVersion": "1.0",
+        "operation": "DELETE",
+        "correlationId": "1596304567816229314",
+        "originatorId": "849e6c6b420",
+        "payload": {},
+        "requestId": "23343221",
+        "target": "policy-agent",
+        "timestamp": "2020-08-01 17:56:07.816235",
+        "type": "request",
+        "url": "/policy?id=0f7bb041e1584b1fa17e87520d70a3000"
+    },
+    {
+        "apiVersion": "1.0",
+        "operation": "DELETE",
+        "correlationId": "1596304567816229314",
+        "originatorId": "849e6c6b420",
+        "payload": {},
+        "requestId": "23343221",
+        "target": "policy-agent",
+        "timestamp": "2020-08-01 17:56:07.816235",
+        "type": "request",
+        "url": "/policy?id=0f7bb041e1584b1fa17e87520d70a3100"
+    },
+    {
+        "apiVersion": "1.0",
+        "operation": "DELETE",
+        "correlationId": "1596304567816229314",
+        "originatorId": "849e6c6b420",
+        "payload": {},
+        "requestId": "23343221",
+        "target": "policy-agent",
+        "timestamp": "2020-08-01 17:56:07.816235",
+        "type": "request",
+        "url": "/policy?id=0f7bb041e1584b1fa17e87520d70a3101"
+    },
+    {
+        "apiVersion": "1.0",
+        "operation": "DELETE",
+        "correlationId": "1596304567816229314",
+        "originatorId": "849e6c6b420",
+        "payload": {},
+        "requestId": "23343221",
+        "target": "policy-agent",
+        "timestamp": "2020-08-01 17:56:07.816235",
+        "type": "request",
+        "url": "/policy?id=0f7bb041e1584b1fa17e87520d70a3102"
+    }
+]
\ No newline at end of file
diff --git a/smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v1/dmaap-msg-policy-get.json.j2 b/smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v1/dmaap-msg-policy-get.json.j2
new file mode 100644 (file)
index 0000000..abcaa35
--- /dev/null
@@ -0,0 +1,50 @@
+[
+    {
+        "apiVersion": "1.0",
+        "operation": "GET",
+        "correlationId": "1596304567017739720",
+        "originatorId": "849e6c6b420",
+        "payload": {},
+        "requestId": "23343221",
+        "target": "policy-agent",
+        "timestamp": "2020-08-01 17:56:07.017744",
+        "type": "request",
+        "url": "/policy?id=0f7bb041e1584b1fa17e87520d70a3000"
+    },
+    {
+        "apiVersion": "1.0",
+        "operation": "GET",
+        "correlationId": "1596304567017739720",
+        "originatorId": "849e6c6b420",
+        "payload": {},
+        "requestId": "23343221",
+        "target": "policy-agent",
+        "timestamp": "2020-08-01 17:56:07.017744",
+        "type": "request",
+        "url": "/policy?id=0f7bb041e1584b1fa17e87520d70a3100"
+    },
+    {
+        "apiVersion": "1.0",
+        "operation": "GET",
+        "correlationId": "1596304567017739720",
+        "originatorId": "849e6c6b420",
+        "payload": {},
+        "requestId": "23343221",
+        "target": "policy-agent",
+        "timestamp": "2020-08-01 17:56:07.017744",
+        "type": "request",
+        "url": "/policy?id=0f7bb041e1584b1fa17e87520d70a3101"
+    },
+    {
+        "apiVersion": "1.0",
+        "operation": "GET",
+        "correlationId": "1596304567017739720",
+        "originatorId": "849e6c6b420",
+        "payload": {},
+        "requestId": "23343221",
+        "target": "policy-agent",
+        "timestamp": "2020-08-01 17:56:07.017744",
+        "type": "request",
+        "url": "/policy?id=0f7bb041e1584b1fa17e87520d70a3102"
+    }
+]
\ No newline at end of file
diff --git a/smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v1/dmaap-msg-policy-schemas-get.json.j2 b/smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v1/dmaap-msg-policy-schemas-get.json.j2
new file mode 100644 (file)
index 0000000..05a7975
--- /dev/null
@@ -0,0 +1,13 @@
+[
+    {
+        "type": "request",
+        "correlationId": "c09ac7d1-de62-0016-2000-e63701125557-201",
+        "target": "policy-agent",
+        "timestamp": "2019-05-14T11:44:51.36Z",
+        "apiVersion": "1.0",
+        "originatorId": "849e6c6b420",
+        "requestId": "23343221",
+        "operation": "GET",
+        "url": "/policy_schemas?ric=ric1"
+    }
+]
diff --git a/smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v1/dmaap-msg-rics-get.json.j2 b/smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v1/dmaap-msg-rics-get.json.j2
new file mode 100644 (file)
index 0000000..59562d3
--- /dev/null
@@ -0,0 +1,14 @@
+[
+    {
+        "apiVersion": "1.0",
+        "operation": "GET",
+        "correlationId": "1596363459399504200",
+        "originatorId": "849e6c6b420",
+        "payload": {},
+        "requestId": "23343221",
+        "target": "policy-agent",
+        "timestamp": "2020-08-02 10:17:39.399517",
+        "type": "request",
+        "url": "/rics"
+    }
+]
\ No newline at end of file
diff --git a/smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v1/dmaap-msg-service-create.json.j2 b/smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v1/dmaap-msg-service-create.json.j2
new file mode 100644 (file)
index 0000000..3e3d542
--- /dev/null
@@ -0,0 +1,46 @@
+[
+    {
+        "apiVersion": "1.0",
+        "operation": "PUT",
+        "correlationId": "1596363458549998500",
+        "originatorId": "849e6c6b420",
+        "payload": {
+            "callbackUrl": "http://callback-receiver:8090/callbacks/1",
+            "keepAliveIntervalSeconds": "1000",
+            "serviceName": "serv1"
+        },
+        "requestId": "23343221",
+        "target": "policy-agent",
+        "timestamp": "2020-08-02 10:17:38.550324",
+        "type": "request",
+        "url": "/service"
+    },
+    {
+        "apiVersion": "1.0",
+        "operation": "PUT",
+        "correlationId": "1596363458549998501",
+        "originatorId": "849e6c6b421",
+        "payload": {
+            "callbackUrl": "http://callback-receiver:8090/callbacks/1",
+            "keepAliveIntervalSeconds": "1000",
+            "serviceName": "service1"
+        },
+        "requestId": "23343221",
+        "target": "policy-agent",
+        "timestamp": "2020-08-02 10:17:38.550324",
+        "type": "request",
+        "url": "/service"
+    },
+    {
+        "apiVersion": "1.0",
+        "operation": "PUT",
+        "correlationId": "1596363459196978900",
+        "originatorId": "849e6c6b420",
+        "payload": {},
+        "requestId": "23343221",
+        "target": "policy-agent",
+        "timestamp": "2020-08-02 10:17:39.197067",
+        "type": "request",
+        "url": "/services/keepalive?name=serv1"
+    }
+]
\ No newline at end of file
diff --git a/smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v1/dmaap-msg-services-get.json.j2 b/smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v1/dmaap-msg-services-get.json.j2
new file mode 100644 (file)
index 0000000..e9c2f8c
--- /dev/null
@@ -0,0 +1,14 @@
+[
+    {
+        "apiVersion": "1.0",
+        "operation": "GET",
+        "correlationId": "1596363458896827100",
+        "originatorId": "849e6c6b420",
+        "payload": {},
+        "requestId": "23343221",
+        "target": "policy-agent",
+        "timestamp": "2020-08-02 10:17:38.897367",
+        "type": "request",
+        "url": "/services"
+    }
+]
\ No newline at end of file
diff --git a/smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v2/dmaap-msg-pms-status.json.j2 b/smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v2/dmaap-msg-pms-status.json.j2
new file mode 100644 (file)
index 0000000..439da01
--- /dev/null
@@ -0,0 +1,14 @@
+[
+    {
+        "apiVersion": "1.0",
+        "operation": "GET",
+        "correlationId": "1596363451067769100",
+        "originatorId": "849e6c6b420",
+        "payload": {},
+        "requestId": "23343221",
+        "target": "policy-agent",
+        "timestamp": "2020-08-02 10:17:31.067784",
+        "type": "request",
+        "url": "/a1-policy/v2/status"
+    }
+]
\ No newline at end of file
diff --git a/smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v2/dmaap-msg-policy-create.json.j2 b/smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v2/dmaap-msg-policy-create.json.j2
new file mode 100644 (file)
index 0000000..3b42dfe
--- /dev/null
@@ -0,0 +1,114 @@
+[
+    {
+        "apiVersion": "1.0",
+        "operation": "PUT",
+        "correlationId": "1596304565904621535",
+        "originatorId": "849e6c6b420",
+        "payload": {
+            "policy_data": {
+                "scope": {
+                    "ueId": "ue3010",
+                    "qosId": "qos3010"
+                },
+                "qosObjectives": {
+                    "priorityLevel": 3010
+                }
+            },
+            "policy_id": "0f7bb041e1584b1fa17e87520d70a3010",
+            "policytype_id": "1",
+            "ric_id": "ric1",
+            "service_id": "service2",
+            "status_notification_uri": "http://example.com",
+            "transient": true
+        },
+        "requestId": "23343221",
+        "target": "policy-agent",
+        "timestamp": "2020-08-01 17:56:05.905035",
+        "type": "request",
+        "url": "/a1-policy/v2/policies/"
+    },
+    {
+        "apiVersion": "1.0",
+        "operation": "PUT",
+        "correlationId": "1596304566656253556",
+        "originatorId": "849e6c6b420",
+        "payload": {
+            "policy_data": {
+                "scope": {
+                    "ueId": "ue3120",
+                    "qosId": "qos3120"
+                },
+                "qosObjectives": {
+                    "priorityLevel": 3120
+                }
+            },
+            "policy_id": "0f7bb041e1584b1fa17e87520d70a3120",
+            "policytype_id": "1",
+            "ric_id": "ric1",
+            "service_id": "service2",
+            "status_notification_uri": "http://example.com",
+            "transient": true
+        },
+        "requestId": "23343221",
+        "target": "policy-agent",
+        "timestamp": "2020-08-01 17:56:06.656949",
+        "type": "request",
+        "url": "/a1-policy/v2/policies/"
+    },
+    {
+        "apiVersion": "1.0",
+        "operation": "PUT",
+        "correlationId": "1596304566656253557",
+        "originatorId": "849e6c6b420",
+        "payload": {
+            "policy_data": {
+                "scope": {
+                    "ueId": "ue3131",
+                    "qosId": "qos3131"
+                },
+                "qosObjectives": {
+                    "priorityLevel": 3101
+                }
+            },
+            "policy_id": "0f7bb041e1584b1fa17e87520d70a3131",
+            "policytype_id": "1",
+            "ric_id": "ric1",
+            "service_id": "service2",
+            "status_notification_uri": "http://example.com",
+            "transient": true
+        },
+        "requestId": "23343221",
+        "target": "policy-agent",
+        "timestamp": "2020-08-01 17:56:06.656949",
+        "type": "request",
+        "url": "/a1-policy/v2/policies/"
+    },
+    {
+        "apiVersion": "1.0",
+        "operation": "PUT",
+        "correlationId": "1596304566656253758",
+        "originatorId": "849e6c6b422",
+        "payload": {
+            "policy_data": {
+                "scope": {
+                    "ueId": "ue3153",
+                    "qosId": "qos3153"
+                },
+                "qosObjectives": {
+                    "priorityLevel": 3103
+                }
+            },
+            "policy_id": "0f7bb041e1584b1fa17e87520d70a3153",
+            "policytype_id": "2",
+            "ric_id": "ric2",
+            "service_id": "service2",
+            "status_notification_uri": "http://example.com",
+            "transient": true
+        },
+        "requestId": "23343221",
+        "target": "policy-agent",
+        "timestamp": "2020-08-01 17:56:06.656949",
+        "type": "request",
+        "url": "/a1-policy/v2/policies/"
+    }
+]
\ No newline at end of file
diff --git a/smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v2/dmaap-msg-policy-delete.json.j2 b/smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v2/dmaap-msg-policy-delete.json.j2
new file mode 100644 (file)
index 0000000..1a126fd
--- /dev/null
@@ -0,0 +1,50 @@
+[
+    {
+        "apiVersion": "1.0",
+        "operation": "DELETE",
+        "correlationId": "1596304567816229314",
+        "originatorId": "849e6c6b420",
+        "payload": {},
+        "requestId": "23343221",
+        "target": "policy-agent",
+        "timestamp": "2020-08-01 17:56:07.816235",
+        "type": "request",
+        "url": "/a1-policy/v2/policies/0f7bb041e1584b1fa17e87520d70a3000"
+    },
+    {
+        "apiVersion": "1.0",
+        "operation": "DELETE",
+        "correlationId": "1596304567816229314",
+        "originatorId": "849e6c6b420",
+        "payload": {},
+        "requestId": "23343221",
+        "target": "policy-agent",
+        "timestamp": "2020-08-01 17:56:07.816235",
+        "type": "request",
+        "url": "/a1-policy/v2/policies/0f7bb041e1584b1fa17e87520d70a3100"
+    },
+    {
+        "apiVersion": "1.0",
+        "operation": "DELETE",
+        "correlationId": "1596304567816229314",
+        "originatorId": "849e6c6b420",
+        "payload": {},
+        "requestId": "23343221",
+        "target": "policy-agent",
+        "timestamp": "2020-08-01 17:56:07.816235",
+        "type": "request",
+        "url": "/a1-policy/v2/policies/0f7bb041e1584b1fa17e87520d70a3101"
+    },
+    {
+        "apiVersion": "1.0",
+        "operation": "DELETE",
+        "correlationId": "1596304567816229314",
+        "originatorId": "849e6c6b420",
+        "payload": {},
+        "requestId": "23343221",
+        "target": "policy-agent",
+        "timestamp": "2020-08-01 17:56:07.816235",
+        "type": "request",
+        "url": "/a1-policy/v2/policies/0f7bb041e1584b1fa17e87520d70a3102"
+    }
+]
\ No newline at end of file
diff --git a/smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v2/dmaap-msg-policy-get.json.j2 b/smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v2/dmaap-msg-policy-get.json.j2
new file mode 100644 (file)
index 0000000..a45e06b
--- /dev/null
@@ -0,0 +1,50 @@
+[
+    {
+        "apiVersion": "1.0",
+        "operation": "GET",
+        "correlationId": "1596304567017739720",
+        "originatorId": "849e6c6b420",
+        "payload": {},
+        "requestId": "23343221",
+        "target": "policy-agent",
+        "timestamp": "2020-08-01 17:56:07.017744",
+        "type": "request",
+        "url": "/a1-policy/v2/policies/0f7bb041e1584b1fa17e87520d70a3000"
+    },
+    {
+        "apiVersion": "1.0",
+        "operation": "GET",
+        "correlationId": "1596304567017739720",
+        "originatorId": "849e6c6b420",
+        "payload": {},
+        "requestId": "23343221",
+        "target": "policy-agent",
+        "timestamp": "2020-08-01 17:56:07.017744",
+        "type": "request",
+        "url": "/a1-policy/v2/policies/0f7bb041e1584b1fa17e87520d70a3100"
+    },
+    {
+        "apiVersion": "1.0",
+        "operation": "GET",
+        "correlationId": "1596304567017739720",
+        "originatorId": "849e6c6b420",
+        "payload": {},
+        "requestId": "23343221",
+        "target": "policy-agent",
+        "timestamp": "2020-08-01 17:56:07.017744",
+        "type": "request",
+        "url": "/a1-policy/v2/policies/0f7bb041e1584b1fa17e87520d70a3101"
+    },
+    {
+        "apiVersion": "1.0",
+        "operation": "GET",
+        "correlationId": "1596304567017739720",
+        "originatorId": "849e6c6b420",
+        "payload": {},
+        "requestId": "23343221",
+        "target": "policy-agent",
+        "timestamp": "2020-08-01 17:56:07.017744",
+        "type": "request",
+        "url": "/a1-policy/v2/policies/0f7bb041e1584b1fa17e87520d70a3102"
+    }
+]
\ No newline at end of file
diff --git a/smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v2/dmaap-msg-policy-schemas-get.json.j2 b/smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v2/dmaap-msg-policy-schemas-get.json.j2
new file mode 100644 (file)
index 0000000..b1b2b55
--- /dev/null
@@ -0,0 +1,13 @@
+[
+    {
+        "type": "request",
+        "correlationId": "c09ac7d1-de62-0016-2000-e63701125557-201",
+        "target": "policy-agent",
+        "timestamp": "2019-05-14T11:44:51.36Z",
+        "apiVersion": "1.0",
+        "originatorId": "849e6c6b420",
+        "requestId": "23343221",
+        "operation": "GET",
+        "url": "/a1-policy/v2/policy-types/1"
+    }
+]
diff --git a/smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v2/dmaap-msg-rics-get.json.j2 b/smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v2/dmaap-msg-rics-get.json.j2
new file mode 100644 (file)
index 0000000..9c047c0
--- /dev/null
@@ -0,0 +1,14 @@
+[
+    {
+        "apiVersion": "1.0",
+        "operation": "GET",
+        "correlationId": "1596363459399504200",
+        "originatorId": "849e6c6b420",
+        "payload": {},
+        "requestId": "23343221",
+        "target": "policy-agent",
+        "timestamp": "2020-08-02 10:17:39.399517",
+        "type": "request",
+        "url": "/a1-policy/v2/rics"
+    }
+]
\ No newline at end of file
diff --git a/smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v2/dmaap-msg-service-create.json.j2 b/smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v2/dmaap-msg-service-create.json.j2
new file mode 100644 (file)
index 0000000..1cd9c25
--- /dev/null
@@ -0,0 +1,46 @@
+[
+    {
+        "apiVersion": "1.0",
+        "operation": "PUT",
+        "correlationId": "1596363458549998500",
+        "originatorId": "849e6c6b420",
+        "payload": {
+            "callback_url": "http://callback-receiver:8090/callbacks/1",
+            "keep_alive_interval_seconds": "1000",
+            "service_id": "serv2"
+        },
+        "requestId": "23343221",
+        "target": "policy-agent",
+        "timestamp": "2020-08-02 10:17:38.550324",
+        "type": "request",
+        "url": "/a1-policy/v2/services"
+    },
+    {
+        "apiVersion": "1.0",
+        "operation": "PUT",
+        "correlationId": "1596363458549998501",
+        "originatorId": "849e6c6b421",
+        "payload": {
+            "callback_url": "http://callback-receiver:8090/callbacks/1",
+            "keep_alive_interval_seconds": "1000",
+            "service_id": "service2"
+        },
+        "requestId": "23343221",
+        "target": "policy-agent",
+        "timestamp": "2020-08-02 10:17:38.550324",
+        "type": "request",
+        "url": "/a1-policy/v2/services"
+    },
+    {
+        "apiVersion": "1.0",
+        "operation": "PUT",
+        "correlationId": "1596363459196978900",
+        "originatorId": "849e6c6b420",
+        "payload": {},
+        "requestId": "23343221",
+        "target": "policy-agent",
+        "timestamp": "2020-08-02 10:17:39.197067",
+        "type": "request",
+        "url": "/a1-policy/v2/services/serv2/keepalive"
+    }
+]
\ No newline at end of file
diff --git a/smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v2/dmaap-msg-services-get.json.j2 b/smo-install/test/pythonsdk/src/oransdk/dmaap/templates/v2/dmaap-msg-services-get.json.j2
new file mode 100644 (file)
index 0000000..7d2d153
--- /dev/null
@@ -0,0 +1,14 @@
+[
+    {
+        "apiVersion": "1.0",
+        "operation": "GET",
+        "correlationId": "1596363458896827100",
+        "originatorId": "849e6c6b420",
+        "payload": {},
+        "requestId": "23343221",
+        "target": "policy-agent",
+        "timestamp": "2020-08-02 10:17:38.897367",
+        "type": "request",
+        "url": "a1-policy/v2/services"
+    }
+]
\ No newline at end of file
diff --git a/smo-install/test/pythonsdk/src/oransdk/enrichmentservice/__init__.py b/smo-install/test/pythonsdk/src/oransdk/enrichmentservice/__init__.py
new file mode 100644 (file)
index 0000000..1075384
--- /dev/null
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: Apache-2.0
+"""ORAN Enrichment Service package."""
diff --git a/smo-install/test/pythonsdk/src/oransdk/enrichmentservice/enrichmentservice.py b/smo-install/test/pythonsdk/src/oransdk/enrichmentservice/enrichmentservice.py
new file mode 100644 (file)
index 0000000..eeab909
--- /dev/null
@@ -0,0 +1,209 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# SPDX-License-Identifier: Apache-2.0
+"""Oran Enrichment Service module."""
+
+from oransdk.configuration import settings
+from onapsdk.onap_service import OnapService
+
+class EnrichmentService(OnapService):
+    """Enrichment Service library."""
+
+    base_url = settings.EMS_URL
+    header = {"Content-Type": "application/json"}
+
+    @classmethod
+    def check_status(cls) -> str:
+        """
+        Get the status of the EnrichmentService component.
+
+        Returns:
+            the status of the EnrichmentService component
+
+        """
+        url = f"{cls.base_url}/status"
+        status = cls.send_message('GET',
+                                  'Get EMS status',
+                                  url)
+        return status
+
+    @classmethod
+    def get_eitypes(cls) -> str:
+        """
+        Get all the EiTypes.
+
+        Returns:
+            the list of EiTypes
+
+        """
+        url = f"{cls.base_url}/data-producer/v1/info-types"
+        eitypes = cls.send_message('GET',
+                                   'Get all the EiTypes',
+                                   url,
+                                   headers=cls.header)
+        return eitypes
+
+    @classmethod
+    def get_eitype_individual(cls, eitype_name) -> str:
+        """
+        Get individual EiType.
+
+        Args:
+           eitype_name: the EiType name
+
+        Returns:
+            the details of the EiType
+
+        """
+        url = f"{cls.base_url}/data-producer/v1/info-types/{eitype_name}"
+        eitype = cls.send_message('GET',
+                                  'Get individual EiType',
+                                  url,
+                                  headers=cls.header)
+        return eitype
+
+    @classmethod
+    def get_eiproducers(cls) -> str:
+        """
+        Get all the EiProducers.
+
+        Returns:
+            the list of EiProducers
+
+        """
+        url = f"{cls.base_url}/data-producer/v1/info-producers"
+        eitypes = cls.send_message('GET',
+                                   'Get all the EiProducers',
+                                   url,
+                                   headers=cls.header)
+        return eitypes
+
+    @classmethod
+    def get_eiproducer_individual(cls, producer) -> str:
+        """
+        Get individual EiProducer.
+
+        Args:
+           type: the EiProducer name
+
+        Returns:
+            the details of the EiProducer
+
+        """
+        url = f"{cls.base_url}/data-producer/v1/info-producers/{producer}"
+        eiproducer = cls.send_message('GET',
+                                      'Get individual EiProducer',
+                                      url,
+                                      headers=cls.header)
+        return eiproducer
+
+    @classmethod
+    def get_eiproducer_status(cls, producer) -> str:
+        """
+        Get the status of EiProducer.
+
+        Args:
+           type: the EiProducer name
+
+        Returns:
+            the status of the EiProducer
+
+        """
+        url = f"{cls.base_url}/data-producer/v1/info-producers/{producer}/status"
+        status = cls.send_message('GET',
+                                  'Get the status of EiProducer',
+                                  url,
+                                  headers=cls.header)
+        return status
+
+    @classmethod
+    def get_eijobs(cls) -> str:
+        """
+        Get all the EiJobs.
+
+        Returns:
+            the list of EiJobs
+
+        """
+        url = f"{cls.base_url}/A1-EI/v1/eijobs"
+        eijobs = cls.send_message('GET',
+                                  'Get all the EiJobs',
+                                  url,
+                                  headers=cls.header)
+        return eijobs
+
+    @classmethod
+    def get_eijob_individual(cls, job) -> str:
+        """
+        Get individual EiJob.
+
+        Args:
+           type: the EiJob name
+
+        Returns:
+            the details of the EiJob
+
+        """
+        url = f"{cls.base_url}/A1-EI/v1/eijobs/{job}"
+        eijob = cls.send_message('GET',
+                                 'Get individual EiJob',
+                                 url,
+                                 headers=cls.header)
+        return eijob
+
+    @classmethod
+    def create_eitype(cls,
+                      type_name,
+                      type_data) -> None:
+        """
+        Create EiType.
+
+        Args:
+           type: the EiType name
+           type_data: the EiType data to create, in binary format
+
+        """
+        url = f"{cls.base_url}/data-producer/v1/info-types/{type_name}"
+        cls.send_message('PUT',
+                         'Create EiType',
+                         url,
+                         data=type_data,
+                         headers=cls.header)
+
+    @classmethod
+    def create_eiproducer(cls,
+                          producer,
+                          producer_data) -> None:
+        """
+        Create EiProducer.
+
+        Args:
+           producer: the EiProducer name
+           producer_data: the EiProducer data to create, in binary format
+
+        """
+        url = f"{cls.base_url}/data-producer/v1/info-producers/{producer}"
+        cls.send_message('PUT',
+                         'Create EiProducer',
+                         url,
+                         data=producer_data,
+                         headers=cls.header)
+
+    @classmethod
+    def create_eijob(cls,
+                     job,
+                     job_data) -> None:
+        """
+        Create EiJob.
+
+        Args:
+           job: the EiJob name
+           job_data: the EiJob data to create, in binary format
+
+        """
+        url = f"{cls.base_url}/A1-EI/v1/eijobs/{job}"
+        cls.send_message('PUT',
+                         'Create EiJob',
+                         url,
+                         data=job_data,
+                         headers=cls.header)
diff --git a/smo-install/test/pythonsdk/src/oransdk/enrichmentservice/templates/EiJob.json.j2 b/smo-install/test/pythonsdk/src/oransdk/enrichmentservice/templates/EiJob.json.j2
new file mode 100644 (file)
index 0000000..003c70f
--- /dev/null
@@ -0,0 +1,11 @@
+{
+    "eiTypeId": "type1",
+    "jobResultUri": "https://ricsim_g3_1:8185/datadelivery",
+    "jobOwner": "ricsim_g3_1",
+    "jobStatusNotificationUri": "http://producer:80/",
+    "jobDefinition": {
+        "jobparam1": "value1_job1",
+        "jobparam2": "value2_job1",
+        "jobparam3": "value3_job1"
+    }
+}
\ No newline at end of file
diff --git a/smo-install/test/pythonsdk/src/oransdk/enrichmentservice/templates/EiProducer.json.j2 b/smo-install/test/pythonsdk/src/oransdk/enrichmentservice/templates/EiProducer.json.j2
new file mode 100644 (file)
index 0000000..a691e8b
--- /dev/null
@@ -0,0 +1,5 @@
+{
+    "supported_info_types": ["type1"],
+    "info_job_callback_url": "http://producer:80/callbacks/job/prod-a",
+    "info_producer_supervision_callback_url": "http://producer:80/callbacks/supervision/prod-a"
+}
\ No newline at end of file
diff --git a/smo-install/test/pythonsdk/src/oransdk/enrichmentservice/templates/EiType.json.j2 b/smo-install/test/pythonsdk/src/oransdk/enrichmentservice/templates/EiType.json.j2
new file mode 100644 (file)
index 0000000..03762e5
--- /dev/null
@@ -0,0 +1,8 @@
+{
+    "info_job_data_schema":{
+       "$schema":"http://json-schema.org/draft-07/schema#",
+       "title":"STD_Type1_1.0.0",
+       "description":"EI-Type 1",
+       "type":"object"
+    }
+ }
\ No newline at end of file
diff --git a/smo-install/test/pythonsdk/src/oransdk/policy/__init__.py b/smo-install/test/pythonsdk/src/oransdk/policy/__init__.py
new file mode 100644 (file)
index 0000000..f96dfc9
--- /dev/null
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: Apache-2.0
+"""ONAP Policy package."""
diff --git a/smo-install/test/pythonsdk/src/oransdk/policy/policy.py b/smo-install/test/pythonsdk/src/oransdk/policy/policy.py
new file mode 100644 (file)
index 0000000..3413909
--- /dev/null
@@ -0,0 +1,130 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# SPDX-License-Identifier: Apache-2.0
+"""Onap Policy module."""
+
+from dataclasses import dataclass
+from typing import Dict
+from oransdk.configuration import settings
+from onapsdk.onap_service import OnapService
+
+@dataclass
+class PolicyType:
+    """PolicyType dataclass."""
+
+    type: str
+    version: str
+
+
+class OranPolicy(OnapService):
+    """Onap Policy library."""
+
+    pap_url = settings.POLICY_PAP_URL
+    api_url = settings.POLICY_API_URL
+    header = {"Accept": "application/json", "Content-Type": "application/json"}
+
+    @classmethod
+    def get_components_status(cls,
+                              basic_auth: Dict[str, str]) -> Dict:
+        """
+        Get status of Policy component.
+
+        Args:
+           basic_auth: (Dict[str, str]) for example:{ 'username': 'bob', 'password': 'secret' }
+
+        Returns:
+           the status of the Policy component
+
+        """
+        url = f"{cls.pap_url}/policy/pap/v1/components/healthcheck"
+        status = cls.send_message_json('GET',
+                                       'Get status of Policy component',
+                                       url,
+                                       basic_auth=basic_auth)
+        return status
+
+    @classmethod
+    def get_policy_status(cls,
+                          basic_auth: Dict[str, str]) -> Dict:
+        """
+        Get status of all the policies.
+
+        Returns:
+           the status of all the policies
+
+        """
+        url = f"{cls.pap_url}/policy/pap/v1/policies/status"
+        status = cls.send_message_json('GET',
+                                       'Get status of all the policies',
+                                       url,
+                                       basic_auth=basic_auth)
+        return status
+
+    @classmethod
+    def get_policy(cls,
+                   policy_type: PolicyType,
+                   policy_name,
+                   policy_version,
+                   basic_auth: Dict[str, str]) -> Dict:
+        """
+        Get the policy.
+
+        Args:
+           policy_type: the policy type
+           policy_name: the policy name
+           policy_version: the version of the policy
+           basic_auth: (Dict[str, str]) for example:{ 'username': 'bob', 'password': 'secret' }
+
+        Returns:
+           the policy
+
+        """
+        url = f"{cls.api_url}/policy/api/v1/policytypes/{policy_type.type}/versions/"\
+              + f"{policy_type.version}/policies/{policy_name}/versions/{policy_version}"
+        policy = cls.send_message_json('GET',
+                                       'Get the policy',
+                                       url,
+                                       basic_auth=basic_auth)
+        return policy
+
+    @classmethod
+    def create_policy(cls,
+                      policy_type: PolicyType,
+                      policy_data,
+                      basic_auth: Dict[str, str]) -> None:
+        """
+        Create a policy.
+
+        Args:
+           policy_type: the policy type
+           type_version: the version of the policy type
+           policy_data: the policy to be created, in binary format
+
+        """
+        url = f"{cls.api_url}/policy/api/v1/policytypes/{policy_type.type}/"\
+              + f"versions/{policy_type.version}/policies"
+        cls.send_message('POST',
+                         'Create Policy',
+                         url,
+                         data=policy_data,
+                         headers=cls.header,
+                         basic_auth=basic_auth)
+
+    @classmethod
+    def deploy_policy(cls,
+                      policy_data,
+                      basic_auth: Dict[str, str]) -> None:
+        """
+        Deploy a policy.
+
+        Args:
+           policy_data: the policy to be deployed, in binary format
+
+        """
+        url = f"{cls.pap_url}/policy/pap/v1/pdps/policies"
+        cls.send_message('POST',
+                         'Deploy Policy',
+                         url,
+                         data=policy_data,
+                         headers=cls.header,
+                         basic_auth=basic_auth)
diff --git a/smo-install/test/pythonsdk/src/oransdk/policy/templates/DeployPolicyPAP.json.j2 b/smo-install/test/pythonsdk/src/oransdk/policy/templates/DeployPolicyPAP.json.j2
new file mode 100644 (file)
index 0000000..68eab98
--- /dev/null
@@ -0,0 +1,8 @@
+{
+  "policies": [
+    {
+      "policy-id": "onap.policies.native.apex.LinkMonitor",
+      "policy-version": "1.0.0"
+    }
+  ]
+}
diff --git a/smo-install/test/pythonsdk/src/oransdk/policy/templates/ToscaPolicy.json.j2 b/smo-install/test/pythonsdk/src/oransdk/policy/templates/ToscaPolicy.json.j2
new file mode 100644 (file)
index 0000000..6974128
--- /dev/null
@@ -0,0 +1 @@
+{"tosca_definitions_version":"tosca_simple_yaml_1_1_0","topology_template":{"policies":[{"onap.policies.native.apex.LinkMonitor":{"type":"onap.policies.native.Apex","type_version":"1.0.0","name":"onap.policies.native.apex.LinkMonitor","version":"1.0.0","properties":{"engineServiceParameters":{"name":"LinkMonitorApexEngine","version":"0.0.1","id":101,"instanceCount":1,"deploymentPort":12345,"engineParameters":{"executorParameters":{"JAVASCRIPT":{"parameterClassName":"org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"}},"contextParameters":{"parameterClassName":"org.onap.policy.apex.context.parameters.ContextParameters","schemaParameters":{"Avro":{"parameterClassName":"org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters"}}},"taskParameters":[{"key":"ORU-ODU-Map","value":"{\"o-ru-11221\": \"o-du-1122\"}"}]},"policy_type_impl":{"apexPolicyModel":{"key":{"name":"LinkMonitorModel","version":"0.0.1"},"keyInformation":{"key":{"name":"LinkMonitorModel_KeyInfo","version":"0.0.1"},"keyInfoMap":{"entry":[{"key":{"name":"ApexMessageOutputEvent","version":"0.0.1"},"value":{"key":{"name":"ApexMessageOutputEvent","version":"0.0.1"},"UUID":"cca47d74-7754-4a61-b163-ca31f66b157b","description":"Generated description for concept referred to by key \"ApexMessageOutputEvent:0.0.1\""}},{"key":{"name":"CreateLinkClearedOutfieldsEvent","version":"0.0.1"},"value":{"key":{"name":"CreateLinkClearedOutfieldsEvent","version":"0.0.1"},"UUID":"a295d6a3-1b73-387e-abba-b41e9b608802","description":"Generated description for concept referred to by key \"CreateLinkClearedOutfieldsEvent:0.0.1\""}},{"key":{"name":"CreateLinkClearedOutfieldsTask","version":"0.0.1"},"value":{"key":{"name":"CreateLinkClearedOutfieldsTask","version":"0.0.1"},"UUID":"fd594e88-411d-4a94-b2be-697b3a0d7adf","description":"This task creates the output fields when link failure is cleared."}},{"key":{"name":"CreateLinkFailureOutfieldsEvent","version":"0.0.1"},"value":{"key":{"name":"CreateLinkFailureOutfieldsEvent","version":"0.0.1"},"UUID":"02be2b5d-45b7-3c54-ae54-97f2b5c30125","description":"Generated description for concept referred to by key \"CreateLinkFailureOutfieldsEvent:0.0.1\""}},{"key":{"name":"CreateLinkFailureOutfieldsTask","version":"0.0.1"},"value":{"key":{"name":"CreateLinkFailureOutfieldsTask","version":"0.0.1"},"UUID":"ac3d9842-80af-4a98-951c-bd79a431c613","description":"This task the output fields when link failure is detected."}},{"key":{"name":"LinkClearedTask","version":"0.0.1"},"value":{"key":{"name":"LinkClearedTask","version":"0.0.1"},"UUID":"eecfde90-896c-4343-8f9c-2603ced94e2d","description":"This task sends a message to the output when link failure is cleared."}},{"key":{"name":"LinkFailureInputEvent","version":"0.0.1"},"value":{"key":{"name":"LinkFailureInputEvent","version":"0.0.1"},"UUID":"c4500941-3f98-4080-a9cc-5b9753ed050b","description":"Generated description for concept referred to by key \"LinkFailureInputEvent:0.0.1\""}},{"key":{"name":"LinkFailureInputSchema","version":"0.0.1"},"value":{"key":{"name":"LinkFailureInputSchema","version":"0.0.1"},"UUID":"3b3974fc-3012-3b02-9f33-c9d8eefe4dc1","description":"Generated description for concept referred to by key \"LinkFailureInputSchema:0.0.1\""}},{"key":{"name":"LinkFailureOutputEvent","version":"0.0.1"},"value":{"key":{"name":"LinkFailureOutputEvent","version":"0.0.1"},"UUID":"4f04aa98-e917-4f4a-882a-c75ba5a99374","description":"Generated description for concept referred to by key \"LinkFailureOutputEvent:0.0.1\""}},{"key":{"name":"LinkFailureOutputSchema","version":"0.0.1"},"value":{"key":{"name":"LinkFailureOutputSchema","version":"0.0.1"},"UUID":"2d1a7f6e-eb9a-3984-be1f-283d98111b84","description":"Generated description for concept referred to by key \"LinkFailureOutputSchema:0.0.1\""}},{"key":{"name":"LinkFailureTask","version":"0.0.1"},"value":{"key":{"name":"LinkFailureTask","version":"0.0.1"},"UUID":"3351b0f4-cf06-4fa2-8823-edf67bd30223","description":"This task updates the config for O-RU when link failure is detected."}},{"key":{"name":"LinkMonitorModel","version":"0.0.1"},"value":{"key":{"name":"LinkMonitorModel","version":"0.0.1"},"UUID":"540226fb-55ee-4f0e-a444-983a0494818e","description":"This is the Apex Policy Model for link monitoring."}},{"key":{"name":"LinkMonitorModel_Events","version":"0.0.1"},"value":{"key":{"name":"LinkMonitorModel_Events","version":"0.0.1"},"UUID":"27ad3e7e-fe3b-3bd6-9081-718705c2bcea","description":"Generated description for concept referred to by key \"LinkMonitorModel_Events:0.0.1\""}},{"key":{"name":"LinkMonitorModel_KeyInfo","version":"0.0.1"},"value":{"key":{"name":"LinkMonitorModel_KeyInfo","version":"0.0.1"},"UUID":"ea0b5f58-eefd-358a-9660-840c640bf981","description":"Generated description for concept referred to by key \"LinkMonitorModel_KeyInfo:0.0.1\""}},{"key":{"name":"LinkMonitorModel_Policies","version":"0.0.1"},"value":{"key":{"name":"LinkMonitorModel_Policies","version":"0.0.1"},"UUID":"ee9e0b0f-2b7d-3ab7-9a98-c5ec05ed823d","description":"Generated description for concept referred to by key \"LinkMonitorModel_Policies:0.0.1\""}},{"key":{"name":"LinkMonitorModel_Schemas","version":"0.0.1"},"value":{"key":{"name":"LinkMonitorModel_Schemas","version":"0.0.1"},"UUID":"fa5f9b8f-796c-3c70-84e9-5140c958c4bb","description":"Generated description for concept referred to by key \"LinkMonitorModel_Schemas:0.0.1\""}},{"key":{"name":"LinkMonitorModel_Tasks","version":"0.0.1"},"value":{"key":{"name":"LinkMonitorModel_Tasks","version":"0.0.1"},"UUID":"eec592f7-69d5-39a9-981a-e552f787ed01","description":"Generated description for concept referred to by key \"LinkMonitorModel_Tasks:0.0.1\""}},{"key":{"name":"LinkMonitorPolicy","version":"0.0.1"},"value":{"key":{"name":"LinkMonitorPolicy","version":"0.0.1"},"UUID":"6c5e410f-489a-46ff-964e-982ce6e8b6d0","description":"Generated description for concept referred to by key \"LinkMonitorPolicy:0.0.1\""}},{"key":{"name":"MessageSchema","version":"0.0.1"},"value":{"key":{"name":"MessageSchema","version":"0.0.1"},"UUID":"ac4b34ac-39d6-3393-a267-8d5b84854018","description":"A schema for messages from apex"}},{"key":{"name":"NoPolicyDefinedTask","version":"0.0.1"},"value":{"key":{"name":"NoPolicyDefinedTask","version":"0.0.1"},"UUID":"d48b619e-d00d-4008-b884-02d76ea4350b","description":"This task sends a message to the output when an event is received for which no policy has been defined."}},{"key":{"name":"OduIdSchema","version":"0.0.1"},"value":{"key":{"name":"OduIdSchema","version":"0.0.1"},"UUID":"50662174-a88b-3cbd-91bd-8e91b40b2660","description":"A schema for O-DU-ID"}},{"key":{"name":"OruIdSchema","version":"0.0.1"},"value":{"key":{"name":"OruIdSchema","version":"0.0.1"},"UUID":"54daf32b-015f-39cd-8530-a1175c5553e9","description":"A schema for O-RU-ID"}}]}},"policies":{"key":{"name":"LinkMonitorModel_Policies","version":"0.0.1"},"policyMap":{"entry":[{"key":{"name":"LinkMonitorPolicy","version":"0.0.1"},"value":{"policyKey":{"name":"LinkMonitorPolicy","version":"0.0.1"},"template":"Freestyle","state":{"entry":[{"key":"LinkClearedState","value":{"stateKey":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"NULL","localName":"LinkClearedState"},"trigger":{"name":"CreateLinkClearedOutfieldsEvent","version":"0.0.1"},"stateOutputs":{"entry":[{"key":"LinkClearedLogic_Output_Direct","value":{"key":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkClearedState","localName":"LinkClearedLogic_Output_Direct"},"outgoingEvent":{"name":"ApexMessageOutputEvent","version":"0.0.1"},"nextState":{"parentKeyName":"NULL","parentKeyVersion":"0.0.0","parentLocalName":"NULL","localName":"NULL"}}}]},"contextAlbumReference":[],"taskSelectionLogic":{"key":"NULL","logicFlavour":"UNDEFINED","logic":""},"stateFinalizerLogicMap":{"entry":[]},"defaultTask":{"name":"LinkClearedTask","version":"0.0.1"},"taskReferences":{"entry":[{"key":{"name":"LinkClearedTask","version":"0.0.1"},"value":{"key":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkClearedState","localName":"LinkClearedTask"},"outputType":"DIRECT","output":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkClearedState","localName":"LinkClearedLogic_Output_Direct"}}}]}}},{"key":"LinkFailureOrClearedState","value":{"stateKey":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"NULL","localName":"LinkFailureOrClearedState"},"trigger":{"name":"LinkFailureInputEvent","version":"0.0.1"},"stateOutputs":{"entry":[{"key":"CreateLinkClearedOutfieldsLogic_Output_Direct","value":{"key":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkFailureOrClearedState","localName":"CreateLinkClearedOutfieldsLogic_Output_Direct"},"outgoingEvent":{"name":"CreateLinkClearedOutfieldsEvent","version":"0.0.1"},"nextState":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"NULL","localName":"LinkClearedState"}}},{"key":"CreateLinkFailureOutfieldsLogic_Output_Direct","value":{"key":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkFailureOrClearedState","localName":"CreateLinkFailureOutfieldsLogic_Output_Direct"},"outgoingEvent":{"name":"CreateLinkFailureOutfieldsEvent","version":"0.0.1"},"nextState":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"NULL","localName":"LinkFailureState"}}},{"key":"NoPolicyDefinedLogic_Output_Direct","value":{"key":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkFailureOrClearedState","localName":"NoPolicyDefinedLogic_Output_Direct"},"outgoingEvent":{"name":"ApexMessageOutputEvent","version":"0.0.1"},"nextState":{"parentKeyName":"NULL","parentKeyVersion":"0.0.0","parentLocalName":"NULL","localName":"NULL"}}}]},"contextAlbumReference":[],"taskSelectionLogic":{"key":"TaskSelectionLogic","logicFlavour":"JAVASCRIPT","logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2021 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(\"Task Selection Execution: '\"+executor.subject.id+\n    \"'. InputFields: '\"+executor.inFields+\"'\");\n\nvar linkFailureInput = executor.inFields.get(\"LinkFailureInput\");\nvar commonEventHeader = linkFailureInput.get(\"event\").get(\"commonEventHeader\");\nvar domain = commonEventHeader.get(\"domain\");\n\ntaskFailure = executor.subject.getTaskKey(\"CreateLinkFailureOutfieldsTask\");\ntaskCleared = executor.subject.getTaskKey(\"CreateLinkClearedOutfieldsTask\");\ntaskDefault = executor.subject.getDefaultTaskKey();\n\nif (domain == \"fault\") {\n    var faultFields = linkFailureInput.get(\"event\").get(\"faultFields\");\n    var alarmCondition = faultFields.get(\"alarmCondition\");\n    var eventSeverity = faultFields.get(\"eventSeverity\");\n    if (alarmCondition == \"28\" && eventSeverity != \"NORMAL\") {\n        taskFailure.copyTo(executor.selectedTask);\n    } else if (alarmCondition == \"28\" && eventSeverity == \"NORMAL\") {\n        taskCleared.copyTo(executor.selectedTask);\n    } else {\n        taskDefault.copyTo(executor.selectedTask);\n    }\n} else {\n    taskDefault.copyTo(executor.selectedTask);\n}\n\ntrue;"},"stateFinalizerLogicMap":{"entry":[]},"defaultTask":{"name":"NoPolicyDefinedTask","version":"0.0.1"},"taskReferences":{"entry":[{"key":{"name":"CreateLinkClearedOutfieldsTask","version":"0.0.1"},"value":{"key":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkFailureOrClearedState","localName":"CreateLinkClearedOutfieldsTask"},"outputType":"DIRECT","output":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkFailureOrClearedState","localName":"CreateLinkClearedOutfieldsLogic_Output_Direct"}}},{"key":{"name":"CreateLinkFailureOutfieldsTask","version":"0.0.1"},"value":{"key":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkFailureOrClearedState","localName":"CreateLinkFailureOutfieldsTask"},"outputType":"DIRECT","output":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkFailureOrClearedState","localName":"CreateLinkFailureOutfieldsLogic_Output_Direct"}}},{"key":{"name":"NoPolicyDefinedTask","version":"0.0.1"},"value":{"key":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkFailureOrClearedState","localName":"NoPolicyDefinedTask"},"outputType":"DIRECT","output":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkFailureOrClearedState","localName":"NoPolicyDefinedLogic_Output_Direct"}}}]}}},{"key":"LinkFailureState","value":{"stateKey":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"NULL","localName":"LinkFailureState"},"trigger":{"name":"CreateLinkFailureOutfieldsEvent","version":"0.0.1"},"stateOutputs":{"entry":[{"key":"LinkFailureLogic_Output_Direct","value":{"key":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkFailureState","localName":"LinkFailureLogic_Output_Direct"},"outgoingEvent":{"name":"LinkFailureOutputEvent","version":"0.0.1"},"nextState":{"parentKeyName":"NULL","parentKeyVersion":"0.0.0","parentLocalName":"NULL","localName":"NULL"}}}]},"contextAlbumReference":[],"taskSelectionLogic":{"key":"NULL","logicFlavour":"UNDEFINED","logic":""},"stateFinalizerLogicMap":{"entry":[]},"defaultTask":{"name":"LinkFailureTask","version":"0.0.1"},"taskReferences":{"entry":[{"key":{"name":"LinkFailureTask","version":"0.0.1"},"value":{"key":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkFailureState","localName":"LinkFailureTask"},"outputType":"DIRECT","output":{"parentKeyName":"LinkMonitorPolicy","parentKeyVersion":"0.0.1","parentLocalName":"LinkFailureState","localName":"LinkFailureLogic_Output_Direct"}}}]}}}]},"firstState":"LinkFailureOrClearedState"}}]}},"tasks":{"key":{"name":"LinkMonitorModel_Tasks","version":"0.0.1"},"taskMap":{"entry":[{"key":{"name":"CreateLinkClearedOutfieldsTask","version":"0.0.1"},"value":{"key":{"name":"CreateLinkClearedOutfieldsTask","version":"0.0.1"},"inputFields":{"entry":[{"key":"LinkFailureInput","value":{"key":"LinkFailureInput","fieldSchemaKey":{"name":"LinkFailureInputSchema","version":"0.0.1"},"optional":false}}]},"outputFields":{"entry":[{"key":"OruId","value":{"key":"OruId","fieldSchemaKey":{"name":"OruIdSchema","version":"0.0.1"},"optional":false}}]},"taskParameters":{"entry":[]},"contextAlbumReference":[],"taskLogic":{"key":"TaskLogic","logicFlavour":"JAVASCRIPT","logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2021 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(\"Task Execution: '\"+executor.subject.id+\"'. Input Fields: '\"+executor.inFields+\"'\");\n\nvar linkFailureInput = executor.inFields.get(\"LinkFailureInput\");\nvar oruId = linkFailureInput.get(\"event\").get(\"commonEventHeader\").get(\"sourceName\");\n\nexecutor.outFields.put(\"OruId\", oruId);\n\nexecutor.logger.info(executor.outFields);\n\ntrue;"}}},{"key":{"name":"CreateLinkFailureOutfieldsTask","version":"0.0.1"},"value":{"key":{"name":"CreateLinkFailureOutfieldsTask","version":"0.0.1"},"inputFields":{"entry":[{"key":"LinkFailureInput","value":{"key":"LinkFailureInput","fieldSchemaKey":{"name":"LinkFailureInputSchema","version":"0.0.1"},"optional":false}}]},"outputFields":{"entry":[{"key":"OduId","value":{"key":"OduId","fieldSchemaKey":{"name":"OduIdSchema","version":"0.0.1"},"optional":false}},{"key":"OruId","value":{"key":"OruId","fieldSchemaKey":{"name":"OruIdSchema","version":"0.0.1"},"optional":false}}]},"taskParameters":{"entry":[]},"contextAlbumReference":[],"taskLogic":{"key":"TaskLogic","logicFlavour":"JAVASCRIPT","logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2021 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(\"Task Execution: '\"+executor.subject.id+\"'. Input Fields: '\"+executor.inFields+\"'\");\n\nvar returnValue = true;\nvar linkFailureInput = executor.inFields.get(\"LinkFailureInput\");\nvar oruId = linkFailureInput.get(\"event\").get(\"commonEventHeader\").get(\"sourceName\");\nvar oruOduMap = JSON.parse(executor.parameters.get(\"ORU-ODU-Map\"));\n\nif (oruId in oruOduMap) {\n    var oduId = oruOduMap[oruId];\n    executor.outFields.put(\"OruId\", oruId);\n    executor.outFields.put(\"OduId\", oduId);\n    executor.logger.info(executor.outFields);\n} else {\n    executor.message = \"No O-RU found in the config with this ID: \" + oruId;\n    returnValue = false;\n}\n\nreturnValue;"}}},{"key":{"name":"LinkClearedTask","version":"0.0.1"},"value":{"key":{"name":"LinkClearedTask","version":"0.0.1"},"inputFields":{"entry":[{"key":"OruId","value":{"key":"OruId","fieldSchemaKey":{"name":"OruIdSchema","version":"0.0.1"},"optional":false}}]},"outputFields":{"entry":[{"key":"message","value":{"key":"message","fieldSchemaKey":{"name":"MessageSchema","version":"0.0.1"},"optional":false}}]},"taskParameters":{"entry":[]},"contextAlbumReference":[],"taskLogic":{"key":"TaskLogic","logicFlavour":"JAVASCRIPT","logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2021 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(\"Task Execution: '\"+executor.subject.id+\"'. Input Fields: '\"+executor.inFields+\"'\");\n\nvar oruId = executor.inFields.get(\"OruId\");\n\nexecutor.outFields.put(\"message\", \"CLEARED link failure for O-RU: \" + oruId);\n\nexecutor.logger.info(executor.outFields);\n\ntrue;"}}},{"key":{"name":"LinkFailureTask","version":"0.0.1"},"value":{"key":{"name":"LinkFailureTask","version":"0.0.1"},"inputFields":{"entry":[{"key":"OduId","value":{"key":"OduId","fieldSchemaKey":{"name":"OduIdSchema","version":"0.0.1"},"optional":false}},{"key":"OruId","value":{"key":"OruId","fieldSchemaKey":{"name":"OruIdSchema","version":"0.0.1"},"optional":false}}]},"outputFields":{"entry":[{"key":"LinkFailureOutput","value":{"key":"LinkFailureOutput","fieldSchemaKey":{"name":"LinkFailureOutputSchema","version":"0.0.1"},"optional":false}}]},"taskParameters":{"entry":[]},"contextAlbumReference":[],"taskLogic":{"key":"TaskLogic","logicFlavour":"JAVASCRIPT","logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2021 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(\"Task Execution: '\"+executor.subject.id+\"'. Input Fields: '\"+executor.inFields+\"'\");\n\nvar linkFailureOutput = executor.subject.getOutFieldSchemaHelper(\"LinkFailureOutput\").createNewInstance();\n\nvar oruId = executor.inFields.get(\"OruId\");\nvar oduId = executor.inFields.get(\"OduId\");\n\nvar unlockMessageArray = new java.util.ArrayList();\nfor (var i = 0; i < 1; i++) {\n    unlockMessageArray.add({\n        \"name\" : oruId,\n        \"administrative_DasH_state\" : \"UNLOCKED\"\n    });\n}\n\nlinkFailureOutput.put(\"o_DasH_ran_DasH_sc_DasH_du_DasH_hello_DasH_world_ColoN_du_DasH_to_DasH_ru_DasH_connection\", unlockMessageArray);\nexecutor.outFields.put(\"LinkFailureOutput\", linkFailureOutput.toString());\n\nexecutor.getExecutionProperties().setProperty(\"OduId\", oduId);\nexecutor.getExecutionProperties().setProperty(\"OruId\", oruId);\n\nexecutor.logger.info(executor.outFields);\n\ntrue;"}}},{"key":{"name":"NoPolicyDefinedTask","version":"0.0.1"},"value":{"key":{"name":"NoPolicyDefinedTask","version":"0.0.1"},"inputFields":{"entry":[{"key":"LinkFailureInput","value":{"key":"LinkFailureInput","fieldSchemaKey":{"name":"LinkFailureInputSchema","version":"0.0.1"},"optional":false}}]},"outputFields":{"entry":[{"key":"message","value":{"key":"message","fieldSchemaKey":{"name":"MessageSchema","version":"0.0.1"},"optional":false}}]},"taskParameters":{"entry":[]},"contextAlbumReference":[],"taskLogic":{"key":"TaskLogic","logicFlavour":"JAVASCRIPT","logic":"/*\n * ============LICENSE_START=======================================================\n * Copyright (C) 2021 Nordix Foundation.\n * ================================================================================\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n * ============LICENSE_END=========================================================\n */\n\nexecutor.logger.info(\"Task Execution: '\"+executor.subject.id+\"'. Input Fields: '\"+executor.inFields+\"'\");\n\nexecutor.outFields.put(\"message\", \"No policy defined for this event\");\n\nexecutor.logger.info(executor.outFields);\n\ntrue;"}}}]}},"events":{"key":{"name":"LinkMonitorModel_Events","version":"0.0.1"},"eventMap":{"entry":[{"key":{"name":"ApexMessageOutputEvent","version":"0.0.1"},"value":{"key":{"name":"ApexMessageOutputEvent","version":"0.0.1"},"nameSpace":"org.onap.policy.apex.auth.clieditor","source":"APEX","target":"APEX","parameter":{"entry":[{"key":"message","value":{"key":"message","fieldSchemaKey":{"name":"MessageSchema","version":"0.0.1"},"optional":false}}]}}},{"key":{"name":"CreateLinkClearedOutfieldsEvent","version":"0.0.1"},"value":{"key":{"name":"CreateLinkClearedOutfieldsEvent","version":"0.0.1"},"nameSpace":"org.onap.policy.apex.auth.clieditor","source":"APEX","target":"APEX","parameter":{"entry":[{"key":"OruId","value":{"key":"OruId","fieldSchemaKey":{"name":"OruIdSchema","version":"0.0.1"},"optional":false}}]}}},{"key":{"name":"CreateLinkFailureOutfieldsEvent","version":"0.0.1"},"value":{"key":{"name":"CreateLinkFailureOutfieldsEvent","version":"0.0.1"},"nameSpace":"org.onap.policy.apex.auth.clieditor","source":"APEX","target":"APEX","parameter":{"entry":[{"key":"OduId","value":{"key":"OduId","fieldSchemaKey":{"name":"OduIdSchema","version":"0.0.1"},"optional":false}},{"key":"OruId","value":{"key":"OruId","fieldSchemaKey":{"name":"OruIdSchema","version":"0.0.1"},"optional":false}}]}}},{"key":{"name":"LinkFailureInputEvent","version":"0.0.1"},"value":{"key":{"name":"LinkFailureInputEvent","version":"0.0.1"},"nameSpace":"org.onap.policy.apex.auth.clieditor","source":"DMAAP","target":"APEX","parameter":{"entry":[{"key":"LinkFailureInput","value":{"key":"LinkFailureInput","fieldSchemaKey":{"name":"LinkFailureInputSchema","version":"0.0.1"},"optional":false}}]}}},{"key":{"name":"LinkFailureOutputEvent","version":"0.0.1"},"value":{"key":{"name":"LinkFailureOutputEvent","version":"0.0.1"},"nameSpace":"org.onap.policy.apex.auth.clieditor","source":"APEX","target":"OAM","parameter":{"entry":[{"key":"LinkFailureOutput","value":{"key":"LinkFailureOutput","fieldSchemaKey":{"name":"LinkFailureOutputSchema","version":"0.0.1"},"optional":false}}]}}}]}},"schemas":{"key":{"name":"LinkMonitorModel_Schemas","version":"0.0.1"},"schemas":{"entry":[{"key":{"name":"LinkFailureInputSchema","version":"0.0.1"},"value":{"key":{"name":"LinkFailureInputSchema","version":"0.0.1"},"schemaFlavour":"Avro","schemaDefinition":"{\n    \"type\": \"record\",\n    \"name\": \"Link_Failure_Input\",\n    \"fields\": [\n        {\n            \"name\": \"event\",\n            \"type\": {\n                \"type\": \"record\",\n                \"name\": \"Event_Type\",\n                \"fields\": [\n                    {\n                        \"name\": \"commonEventHeader\",\n                        \"type\": {\n                            \"type\": \"record\",\n                            \"name\": \"Common_Event_Header_Type\",\n                            \"fields\": [\n                                {\n                                    \"name\": \"domain\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"eventId\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"eventName\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"eventType\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"sequence\",\n                                    \"type\": \"int\"\n                                },\n                                {\n                                    \"name\": \"priority\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"reportingEntityId\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"reportingEntityName\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"sourceId\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"sourceName\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"startEpochMicrosec\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"lastEpochMicrosec\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"nfNamingCode\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"nfVendorName\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"timeZoneOffset\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"version\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"vesEventListenerVersion\",\n                                    \"type\": \"string\"\n                                }\n                            ]\n                        }\n                    },\n                    {\n                        \"name\": \"faultFields\",\n                        \"type\": {\n                            \"type\": \"record\",\n                            \"name\": \"Fault_Fields_Type\",\n                            \"fields\": [\n                                {\n                                    \"name\": \"faultFieldsVersion\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"alarmCondition\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"alarmInterfaceA\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"eventSourceType\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"specificProblem\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"eventSeverity\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"vfStatus\",\n                                    \"type\": \"string\"\n                                },\n                                {\n                                    \"name\": \"alarmAdditionalInformation\",\n                                    \"type\": {\n                                        \"type\": \"record\",\n                                        \"name\": \"Alarm_Additional_Information_Type\",\n                                        \"fields\": [\n                                            {\n                                                \"name\": \"eventTime\",\n                                                \"type\": \"string\"\n                                            },\n                                            {\n                                                \"name\": \"equipType\",\n                                                \"type\": \"string\"\n                                            },\n                                            {\n                                                \"name\": \"vendor\",\n                                                \"type\": \"string\"\n                                            },\n                                            {\n                                                \"name\": \"model\",\n                                                \"type\": \"string\"\n                                            }\n                                        ]\n                                    }\n                                }\n                            ]\n                        }\n                    }\n                ]\n            }\n        }\n    ]\n}"}},{"key":{"name":"LinkFailureOutputSchema","version":"0.0.1"},"value":{"key":{"name":"LinkFailureOutputSchema","version":"0.0.1"},"schemaFlavour":"Avro","schemaDefinition":"{\n    \"type\": \"record\",\n    \"name\": \"Link_Failure_Output\",\n    \"fields\": [\n        {\n            \"name\": \"o_DasH_ran_DasH_sc_DasH_du_DasH_hello_DasH_world_ColoN_du_DasH_to_DasH_ru_DasH_connection\",\n            \"type\": {\n        \t\"type\": \"array\",\n        \t\"items\": {\n\t\t    \"name\": \"Config_Change_Message\",\n                    \"type\": \"record\",\n                    \"fields\": [\n                        {\n                            \"name\": \"name\",\n                            \"type\": \"string\"\n                        },\n\t\t\t{\n                            \"name\": \"administrative_DasH_state\",\n                            \"type\": \"string\"\n                        }\n                    ]\n                }\n\t    }\n        }\n    ]\n}"}},{"key":{"name":"MessageSchema","version":"0.0.1"},"value":{"key":{"name":"MessageSchema","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.String"}},{"key":{"name":"OduIdSchema","version":"0.0.1"},"value":{"key":{"name":"OduIdSchema","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.String"}},{"key":{"name":"OruIdSchema","version":"0.0.1"},"value":{"key":{"name":"OruIdSchema","version":"0.0.1"},"schemaFlavour":"Java","schemaDefinition":"java.lang.String"}}]}}}}},"eventOutputParameters":{"RestProducer":{"carrierTechnologyParameters":{"carrierTechnology":"RESTCLIENT","parameterClassName":"org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters","parameters":{"url":"http://sdnc-oam:8282/rests/data/network-topology:network-topology/topology=topology-netconf/node={OduId}/yang-ext:mount/o-ran-sc-du-hello-world:network-function/du-to-ru-connection={OruId}","httpMethod":"PUT","httpHeaders":[["Authorization","Basic YWRtaW46S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ=="]]}},"eventProtocolParameters":{"eventProtocol":"JSON","parameters":{"pojoField":"LinkFailureOutput"}},"eventNameFilter":"LinkFailureOutputEvent"},"StdOutProducer":{"carrierTechnologyParameters":{"carrierTechnology":"FILE","parameters":{"standardIo":true}},"eventProtocolParameters":{"eventProtocol":"JSON","parameters":{"pojoField":"message"}},"eventNameFilter":"ApexMessageOutputEvent"}},"eventInputParameters":{"DMaaPConsumer":{"carrierTechnologyParameters":{"carrierTechnology":"RESTCLIENT","parameterClassName":"org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters","parameters":{"url":"http://message-router:3904/events/unauthenticated.SEC_FAULT_OUTPUT/users/link-monitor-nonrtric?timeout=15000&limit=100"}},"eventProtocolParameters":{"eventProtocol":"JSON","parameters":{"versionAlias":"version","pojoField":"LinkFailureInput"}},"eventName":"LinkFailureInputEvent"}}}}}]}}
diff --git a/smo-install/test/pythonsdk/src/oransdk/sdnc/__init__.py b/smo-install/test/pythonsdk/src/oransdk/sdnc/__init__.py
new file mode 100644 (file)
index 0000000..5d64d18
--- /dev/null
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: Apache-2.0
+"""ONAP SDNC package."""
diff --git a/smo-install/test/pythonsdk/src/oransdk/sdnc/sdnc.py b/smo-install/test/pythonsdk/src/oransdk/sdnc/sdnc.py
new file mode 100644 (file)
index 0000000..2353882
--- /dev/null
@@ -0,0 +1,52 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# SPDX-License-Identifier: Apache-2.0
+"""Onap Sdnc module."""
+
+from typing import Dict
+from oransdk.configuration import settings
+from onapsdk.sdnc.sdnc_element import SdncElement
+
+class OranSdnc(SdncElement):
+    """SDNC library."""
+
+    base_url = settings.SDNC_URL
+
+    @classmethod
+    def get_status(cls) -> str:
+        """
+        Get status of SDNC component.
+
+        Returns:
+           the status of the SDNC component
+
+        """
+        url = f"{cls.base_url}/apidoc/explorer/"
+        status = cls.send_message('GET',
+                                  'Get status of SDNC component',
+                                  url)
+        return status
+
+    @classmethod
+    def get_odu_oru_status(cls,
+                           odu_node,
+                           oru_node,
+                           basic_auth: Dict[str, str]) -> dict:
+        """
+        Get status of SDNC component.
+
+        Args:
+           basic_auth: (Dict[str, str]) for example:{ 'username': 'bob', 'password': 'secret' }
+
+        Returns:
+           the status of the SDNC component
+
+        """
+        url = f"{cls.base_url}/rests/data/network-topology:network-topology/"\
+              + f"topology=topology-netconf/node={odu_node}/yang-ext:mount/"\
+              + f"o-ran-sc-du-hello-world:network-function/du-to-ru-connection={oru_node}"
+        status = cls.send_message_json('GET',
+                                       'Get status of Odu Oru connectivity',
+                                       url,
+                                       basic_auth=basic_auth)
+        return status
diff --git a/smo-install/test/pythonsdk/src/oransdk/utils/jinja.py b/smo-install/test/pythonsdk/src/oransdk/utils/jinja.py
new file mode 100644 (file)
index 0000000..f481cb6
--- /dev/null
@@ -0,0 +1,32 @@
+# -*- coding: utf-8 -*-
+# SPDX-License-Identifier: Apache-2.0
+"""Jinja module."""
+
+from jinja2 import Environment, PackageLoader, select_autoescape, ChoiceLoader
+
+
+def jinja_env() -> Environment:
+    """Create Jinja environment.
+
+    jinja_env allow to fetch simply jinja templates where they are.
+    by default jinja engine will look for templates in `templates` directory of
+    the package. So to load a template, you just have to do:
+
+    Example:
+    >>> template = jinja_env().get_template('vendor_create.json.j2')
+    >>> data = template.render(name="vendor")
+
+    See also:
+        SdcElement.create() for real use
+
+    Returns:
+        Environment: the Jinja environment to use
+
+    """
+    return Environment(autoescape=select_autoescape(['html', 'htm', 'xml']),
+                       loader=ChoiceLoader([
+                           PackageLoader("oransdk.a1sim"),
+                           PackageLoader("oransdk.dmaap"),
+                           PackageLoader("oransdk.enrichmentservice"),
+                           PackageLoader("oransdk.policy")
+                       ]))
diff --git a/smo-install/test/pythonsdk/src/oransdk/version.py b/smo-install/test/pythonsdk/src/oransdk/version.py
new file mode 100644 (file)
index 0000000..8afbff9
--- /dev/null
@@ -0,0 +1,6 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# SPDX-License-Identifier: Apache-2.0
+"""Version module."""
+
+__version__ = "1.0.0"
diff --git a/smo-install/test/pythonsdk/src/orantests/configuration/settings.py b/smo-install/test/pythonsdk/src/orantests/configuration/settings.py
new file mode 100644 (file)
index 0000000..d4fe625
--- /dev/null
@@ -0,0 +1,82 @@
+"""Specific settings module."""  # pylint: disable=bad-whitespace
+import subprocess
+
+######################
+#                    #
+# ONAP INPUTS DATAS  #
+#                    #
+######################
+
+
+# Variables to set logger information
+# Possible values for logging levels in onapsdk: INFO, DEBUG , WARNING, ERROR
+LOG_CONFIG = {
+    "version": 1,
+    "disable_existing_loggers": False,
+    "formatters": {
+        "default": {
+            "class": "logging.Formatter",
+            "format": "%(asctime)s %(levelname)s %(lineno)d:%(filename)s(%(process)d) - %(message)s"
+        }
+    },
+    "handlers": {
+        "console": {
+            "level": "DEBUG",
+            "class": "logging.StreamHandler",
+            "formatter": "default"
+        },
+        "file": {
+            "level": "DEBUG",
+            "class": "logging.FileHandler",
+            "formatter": "default",
+            "filename": "pythonsdk.debug.log",
+            "mode": "w"
+        }
+    },
+    "root": {
+        "level": "DEBUG",
+        "handlers": ["console", "file"]
+    }
+}
+
+######################
+#                    #
+# ONAP SERVICES URLS #
+#                    #
+######################
+
+AAI_URL         = "https://aai.api.sparky.simpledemo.onap.org:30233"
+AAI_API_VERSION = "v23"
+AAI_AUTH        = "Basic QUFJOkFBSQ=="
+CDS_URL         = "http://portal.api.simpledemo.onap.org:30449"
+CDS_AUTH        = ("ccsdkapps", "ccsdkapps")
+MSB_URL         = "https://msb.api.simpledemo.onap.org:30283"
+SDC_BE_URL      = "https://sdc.api.be.simpledemo.onap.org:30204"
+SDC_FE_URL      = "https://sdc.api.fe.simpledemo.onap.org:30207"
+SDC_AUTH        = "Basic YWFpOktwOGJKNFNYc3pNMFdYbGhhazNlSGxjc2UyZ0F3ODR2YW9HR21KdlV5MlU="
+#SDNC_URL        = "https://sdnc.api.simpledemo.onap.org:30267"
+SDNC_AUTH       = "Basic YWRtaW46S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ=="
+SO_URL          = "http://so.api.simpledemo.onap.org:30277"
+SO_API_VERSION  = "v7"
+SO_AUTH         = "Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA=="
+VID_URL         = "https://vid.api.simpledemo.onap.org:30200"
+VID_API_VERSION = "/vid"
+CLAMP_URL       = "https://clamp.api.simpledemo.onap.org:30258"
+CLAMP_AUTH      = "Basic ZGVtb0BwZW9wbGUub3NhYWYub3JnOmRlbW8xMjM0NTYh"
+VES_URL         = "http://ves.api.simpledemo.onap.org:30417"
+DMAAP_URL       = "http://192.168.1.39:3904"
+NBI_URL         = "https://nbi.api.simpledemo.onap.org:30274"
+NBI_API_VERSION = "/nbi/api/v4"
+
+POLICY_BASICAUTH = { 'username': 'healthcheck', 'password': 'zb!XztG34' }
+
+DMAAP_URL = "http://"+subprocess.run("kubectl get services message-router -n onap |grep message-router | awk '{print $3}'", shell=True, check=True, stdout=subprocess.PIPE).stdout.decode('utf-8').strip()+":3904"
+
+A1SIM_OSC_URL = "http://"+subprocess.run("kubectl get services a1-sim-osc -n nonrtric |grep a1-sim-osc | awk '{print $3}'", shell=True, check=True, stdout=subprocess.PIPE).stdout.decode('utf-8').strip()+":8085"
+A1SIM_STD1_URL = "http://"+subprocess.run("kubectl get services a1-sim-std-1 -n nonrtric |grep a1-sim-std-1 | awk '{print $3}'", shell=True, check=True, stdout=subprocess.PIPE).stdout.decode('utf-8').strip()+":3904"
+A1SIM_STD2_URL = "http://"+subprocess.run("kubectl get services a1-sim-std-2 -n nonrtric |grep a1-sim-std-2 | awk '{print $3}'", shell=True, check=True, stdout=subprocess.PIPE).stdout.decode('utf-8').strip()+":3904"
+
+POLICY_PAP_URL = "https://"+subprocess.run("kubectl get services policy-pap -n onap |grep policy-pap | awk '{print $3}'", shell=True, check=True, stdout=subprocess.PIPE).stdout.decode('utf-8').strip()+":6969"
+POLICY_API_URL = "https://"+subprocess.run("kubectl get services policy-api -n onap |grep policy-api | awk '{print $3}'", shell=True, check=True, stdout=subprocess.PIPE).stdout.decode('utf-8').strip()+":6969"
+SDNC_URL = "http://"+subprocess.run("kubectl get services sdnc-oam -n onap |grep sdnc-oam | awk '{print $3}'", shell=True, check=True, stdout=subprocess.PIPE).stdout.decode('utf-8').strip()+":8282"
+
diff --git a/smo-install/test/pythonsdk/src/orantests/test_apex_policy.py b/smo-install/test/pythonsdk/src/orantests/test_apex_policy.py
new file mode 100644 (file)
index 0000000..7195a31
--- /dev/null
@@ -0,0 +1,114 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: Apache-2.0
+
+import time
+import subprocess
+import logging
+import logging.config
+from onapsdk.configuration import settings
+from oransdk.dmaap.dmaap import OranDmaap
+from oransdk.policy.policy import OranPolicy, PolicyType
+from oransdk.sdnc.sdnc import OranSdnc
+from oransdk.utils.jinja import jinja_env
+
+logging.config.dictConfig(settings.LOG_CONFIG)
+logger = logging.getLogger("test APEX policy")
+
+def test_a1():
+    dmaap = OranDmaap()
+    logger.info("Create new topic")
+    topic = '{  "topicName": "unauthenticated.SEC_FAULT_OUTPUT",  "topicDescription": "test topic",  "partitionCount": 1,  "replicationCnCount": 1,  "transactionEnabled": "false"}'
+    response = dmaap.create_topic(topic)
+    logger.info("response is: %s", response)
+
+    logger.info("Verify topic created")
+    topiclist = dmaap.get_all_topics({})
+    topic_created = False
+    for topic in topiclist:
+      if topic["topicName"] == "unauthenticated.SEC_FAULT_OUTPUT":
+          topic_created = True
+          break
+
+    if (topic_created):
+          logger.info("Topic created successfully")
+    else:
+          logger.info("Topic creation failed")
+
+
+    logger.info("Verify policy components are ready")
+    policy = OranPolicy()
+    policy_ready = {"api_ready": False, "pap_ready": False, "apex_ready": False}
+    for x in range(60):
+        policy_status = policy.get_components_status(settings.POLICY_BASICAUTH)
+        if (policy_status["api"]["healthy"] and policy_ready["api_ready"] == False):
+            logger.info("Policy Api is ready")
+            policy_ready["api_ready"] = True
+        if (policy_status["pap"]["healthy"] and policy_ready["pap_ready"] == False):
+            logger.info("Policy Pap is ready")
+            policy_ready["pap_ready"] = True
+        if (policy_status["pdps"]["apex"][0]["healthy"] == "HEALTHY" and policy_ready["apex_ready"] == False):
+            logger.info("Policy Apex is ready")
+            policy_ready["apex_ready"] = True
+        if (policy_ready["api_ready"] and policy_ready["pap_ready"] and policy_ready["apex_ready"]):
+            logger.info("Policy status all ready")
+            break
+
+
+    if (policy_ready["api_ready"] == False or policy_ready["pap_ready"] == False or policy_ready["apex_ready"] == False):
+        logger.info("Policy components are not ready. Exit the test.")
+
+
+    logger.info("Create policy")
+    policy_data = jinja_env().get_template("ToscaPolicy.json.j2").render()
+    policy.create_policy(PolicyType(type="onap.policies.native.Apex", version="1.0.0"), policy_data, settings.POLICY_BASICAUTH)
+
+    logger.info("Verify whether policy created successfully")
+    policy_response = policy.get_policy(PolicyType(type="onap.policies.native.Apex", version="1.0.0"),
+                                        "onap.policies.native.apex.LinkMonitor", "1.0.0", settings.POLICY_BASICAUTH)
+    if (policy_response):
+        logger.info("Policy created successfully")
+    else:
+        logger.info("Policy creation failed")
+
+    logger.info("Deploy policy")
+    deploy_policy = jinja_env().get_template("DeployPolicyPAP.json.j2").render()
+    policy.deploy_policy(deploy_policy, settings.POLICY_BASICAUTH)
+
+    logger.info("Verify the policy is deployed")
+    policy_status_list = policy.get_policy_status(settings.POLICY_BASICAUTH)
+    policy_deployed = False
+    for status in policy_status_list:
+        logger.info("the status %s,%s,%s:", status["policy"]["name"], status["policy"]["version"] , status["deploy"] )
+        if (status["policy"]["name"] == "onap.policies.native.apex.LinkMonitor" and status["policy"]["version"] == "1.0.0" and status["deploy"]):
+            policy_deployed = True
+            break
+
+    if policy_deployed:
+        logger.info("Policy deployed successfully")
+    else:
+        logger.info("Failed to deploy policy")
+
+    logger.info("Check O-du/O-ru status")
+    SDNC_BASICAUTH = { 'username': 'admin', 'password': 'Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U' }
+    sdnc = OranSdnc()
+    status = sdnc.get_odu_oru_status("o-du-1122", "o-ru-11221", SDNC_BASICAUTH)
+    if status["o-ran-sc-du-hello-world:du-to-ru-connection"][0]["administrative-state"] == "LOCKED":
+        logger.info("The initial state of o-du o-ru connection is LOCKED")
+
+    logger.info("Wait for a while for Apex engine to be ready before sending Dmaap event")
+    dmaap = OranDmaap()
+    event = jinja_env().get_template("LinkFailureEvent.json.j2").render()
+    for x in range(60):
+        dmaap.send_link_failure_event(event)
+        output = subprocess.getoutput('kubectl logs onap-policy-apex-pdp-0 -n onap | grep "Task Selection Execution: \'LinkMonitorPolicy:0.0.1:NULL:LinkFailureOrClearedState\'" | wc -l')
+        if (int(output) > 0):
+            logger.info("Apex engine is ready. LinkFailureEvent sent to Dmaap")
+            break
+        else:
+            logger.info("Apex engine not ready yet, wait for a while and try again")
+            time.sleep(2)
+
+    logger.info("Check O-du/O-ru status again")
+    status = sdnc.get_odu_oru_status("o-du-1122", "o-ru-11221", SDNC_BASICAUTH)
+    if status["o-ran-sc-du-hello-world:du-to-ru-connection"][0]["administrative-state"] == "UNLOCKED":
+        logger.info("The updated state of o-du o-ru connection is UNLOCKED")
diff --git a/smo-install/test/pythonsdk/src/orantests/test_dmaap.py b/smo-install/test/pythonsdk/src/orantests/test_dmaap.py
new file mode 100644 (file)
index 0000000..50fa667
--- /dev/null
@@ -0,0 +1,44 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: Apache-2.0
+
+import logging
+from pathlib import Path
+from onapsdk.configuration import settings
+from oransdk.dmaap.dmaap import OranDmaap
+from oransdk.a1sim.a1sim import A1sim
+from oransdk.utils.jinja import jinja_env
+
+BASIC_AUTH = {}
+
+logging.config.dictConfig(settings.LOG_CONFIG)
+logger = logging.getLogger("test DMAAP")
+
+#dmaap = OranDmaap()
+#logger.info("Get all the topics")
+#topiclist = dmaap.get_all_topics(BASIC_AUTH)
+#logger.info("response is: %s", topiclist)
+
+
+#logger.info("Create new topic")
+#topic = '{  "topicName": "unauthenticated.SEC_FAULT_OUTPUT",  "topicDescription": "test topic",  "partitionCount": 1,  "replicationCnCount": 1,  "transactionEnabled": "false"}'
+#response = dmaap.create_topic(topic, BASIC_AUTH)
+#logger.info("response is: %s", response)
+
+
+#logger.info("Get topics again")
+#topiclist = dmaap.get_all_topics(BASIC_AUTH)
+#logger.info("response is: %s", topiclist)
+
+
+def test_dmaap():
+    logger.info("Get ric version for ost")
+    a1sim = A1sim()
+    version1 = a1sim.check_version(settings.A1SIM_OSC_URL)
+
+    status = a1sim.check_status(settings.A1SIM_OSC_URL)
+
+    number = a1sim.get_policy_number(settings.A1SIM_OSC_URL)
+
+    data = jinja_env().get_template("OSC/policy_type.json.j2").render()
+    a1sim.create_policy_type(settings.A1SIM_OSC_URL, 1, data)
+    assert(True)
diff --git a/smo-install/test/pythonsdk/tox.ini b/smo-install/test/pythonsdk/tox.ini
new file mode 100644 (file)
index 0000000..7475a4f
--- /dev/null
@@ -0,0 +1,36 @@
+[tox]
+#envlist = pylint,pydocstyle,unit-tests,oran-tests
+skipsdist=True
+
+[testenv]
+deps =
+    pylint==2.4.4
+    pytest==6.2.5
+    pytest-cov==2.10.1
+    pydocstyle==5.1.1
+    onapsdk==9.0.0
+
+passenv = *
+
+[testenv:unit-tests]
+basepython=python3.8
+commands = pytest -v --junit-xml=unit-tests.xml unit-tests/
+setenv =
+    PYTHONPATH = $PYTHONPATH:{toxinidir}/src
+    ONAP_PYTHON_SDK_SETTINGS=oransdk.configuration.global_settings
+
+[testenv:oran-tests]
+basepython=python3.8
+commands = pytest -v --junit-xml=oran-tests.xml src/orantests/
+setenv =
+    PYTHONPATH = $PYTHONPATH:{toxinidir}/src
+    ONAP_PYTHON_SDK_SETTINGS=orantests.configuration.settings
+
+
+[testenv:pylint]
+basepython=python3.8
+commands = pylint --disable=invalid-name src/
+
+[testenv:pydocstyle]
+basepython=python3.8
+commands = pydocstyle src/
diff --git a/smo-install/test/pythonsdk/unit-tests/__init__.py b/smo-install/test/pythonsdk/unit-tests/__init__.py
new file mode 100644 (file)
index 0000000..7cbf434
--- /dev/null
@@ -0,0 +1,10 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: Apache-2.0
+"""Main test module."""
+
+import logging
+
+logging.basicConfig(
+    level=logging.DEBUG,
+    format='%(asctime)s - %(name)-23s - %(levelname)-8s - %(message)s')
+logging.captureWarnings(True)
diff --git a/smo-install/test/pythonsdk/unit-tests/test_a1policymanagement.py b/smo-install/test/pythonsdk/unit-tests/test_a1policymanagement.py
new file mode 100644 (file)
index 0000000..badfebd
--- /dev/null
@@ -0,0 +1,69 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: Apache-2.0
+"""Test A1policymanagement module."""
+
+from unittest import mock
+from oransdk.a1policymanagement.a1policymanagement import A1policymanagement
+
+HEADER = {"Accept": "application/json", "Content-Type": "application/json"}
+BASE_URL = "http://localhost:8081"
+
+def test_initialization():
+    """Class initialization test."""
+    a1policymanagement = A1policymanagement()
+    assert isinstance(a1policymanagement, A1policymanagement)
+
+
+@mock.patch.object(A1policymanagement, 'send_message')
+def test_check_status(mock_send_message):
+    """Test A1policymanagement's class method."""
+    A1policymanagement.check_status()
+    mock_send_message.assert_called_once_with('GET',
+                                              'Get A1 policy management status',
+                                              (f"{BASE_URL}/status"))
+
+@mock.patch.object(A1policymanagement, 'send_message_json')
+def test_get_policy_types(mock_send_message_json):
+    """Test A1policymanagement's class method."""
+    A1policymanagement.get_policy_types()
+    mock_send_message_json.assert_called_once_with('GET',
+                                              'Get all the policy types',
+                                              (f"{BASE_URL}/policy_types"))
+
+@mock.patch.object(A1policymanagement, 'send_message_json')
+def test_get_policy_type_agent(mock_send_message_json):
+    """Test A1policymanagement's class method."""
+    A1policymanagement.get_policy_type_agent()
+    mock_send_message_json.assert_called_once_with('GET',
+                                              'Get all the policy types from policy agent',
+                                              (f"{BASE_URL}/a1-policy/v2/policy-types"))
+
+@mock.patch.object(A1policymanagement, 'send_message_json')
+def test_get_policy(mock_send_message_json):
+    """Test A1policymanagement's class method."""
+    A1policymanagement.get_policy("test_id")
+    mock_send_message_json.assert_called_once_with('GET',
+                                              'Get the policy with policy id',
+                                              (f"{BASE_URL}/a1-policy/v2/policies/test_id"))
+
+@mock.patch.object(A1policymanagement, 'send_message')
+def test_create_service(mock_send_message):
+    """Test A1policymanagement's class method."""
+    service_data = {}
+    A1policymanagement.create_service(service_data)
+    mock_send_message.assert_called_once_with('PUT',
+                                              'Create Service',
+                                              (f"{BASE_URL}/a1-policy/v2/services"),
+                                              data=service_data,
+                                              headers=HEADER)
+
+@mock.patch.object(A1policymanagement, 'send_message')
+def test_create_policy(mock_send_message):
+    """Test A1policymanagement's class method."""
+    policy_data = {}
+    A1policymanagement.create_policy(policy_data)
+    mock_send_message.assert_called_once_with('PUT',
+                                              'Create Policy',
+                                              (f"{BASE_URL}/a1-policy/v2/policies"),
+                                              data=policy_data,
+                                              headers=HEADER)
diff --git a/smo-install/test/pythonsdk/unit-tests/test_a1sim.py b/smo-install/test/pythonsdk/unit-tests/test_a1sim.py
new file mode 100644 (file)
index 0000000..77f83bf
--- /dev/null
@@ -0,0 +1,49 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: Apache-2.0
+"""Test A1sim module."""
+
+from unittest import mock
+from oransdk.a1sim.a1sim import A1sim
+
+HEADER = {"Accept": "application/json", "Content-Type": "application/json"}
+BASE_URL = "http://localhost:8081"
+
+def test_initialization():
+    """Class initialization test."""
+    a1sim = A1sim()
+    assert isinstance(a1sim, A1sim)
+
+
+@mock.patch.object(A1sim, 'send_message')
+def test_check_version(mock_send_message):
+    """Test A1sim's class method."""
+    A1sim.check_version(BASE_URL)
+    mock_send_message.assert_called_once_with('GET',
+                                              'Get ric version',
+                                              (f"{BASE_URL}/counter/interface"))
+
+@mock.patch.object(A1sim, 'send_message')
+def test_check_status(mock_send_message):
+    """Test A1sim's class method."""
+    A1sim.check_status(BASE_URL)
+    mock_send_message.assert_called_once_with('GET',
+                                              'Get ric status',
+                                              (f"{BASE_URL}"))
+
+@mock.patch.object(A1sim, 'send_message')
+def test_get_policy_number(mock_send_message):
+    """Test A1sim's class method."""
+    A1sim.get_policy_number(BASE_URL)
+    mock_send_message.assert_called_once_with('GET',
+                                              'Get policy numbers for ric',
+                                              (f"{BASE_URL}/counter/num_instances"))
+
+@mock.patch.object(A1sim, 'send_message')
+def test_create_policy_type(mock_send_message):
+    """Test A1sim's class method."""
+    A1sim.create_policy_type(BASE_URL, "test_id", {})
+    mock_send_message.assert_called_once_with('PUT',
+                                              'Create Policy Type',
+                                              (f"{BASE_URL}/policytype?id=test_id"),
+                                              data={},
+                                              headers=HEADER)
diff --git a/smo-install/test/pythonsdk/unit-tests/test_dmaap.py b/smo-install/test/pythonsdk/unit-tests/test_dmaap.py
new file mode 100644 (file)
index 0000000..9865bde
--- /dev/null
@@ -0,0 +1,71 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: Apache-2.0
+"""Test clamp module."""
+
+from unittest import mock
+from oransdk.dmaap.dmaap import OranDmaap
+from onapsdk.dmaap.dmaap_service import DmaapService
+
+#examples
+TOPIC = {
+    "topicName": "test.TOPIC",
+    "topicDescription": "test topic",
+    "partitionCount": 1,
+    "replicationCnCount": 1,
+    "transactionEnabled": "false"
+    }
+
+HEADER={"accept": "application/json", "Content-Type": "application/json"}
+BASIC_AUTH = {'username': 'dcae@dcae.onap.org', 'password': 'demo123456!'}
+BASE_URL = "http://localhost:3904"
+
+def test_initialization():
+    """Class initialization test."""
+    dmaap = OranDmaap()
+    assert isinstance(dmaap, OranDmaap)
+
+
+@mock.patch.object(OranDmaap, 'send_message')
+def test_create_topic(mock_send_message):
+    """Test Dmaap's class method."""
+    OranDmaap.create_topic(TOPIC)
+    mock_send_message.assert_called_once_with('POST',
+                                              'Create Dmaap Topic',
+                                              (f"{BASE_URL}/topics/create"),
+                                              data=TOPIC,
+                                              headers=HEADER)
+
+@mock.patch.object(OranDmaap, 'send_message')
+def test_create_service(mock_send_message):
+    """Test Dmaap's class method."""
+    event = {}
+    OranDmaap.create_service(event)
+    mock_send_message.assert_called_once_with('POST',
+                                              'Create Service via Dmaap',
+                                              (f"{BASE_URL}/events/A1-POLICY-AGENT-READ/"),
+                                              data=event,
+                                              headers=HEADER)
+
+@mock.patch.object(OranDmaap, 'send_message')
+def test_send_link_failure_event(mock_send_message):
+    """Test Dmaap's class method."""
+    event = {}
+    OranDmaap.send_link_failure_event(event)
+    mock_send_message.assert_called_once_with('POST',
+                                              'Send link failure event',
+                                              (f"{BASE_URL}/events/unauthenticated.SEC_FAULT_OUTPUT/"),
+                                              data=event,
+                                              headers=HEADER)
+
+@mock.patch.object(OranDmaap, 'send_message')
+def test_get_result(mock_send_message):
+    """Test Dmaap's class method."""
+    OranDmaap.get_result()
+    mock_send_message.assert_called_once_with('GET',
+                                              'Get result from previous request',
+                                              (f"{BASE_URL}/events/A1-POLICY-AGENT-WRITE/users/policy-agent?timeout=15000&limit=100"))
+
+@mock.patch.object(OranDmaap, 'send_message_json')
+def test_get_all_topics(mock_send_message_json):
+    """Test Dmaap's class method."""
+    assert OranDmaap.get_all_topics_url == f"{BASE_URL}/topics/listAll"
diff --git a/smo-install/test/pythonsdk/unit-tests/test_enrichmentservice.py b/smo-install/test/pythonsdk/unit-tests/test_enrichmentservice.py
new file mode 100644 (file)
index 0000000..96fb9d3
--- /dev/null
@@ -0,0 +1,125 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: Apache-2.0
+"""Test Enrichment Service module."""
+
+from unittest import mock
+from oransdk.enrichmentservice.enrichmentservice import EnrichmentService
+
+HEADER = {"Content-Type": "application/json"}
+BASE_URL = "http://localhost:8083"
+
+def test_initialization():
+    """Class initialization test."""
+    ems = EnrichmentService()
+    assert isinstance(ems, EnrichmentService)
+
+
+@mock.patch.object(EnrichmentService, 'send_message')
+def test_check_status(mock_send_message):
+    """Test EnrichmentService's class method."""
+    EnrichmentService.check_status()
+    mock_send_message.assert_called_once_with('GET',
+                                              'Get EMS status',
+                                              (f"{BASE_URL}/status"))
+
+
+@mock.patch.object(EnrichmentService, 'send_message')
+def test_get_eitypes(mock_send_message):
+    """Test EnrichmentService's class method."""
+    EnrichmentService.get_eitypes()
+    mock_send_message.assert_called_once_with('GET',
+                                              'Get all the EiTypes',
+                                              (f"{BASE_URL}/data-producer/v1/info-types"),
+                                              headers=HEADER)
+
+
+@mock.patch.object(EnrichmentService, 'send_message')
+def test_get_eitype_individual(mock_send_message):
+    """Test EnrichmentService's class method."""
+    EnrichmentService.get_eitype_individual("test_eitype")
+    mock_send_message.assert_called_once_with('GET',
+                                              'Get individual EiType',
+                                              (f"{BASE_URL}/data-producer/v1/info-types/test_eitype"),
+                                              headers=HEADER)
+
+
+@mock.patch.object(EnrichmentService, 'send_message')
+def test_get_eiproducers(mock_send_message):
+    """Test EnrichmentService's class method."""
+    EnrichmentService.get_eiproducers()
+    mock_send_message.assert_called_once_with('GET',
+                                              'Get all the EiProducers',
+                                              (f"{BASE_URL}/data-producer/v1/info-producers"),
+                                              headers=HEADER)
+
+
+@mock.patch.object(EnrichmentService, 'send_message')
+def test_get_eiproducer_individual(mock_send_message):
+    """Test EnrichmentService's class method."""
+    EnrichmentService.get_eiproducer_individual("test_producer")
+    mock_send_message.assert_called_once_with('GET',
+                                              'Get individual EiProducer',
+                                              (f"{BASE_URL}/data-producer/v1/info-producers/test_producer"),
+                                              headers=HEADER)
+
+
+@mock.patch.object(EnrichmentService, 'send_message')
+def test_get_eiproducer_status(mock_send_message):
+    """Test EnrichmentService's class method."""
+    EnrichmentService.get_eiproducer_status("test_producer")
+    mock_send_message.assert_called_once_with('GET',
+                                              'Get the status of EiProducer',
+                                              (f"{BASE_URL}/data-producer/v1/info-producers/test_producer/status"),
+                                              headers=HEADER)
+
+
+@mock.patch.object(EnrichmentService, 'send_message')
+def test_get_eijobs(mock_send_message):
+    """Test EnrichmentService's class method."""
+    EnrichmentService.get_eijobs()
+    mock_send_message.assert_called_once_with('GET',
+                                              'Get all the EiJobs',
+                                              (f"{BASE_URL}/A1-EI/v1/eijobs"),
+                                              headers=HEADER)
+
+
+@mock.patch.object(EnrichmentService, 'send_message')
+def test_get_eijob_individual(mock_send_message):
+    """Test EnrichmentService's class method."""
+    EnrichmentService.get_eijob_individual("test_job")
+    mock_send_message.assert_called_once_with('GET',
+                                              'Get individual EiJob',
+                                              (f"{BASE_URL}/A1-EI/v1/eijobs/test_job"),
+                                              headers=HEADER)
+
+
+@mock.patch.object(EnrichmentService, 'send_message')
+def test_create_eitype(mock_send_message):
+    """Test EnrichmentService's class method."""
+    EnrichmentService.create_eitype("type_name", {})
+    mock_send_message.assert_called_once_with('PUT',
+                                              'Create EiType',
+                                              (f"{BASE_URL}/data-producer/v1/info-types/type_name"),
+                                              data={},
+                                              headers=HEADER)
+
+
+@mock.patch.object(EnrichmentService, 'send_message')
+def test_create_eiproducer(mock_send_message):
+    """Test EnrichmentService's class method."""
+    EnrichmentService.create_eiproducer("producer", {})
+    mock_send_message.assert_called_once_with('PUT',
+                                              'Create EiProducer',
+                                              (f"{BASE_URL}/data-producer/v1/info-producers/producer"),
+                                              data={},
+                                              headers=HEADER)
+
+@mock.patch.object(EnrichmentService, 'send_message')
+def test_create_eijob(mock_send_message):
+    """Test EnrichmentService's class method."""
+    EnrichmentService.create_eijob("job", {})
+    mock_send_message.assert_called_once_with('PUT',
+                                              'Create EiJob',
+                                              (f"{BASE_URL}/A1-EI/v1/eijobs/job"),
+                                              data={},
+                                              headers=HEADER)
diff --git a/smo-install/test/pythonsdk/unit-tests/test_policy.py b/smo-install/test/pythonsdk/unit-tests/test_policy.py
new file mode 100644 (file)
index 0000000..acbcda3
--- /dev/null
@@ -0,0 +1,71 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: Apache-2.0
+"""Test Policy module."""
+
+from unittest import mock
+from oransdk.policy.policy import OranPolicy, PolicyType
+
+HEADER = {"Accept": "application/json", "Content-Type": "application/json"}
+API_URL = "https://localhost:6969"
+PAP_URL = "https://localhost:6969"
+BASIC_AUTH = {'username': 'dcae@dcae.onap.org', 'password': 'demo123456!'}
+
+def test_initialization():
+    """Class initialization test."""
+    policy = OranPolicy()
+    assert isinstance(policy, OranPolicy)
+
+
+@mock.patch.object(OranPolicy, 'send_message_json')
+def test_get_components_status(mock_send_message_json):
+    """Test Policy's class method."""
+    OranPolicy.get_components_status(BASIC_AUTH)
+    mock_send_message_json.assert_called_once_with('GET',
+                                                   'Get status of Policy component',
+                                                   (f"{PAP_URL}/policy/pap/v1/components/healthcheck"),
+                                                   basic_auth=BASIC_AUTH)
+
+@mock.patch.object(OranPolicy, 'send_message_json')
+def test_get_policy_status(mock_send_message_json):
+    """Test Policy's class method."""
+    OranPolicy.get_policy_status(BASIC_AUTH)
+    mock_send_message_json.assert_called_once_with('GET',
+                                                   'Get status of all the policies',
+                                                   (f"{PAP_URL}/policy/pap/v1/policies/status"),
+                                                   basic_auth=BASIC_AUTH)
+
+
+@mock.patch.object(OranPolicy, 'send_message_json')
+def test_get_policy(mock_send_message_json):
+    """Test Policy's class method."""
+    OranPolicy.get_policy(PolicyType(type="test_type", version="type_version"),
+                          "policy_name", "policy_version", BASIC_AUTH)
+    mock_send_message_json.assert_called_once_with('GET',
+                                                   'Get the policy',
+                                                   (f"{API_URL}/policy/api/v1/policytypes/test_type/versions/"\
+                                                   + "type_version/policies/policy_name/versions/policy_version"),
+                                                   basic_auth=BASIC_AUTH)
+
+
+@mock.patch.object(OranPolicy, 'send_message')
+def test_create_policy(mock_send_message):
+    """Test Policy's class method."""
+    OranPolicy.create_policy(PolicyType(type="test_type", version="type_version"), {}, BASIC_AUTH)
+    mock_send_message.assert_called_once_with('POST',
+                                              'Create Policy',
+                                              (f"{API_URL}/policy/api/v1/policytypes/test_type/"\
+                                              + "versions/type_version/policies"),
+                                              data={},
+                                              headers=HEADER,
+                                              basic_auth=BASIC_AUTH)
+
+@mock.patch.object(OranPolicy, 'send_message')
+def test_deploy_policy(mock_send_message):
+    """Test Policy's class method."""
+    OranPolicy.deploy_policy({}, BASIC_AUTH)
+    mock_send_message.assert_called_once_with('POST',
+                                              'Deploy Policy',
+                                              (f"{API_URL}/policy/pap/v1/pdps/policies"),
+                                              data={},
+                                              headers=HEADER,
+                                              basic_auth=BASIC_AUTH)
diff --git a/smo-install/test/pythonsdk/unit-tests/test_sdnc.py b/smo-install/test/pythonsdk/unit-tests/test_sdnc.py
new file mode 100644 (file)
index 0000000..256a9b0
--- /dev/null
@@ -0,0 +1,34 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: Apache-2.0
+"""Test OranSdnc module."""
+
+from unittest import mock
+from oransdk.sdnc.sdnc import OranSdnc
+
+BASE_URL = "http://localhost:8282"
+BASIC_AUTH = {'username': 'dcae@dcae.onap.org', 'password': 'demo123456!'}
+
+def test_initialization():
+    """Class initialization test."""
+    sdnc = OranSdnc()
+    assert isinstance(sdnc, OranSdnc)
+
+
+@mock.patch.object(OranSdnc, 'send_message')
+def test_get_status(mock_send_message):
+    """Test Sdnc's class method."""
+    OranSdnc.get_status()
+    mock_send_message.assert_called_once_with('GET',
+                                              'Get status of SDNC component',
+                                              (f"{BASE_URL}/apidoc/explorer/"))
+
+@mock.patch.object(OranSdnc, 'send_message_json')
+def test_get_odu_oru_status(mock_send_message_json):
+    """Test Sdnc's class method."""
+    OranSdnc.get_odu_oru_status("o-du", "o-ru", BASIC_AUTH)
+    mock_send_message_json.assert_called_once_with('GET',
+                                                   'Get status of Odu Oru connectivity',
+                                                   (f"{BASE_URL}/rests/data/network-topology:network-topology/"\
+                                                   + "topology=topology-netconf/node=o-du/yang-ext:mount/"\
+                                                   + "o-ran-sc-du-hello-world:network-function/du-to-ru-connection=o-ru"),
+                                                   basic_auth=BASIC_AUTH)
diff --git a/smo-install/test/pythonsdk/unit-tests/test_version.py b/smo-install/test/pythonsdk/unit-tests/test_version.py
new file mode 100644 (file)
index 0000000..fbd6227
--- /dev/null
@@ -0,0 +1,9 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: Apache-2.0
+"""Test version module."""
+
+import oransdk.version as version
+
+def test_version():
+  """Check version is the right one."""
+  assert version.__version__ == '1.0.0'