.. contents::
:depth: 2
+This section will cover how to interact with the PDP-D using telemetry commands. This assumes that you have a PDP-D running to interact with. Take a look at the page "Methods to run PDP-D" if you do not have a PDP-D running for testing purposes.
+
Telemetry
^^^^^^^^^
The username and password for the Telemetry commands are in *${POLICY_HOME}/config/engine.properties*.
+If you are using Eclipse, the credentials can be found in the file **install-drools/src/files/base.conf** within the "drools-pdp" repository.
+The environment variables $TELEMETRY_USER and $TELEMETRY_PASSWORD will also have the credentials if they have already been set.
+
+Recall you can use the command "docker exec -it drools bash" to get the PDP-D running with Docker.
+
+ .. code-block:: bash
+
+ docker exec -it drools bash
+
+Your terminal should now look similar to "policy@drools:/<path>". This indicates you are in the drools docker container. If you run "policy status" the controller should be running.
+
+ .. image:: img/docker/policyStatus.png
+
+To enter the telemetry subshell, use the command "telemetry".
+
+ .. code-block:: bash
+
+ telemetry
+
+Use the "exit" command to exit the telemetry subshell. The terminal will now go back to the docker container.
+
+ .. code-block:: bash
+
+ exit
+
+ .. image:: img/docker/credentials.png
Injecting messages:
-------------------
-To inject messages use the following command. The injected message will look as if it came in from the specified topic and will be processed accordingly.
+To inject messages, use the following command. The injected message will look as if it came in from the specified topic and will be processed accordingly.
Use the command:
http --verify=no --default-scheme=https -a <userName>:<password> PUT :9696/policy/pdp/engine/topics/sources/<comm>/<topic>/events @<onsetFile> Content-Type:"text/plain"
-where <comm> is either "dmaap", "ueb", or "noop", depending on how the topic has been defined in the
-configuration. "dmaap" is the default deployed messaging communication infrastructure in an ONAP installation.
-The following is the equivalent "curl" version:
+The equivalent "curl" version:
.. code-block:: bash
curl --insecure --silent --user <userName>:<password> -X PUT --header "Content-Type: text/plain" --data @<onsetFile> https://localhost:9696/policy/pdp/engine/topics/sources/<comm>/<topic>/events
-The topic being used is *unauthenticated.DCAE_CL_OUTPUT*, which is subject to change. The onset file is a file that contains the data to inject as the onset. The data contained depends on the use case. This is an example for VoLTE:
+Note: you may have to replace "https" with "http" depending on how you are running the drools-pdp.
+
+The <comm> is a messaging communication infrastructure in an ONAP installation. Depending on how a topic has been defined in the configuration, the <comm> is either "dmaap", "ueb", or "noop".
+The default messaging communication infrastructure is "dmaap".
+
+The <topic> is a specific topic name used to send and/or receive information. There are two types of topics:
+
+1. **source** topics (Example: dmaap.source.topics=APPC-LCM-WRITE or dmaap.source.topics=APPC-CL)
+
+2. **sink** topics (Example: dmaap.sink.topics=APPC-LCM-READ or dmaap.sink.topics=APPC-CL)
+
+You can extract <comm> and <topic> from the following example:
+Example: dmaap.sink.topics=APPC-LCM-READ
+
+1. <comm>=dmaap
+
+2. <topic>=APPC-LCM-READ
+
+The onset is a json file that contains the data to inject as the onset. The data contained depends on the use case. This is an example for the vFirewall usecase:
.. code-block:: json
- :caption: VoLTE_Sample_Onset
+ :caption: vFirewall_Sample_Onset
{
- "closedLoopControlName": "ControlLoop-VOLTE-2179b738-fd36-4843-a71a-a8c24c70c55b",
- "closedLoopAlarmStart": 1484677482204798,
- "closedLoopEventClient": "DCAE.HolmesInstance",
+ "closedLoopControlName": "ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a",
+ "closedLoopAlarmStart": 1463679805324,
+ "closedLoopEventClient": "microservice.stringmatcher",
"closedLoopEventStatus": "ONSET",
- "requestID": "97964e10-686e-4790-8c45-bdfa61df770f",
- "target_type": "VM",
- "target": "vserver.vserver-name",
+ "requestID": "c7c6a4aa-bb61-4a15-b831-ba1472dd4a65",
+ "target_type": "VNF",
+ "target": "generic-vnf.vnf-name",
"AAI": {
"vserver.is-closed-loop-disabled": "false",
- "vserver.vserver-name": "dfw1lb01lb01",
- "service-instance.service-instance-id" : "vserver-name-16102016-aai3255-data-11-1",
- "generic-vnf.vnf-id" : "vnf-id-16102016-aai3255-data-11-1",
- "generic-vnf.vnf-name" : "vnf-name-16102016-aai3255-data-11-1"
+ "vserver.prov-status": "ACTIVE",
+ "generic-vnf.vnf-name": "fw0002vm002fw002",
+ "vserver.vserver-name": "OzVServer"
},
"from": "DCAE",
"version": "1.0.2"
Getting Information
-------------------
-To get the name of the active controller(s), use:
+To get the name(s) of the active controller(s), use:
.. code-block:: bash
curl --insecure --silent --user <username>:<password> -X GET https://localhost:9696/policy/pdp/engine/controllers | python -m json.tool
-To check the facts currently in memory, use the following command. There should be 1 each of org.onap.policy.controlloop.PapParams and org.onap.policy.controlloop.Params per policy pushed.
+ # Example output when running PDP-D with Docker:
+
+ policy@drools:/opt/app/policy/config$ echo $TELEMETRY_USER
+
+ demo@people.osaaf.org
+
+ policy@drools:/opt/app/policy/config$ echo $TELEMETRY_PASSWORD
+
+ demo123456!
+
+ policy@drools:/opt/app/policy/config$ curl --insecure --silent --user demo@people.osaaf.org:demo123456! -X GET https://localhost:9696/policy/pdp/engine/controllers | python -m json.tool
+ [
+ "frankfurt",
+ "usecases"
+ ]
+
+To check the facts currently in working memory, use the following command.
.. code-block:: bash
- curl --insecure --silent --user <username>:<password> -X GET https://localhost:9696/policy/pdp/engine/controllers/<controllerName>/drools/facts/<artifactId> | python -m json.tool
+ curl --insecure --silent --user <username>:<password> -X GET https://localhost:9696/policy/pdp/engine/controllers/<controllerName>/drools/facts | python -m json.tool
+
+ # Example output:
+
+ policy@drools:/opt/app/policy/config$ curl --insecure --silent --user demo@people.osaaf.org:demo123456! -X GET https://localhost:9696/policy/pdp/engine/controllers/frankfurt/drools/facts/ | python -m json.tool
+ {
+ "frankfurt": 0
+ }
+ policy@drools:/opt/app/policy/config$ curl --insecure --silent --user demo@people.osaaf.org:demo123456! -X GET https://localhost:9696/policy/pdp/engine/controllers/usecases/drools/facts/ | python -m json.tool
+ {
+ "usecases": 0
+ }
To get additional information about the controller, use:
curl --insecure --silent --user <username>:<password> -X GET https://localhost:9696/policy/pdp/engine/controllers/<controllerName> | python -m json.tool
+ # Example output:
+
+ policy@drools:/opt/app/policy/config$ curl --insecure --silent --user demo@people.osaaf.org:demo123456! -X GET https://localhost:9696/policy/pdp/engine/controllers/frankfurt/ | python -m json.tool
+ {
+ "alive": true,
+ "name": "frankfurt",
+ "topicSinks": [
+ {
+ "effectiveTopic": "APPC-CL",
+ "topicCommInfrastructure": "NOOP",
+ "servers": [
+ "NOOP"
+ ],
+ "alive": true,
+ "topic": "APPC-CL",
+ "recentEvents": [],
+ "locked": false
+ },
+ {
+ "effectiveTopic": "APPC-LCM-READ",
+ "topicCommInfrastructure": "NOOP",
+ "servers": [
+ "NOOP"
+ ],
+ "alive": true,
+ "topic": "APPC-LCM-READ",
+ "recentEvents": [],
+ "locked": false
+ },
+ {
+ "effectiveTopic": "POLICY-CL-MGT",
+ "topicCommInfrastructure": "NOOP",
+ "servers": [
+ "NOOP"
+ ],
+ "alive": true,
+ "topic": "POLICY-CL-MGT",
+ "recentEvents": [],
+ "locked": false
+ },
+ {
+ "effectiveTopic": "SDNR-CL",
+ "topicCommInfrastructure": "NOOP",
+ "servers": [
+ "NOOP"
+ ],
+ "alive": true,
+ "topic": "SDNR-CL",
+ "recentEvents": [],
+ "locked": false
+ },
+ {
+ "effectiveTopic": "DCAE_CL_RSP",
+ "topicCommInfrastructure": "NOOP",
+ "servers": [
+ "NOOP"
+ ],
+ "alive": true,
+ "topic": "DCAE_CL_RSP",
+ "recentEvents": [],
+ "locked": false
+ }
+ ],
+ "drools": {
+ "sessions": [
+ "frankfurt"
+ ],
+ "alive": true,
+ "brained": true,
+ "groupId": "org.onap.policy.drools-applications.controlloop.common",
+ "recentSourceEvents": [],
+ "version": "1.6.0",
+ "modelClassLoaderHash": -1185895883,
+ "baseDomainNames": [
+ "onap.policies.controlloop.operational.common.Drools",
+ "onap.policies.controlloop.Operational"
+ ],
+ "artifactId": "controller-frankfurt",
+ "recentSinkEvents": [],
+ "sessionCoordinates": [
+ "org.onap.policy.drools-applications.controlloop.common:controller-frankfurt:1.6.0:frankfurt"
+ ],
+ "locked": false
+ },
+ "policyTypes": [
+ {
+ "name": "onap.policies.controlloop.operational.common.Drools",
+ "version": "1.0.0"
+ },
+ {
+ "name": "onap.policies.controlloop.Operational",
+ "version": "1.0.0"
+ }
+ ],
+ "locked": false,
+ "topicSources": [
+ {
+ "effectiveTopic": "DCAE_TOPIC",
+ "topicCommInfrastructure": "NOOP",
+ "servers": [
+ "NOOP"
+ ],
+ "alive": false,
+ "topic": "DCAE_TOPIC",
+ "recentEvents": [],
+ "locked": false
+ },
+ {
+ "effectiveTopic": "APPC-CL",
+ "topicCommInfrastructure": "NOOP",
+ "servers": [
+ "NOOP"
+ ],
+ "alive": false,
+ "topic": "APPC-CL",
+ "recentEvents": [],
+ "locked": false
+ },
+ {
+ "effectiveTopic": "APPC-LCM-WRITE",
+ "topicCommInfrastructure": "NOOP",
+ "servers": [
+ "NOOP"
+ ],
+ "alive": false,
+ "topic": "APPC-LCM-WRITE",
+ "recentEvents": [],
+ "locked": false
+ },
+ {
+ "effectiveTopic": "SDNR-CL-RSP",
+ "topicCommInfrastructure": "NOOP",
+ "servers": [
+ "NOOP"
+ ],
+ "alive": false,
+ "topic": "SDNR-CL-RSP",
+ "recentEvents": [],
+ "locked": false
+ }
+ ]
+ }
+
+Within the telemetry subshell, it is easy to get information. Simply navigate to a specific directory using "cd". Use the "get" command to get information. This is a shorter alternatve to using the "curl" requests as shown above.
+
+To get information about the engine:
+
+ .. image:: img/docker/getEngine.png
+
+To list the names of the active controllers:
+
+ .. image:: img/docker/getControllers.png
+
+To get information about the specific "frankfurt" controller:
+
+ .. image:: img/docker/getFrankfurt.png
+
+To get information about the PDP-D environment:
+
+ .. image:: img/docker/getEnvironment.png
+
+To get a list of features that are currently enabled:
+
+ .. image:: img/docker/getFeatures.png
Simulators
^^^^^^^^^^
-Currently, there are 4 supported simulators: A&AI, SO, vFC, and guard. When they are up, they are accessed via localhost on the following ports: A&AI – 6666, SO – 6667, vFC – 6668, and guard – 6669. They all respond with hard-coded values representing their various success messages except for with certain inputs. For the A&AI simulator, if the value being queried with a “GET” query is “getFail” the simulator returns an exception message, if the value being queried in a “GET” query is “disableClosedLoop” the simulator returns a response with the value of “is-closed-loop-disabled” set to true, and if the value being queried in a named query is “error” the response from the simulator is A&AI’s failure message. The other simulator that can return multiple response is the guard simulator, and that returns a deny response if the closed loop control name passed in is “denyGuard”
+Currently, there are 4 supported simulators: A&AI, SO, vFC, and guard. When they are up, they are accessed via localhost on the following ports:
+
+1. A&AI - localhost:6666
+
+2. SO - localhost:6667
+
+3. vFC - localhost:6668
+
+4. guard - localhost:6669
+
+
+They all respond with hard-coded values representing their various success messages except for with certain inputs. For the A&AI simulator, if the value being queried with a “GET” query is “getFail” the simulator returns an exception message, if the value being queried in a “GET” query is “disableClosedLoop” the simulator returns a response with the value of “is-closed-loop-disabled” set to true, and if the value being queried in a named query is “error” the response from the simulator is A&AI’s failure message.
+
+The other simulator that can return multiple responses is the guard simulator, and that returns a deny response if the closed loop control name passed in is “denyGuard”.
Using the Simulators
--------------------
-To check the status of the simulators, run the command: "*features status*". If the feature controlloop-utils is enabled, the simulators are being used, otherwise, they are not.
+To check the status of the simulators, run the command: "*policy status*". If the feature "controlloop-utils" is enabled, the simulators are being used, otherwise, they are not.
**Turning on the simulators**
- First, make sure the controller is off by running the command “*policy stop*”.
- Then turn the feature off with the command “*features disable controlloop-utils*”.
- - Finally restart the controller by running “*policy start*”.
+ - Finally restart the controller by running “*policy start*”.
- Run “*features status*” again and the *feature controlloop-utils* will be **disabled**.
**For Junits**
- For Junits, the package *org.onap.policy.simulators* is neeeded. In the Util class, there are four methods to start the four different simulators: *buildAaiSim()*, *buildSoSim()*, *buildVfcSim()*, and *buildGuardSim()*. Once the method is called, the simulator should be up and waiting to respond to requests. To bring down the simulators, call *HttpServletServer.factory.destroy()*.
+ For Junits, the package *org.onap.policy.simulators* is needed. In the Util class, there are six methods to start the six different simulators: *buildAaiSim()*, *buildSoSim()*, *buildVfcSim()*, *buildGuardSim()*, *buildSdnc()*, and *buildDmaap()*. Once the method is called, the simulator should be up and waiting to respond to requests. To bring down the simulators, call *HttpServletServer.factory.destroy()*.
-Responses
----------
+Sample Responses
+^^^^^^^^^^^^^^^^
-**A&AI**
+A&AI
+--------
.. code-block:: bash
:caption: vnf-GET-response
{
- "vnf-id": vnfId, //vnfId will be the vnfId you query on. If you query on a vnfName, the id will be "error" if the name is "error", "5e49ca06-2972-4532-9ed4-6d071588d792" otherwise
- "vnf-name": vnfName, //vnfName will be the vnfName you query on. If you query on a vnfId, the name will be "USUCP0PCOIL0110UJRT01"
+ "vnf-id": vnfId, // vnfId will be the vnfId you query on. If you query on a vnfName, the id will be "error" if the name is "error", "5e49ca06-2972-4532-9ed4-6d071588d792" otherwise
+ "vnf-name": vnfName, // vnfName will be the vnfName you query on. If you query on a vnfId, the name will be "USUCP0PCOIL0110UJRT01"
"vnf-type": "RT",
"service-id": "d7bb0a21-66f2-4e6d-87d9-9ef3ced63ae4",
"equipment-role": "UCPE",
"management-v6-address": "2001:1890:e00e:fffd::36",
"in-maint": false,
"prov-status":"ACTIVE",
- "is-closed-loop-disabled": isDisabled, //isDisabled will be true if the vnf name/Id you query on is disableClosedLoop, false otherwise
+ "is-closed-loop-disabled": isDisabled, // isDisabled will be true if the vnf name/Id you query on is disableClosedLoop, false otherwise
"resource-version": "1493389458092",
"relationship-list": {
"relationship": [{
.. code-block:: bash
:caption: vnf-GET-fail
- //This is returned if you query on the value "getFail"
+ // This is returned if you query on the value "getFail"
{
"requestError": {
"serviceException": {
.. code-block:: bash
:caption: vserver-GET-error
- //This is returned if you query on the value "getFail"
+ // This is returned if you query on the value "getFail"
{
"requestError": {
"serviceException": {
}
-**SO**
+SO
+------
.. code-block:: bash
:caption: SO-response
-**vFC**
+vFC
+-------
.. code-block:: bash
:caption: vFC-POST-response
}
-**GUARD**
+GUARD
+---------
.. code-block:: bash
:caption: permit-response
.. code-block:: bash
:caption: deny-response
- //This is returned if the closed loop name is denyGuard
+ // This is returned if the closed loop name is denyGuard
{
"decision": "DENY",
"details": "Decision Deny. You asked for it"
--- /dev/null
+.. This work is licensed under a Creative Commons Attribution 4.0 International License.
+.. http://creativecommons.org/licenses/by/4.0
+
+**********************************************************
+Methods to run PDP-D
+**********************************************************
+
+.. contents::
+ :depth: 2
+
+There are two methods you can use to run a PDP-D for testing purposes:
+
+1. Using Docker
+
+2. Using Eclipse
+
+Using Docker
+^^^^^^^^^^^^
+**Step 1:** Clone the integration/csit repository.
+
+You can find the repo here: https://gerrit.onap.org/r/admin/repos/integration/csit.
+Although this repository is used for CSIT testing, we can use this as a means to get a PDP-D up and running with docker.
+
+ .. code-block:: bash
+
+ git clone "https://gerrit.onap.org/r/integration/csit"
+
+**Step 2:** Note the "docker-compose" commands that will be used.
+
+ .. code-block:: bash
+
+ docker-compose -f ${WORKSPACE}/scripts/policy/docker-compose-drools-apps.yml up -d
+
+ docker-compose -f ${WORKSPACE}/scripts/policy/docker-compose-drools-apps.yml down -v
+
+Note that ${WORKSPACE} refers to the local path where the csit repository is.
+
+**Step 3:** Edit the "docker-compose-drools-apps.yml" file.
+
+Take a look at the "csit/scripts/policy/docker-compose-drools-apps.yml" file. It should look similar to this:
+
+ .. image:: img/docker/yamlClone.png
+
+The following changes need to be made based on which version you are running and your local setup.
+
+ .. code-block:: bash
+
+ ${POLICY_MARIADB_VER} should be "10.2.14" (without quotes, version subject to change)
+
+ ${WORKSPACE} should be the absolute path to the cloned "csit" repository.
+
+ ${POLICY_DROOLS_APPS_VERSION} should be "1.6.0" (without quotes, version subject to change).
+
+If you are using MacOS, you will also need to make the following changes:
+
+ .. code-block:: bash
+
+ expose:
+ - 6969
+ - 9696
+
+ will need to be changed to:
+
+ ports:
+ - "6969:6969"
+ - "9696:9696"
+
+**Step 4:** Start containers and interact with PDP-D.
+
+ .. code-block:: bash
+
+ docker-compose -f scripts/policy/docker-compose-drools-apps.yml up -d
+ docker container ls
+ docker exec -it drools bash
+
+ .. image:: img/docker/dockerComposeUp.png
+
+ .. code-block:: bash
+
+ policy status
+
+ .. image:: img/docker/policyStatus.png
+
+ .. code-block:: bash
+
+ # launches subshell where telemetry commands can be executed
+ telemetry
+
+ ls
+
+ cd controllers
+
+ # Get the current controllers
+ get
+
+ .. image:: img/docker/telemetryCmd.png
+
+ .. code-block:: bash
+
+ # Get information about the "frankfurt" controller
+ get frankfurt
+
+ .. image:: img/docker/getFrankfurt.png
+
+
+ .. code-block:: bash
+
+ docker-compose -f scripts/policy/docker-compose-drools-apps.yml down -v
+
+ .. image:: img/docker/dockerComposeDown.png
+
+In the next section, you will see more about using telemetry commands and interacting with the PDP-D.
+
+Using Eclipse
+^^^^^^^^^^^^^
+
+**Step 1:** Clone 'drools-pdp' repository and create a new directory for eclipse workspace.
+
+Link to repository: https://gerrit.onap.org/r/admin/repos/policy/drools-pdp
+For the purposes of this demo, we will create an new directory to use as a workspace for eclipse.
+
+ .. code-block:: bash
+
+ $ git clone "https://gerrit.onap.org/r/policy/drools-pdp"
+ Cloning into 'drools-pdp'...
+ remote: Counting objects: 59, done
+ remote: Finding sources: 100% (30/30)
+ remote: Total 14406 (delta 0), reused 14399 (delta 0)
+ Receiving objects: 100% (14406/14406), 3.23 MiB | 628.00 KiB/s, done.
+ Resolving deltas: 100% (6630/6630), done.
+ Checking out files: 100% (588/588), done.
+
+ $ mkdir workspace-drools-pdp
+
+ $ ls
+ drools-pdp/ workspace-drools-pdp/
+
+The "drools-pdp/" directory contains the cloned repository and "workspace-drools-pdp/" is an empty directory.
+
+**Step 2:** Import "drools-pdp" as an existing maven project.
+
+Open Eclipse. Hit the **browse** button and navigate to the "workspace-drools-pdp/" directory. Select that folder as the workspace directory and hit **launch**.
+
+ .. image:: img/eclipse/selectDirectory.png
+
+Select File -> Import -> Maven -> Existing Maven Projects -> Next
+
+ .. image:: img/eclipse/importMavenProject.png
+
+Select **Browse** and navigate to the root directory of the cloned project. Hit **Select All** to make sure all projects are included and select **Finish**.
+
+ .. image:: img/eclipse/selectProjectsToImport.png
+
+**Step 3:** Run "policy-management" as a java application
+
+All of the projects will appear in the package explorer after they finish importing. Right click on "policy-management", select "Run As", and select "Java Application".
+
+ .. image:: img/eclipse/runAsJavaApp.png
+
+Type "main" and select the option "Main - org.onap.policy.drools.system" then hit **OK**.
+
+ .. image:: img/eclipse/mainAppSelection.png
+
+If everything is successful, the PDP-D will start running and you will notice output displayed in the console. In the next section, you will see how to interact with the PDP-D using telemetry commands.