summaryrefslogtreecommitdiffstats
path: root/docs/drools/runningPDPD.rst
blob: 0934c8c95f98d35e8d4616afff41843d34184870 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
.. 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.