Deployment onap rename
[appc/deployment.git] / docs / APPC Platform Logic / APPC Platform Logic.rst
1 .. ============LICENSE_START==========================================\r
2 .. ===================================================================\r
3 .. Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
4 .. ===================================================================\r
5 .. Licensed under the Creative Commons License, Attribution 4.0 Intl.  (the "License");\r
6 .. you may not use this documentation except in compliance with the License.\r
7 .. You may obtain a copy of the License at\r
8 .. \r
9 ..  https://creativecommons.org/licenses/by/4.0/\r
10 .. \r
11 .. Unless required by applicable law or agreed to in writing, software\r
12 .. distributed under the License is distributed on an "AS IS" BASIS,\r
13 .. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
14 .. See the License for the specific language governing permissions and\r
15 .. limitations under the License.\r
16 .. ============LICENSE_END============================================\r
17 .. ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
18 \r
19 ===================\r
20 APPC Platform Logic\r
21 ===================\r
22 \r
23 Platform Logic is a SDNC-based component that was re-purposed in APPC to also be able to load Directed Graphs (DGs) into the APPC MySQL Database, especifically in the SVC_LOGIC table where all the DGs are loaded and activated for use.\r
24 \r
25 In a visual perspective, a Directed Graph is a set of input/output/processing nodes (which are code blocks defining a certain logic or action) connected to each other. This ultimately forms what is denominated as a "service flow" that defines the actions to be taken for a specific APPC action (i.e. an APPC lifecycle/LCM action that restarts a VNF).\r
26 \r
27 For more information on the useability and definition of a Directed Graph, SDNC's Service Logic Interpreter (SLI), and using the DG Builder (AT&T version of Node-RED - also one of APPC's docker containers), please visit the `Service Logic Interpreter Directed Graph Guide <https://wiki.onap.org/display/DW/Service+Logic+Interpreter+Directed+Graph+Guide>`__ in the ONAP Wiki.\r
28 \r
29 \r
30 Platform Logic - Structure\r
31 ==========================\r
32 \r
33 The APPC Platform Logic is based on SDNC's Platform Logic Structure, and they are both based on a maven/pom-based build structure. SDNC Platform Logic code can be found `here <https://gerrit.onap.org/r/gitweb?p=sdnc/oam.git;a=tree;f=platform-logic;h=f4a0366a45c5bad0e1e22606f7dcbe3735b68fd5;hb=HEAD>`__, and APPC Platform Logic code can be found `here <https://gerrit.onap.org/r/gitweb?p=appc/deployment.git;a=tree;f=platform-logic;h=064d6bfe5cdb8437e93a992432c4fbae2cb02931;hb=HEAD>`__. They both have the same basic structure while the main difference is that SDNC hosts the SDNC DGs and APPC hosts the APPC DGs.\r
34 \r
35 The main composition of Platform Logic consists of trigerring shell scripts to call SLI java-based libraries to ultimately load and activate DGs into the MySQL Database.\r
36 \r
37 -  There are two main folders that compose platform-logic:\r
38 \r
39   -  installer: This is where the shell scripts are located on and where the assembly script in XML format that takes care of defining how the platform logic bundle (in a .zip package) will be wrapped up. Since the outcome will be in the form of a ZIP file, the following items will be contained in it:\r
40 \r
41     -  Directed Graphs (in XML format)\r
42     -  Shell Scripts needed to load and activate the Directed Graphs into the SQL Database\r
43     -  Resources (such as the SQL scripts needed to set up VNF_DG_MAPPING table, and svclogic properties needed to point out which SQL DB to load DGs).\r
44     -  JAR SLI libraries needed to execute the load/activation of DGs into the DB.\r
45           \r
46   -  appc: This is where the DGs and its DG attribute definitions script are located at. The following items are contained in here:\r
47 \r
48     -  The DG scripts in XML format are used in conjunction with the shell scripts in the installer path to load and activate DGs into the DB.\r
49     -  The DG scripts in JSON format are used when wanting to load and activate DGs into the DB but using nodered/dgbuilder graphic GUI (the third container deployed in APPC's docker-compose script).\r
50     -  The `graph.versions script <https://gerrit.onap.org/r/gitweb?p=appc/deployment.git;a=blob;f=platform-logic/appc/src/main/resources/graph.versions;h=c3e8fd372bc60d180963af2e09870117debd7398;hb=HEAD>`__ that contains the DG attribute definitions (module name, version number, rpc name, and sync mode) where all this data can all be found in the DG itself. This script is then read by the install.sh script which is the one that runs the `svclogic.sh script <https://gerrit.onap.org/r/gitweb?p=appc/deployment.git;a=blob;f=platform-logic/installer/src/main/scripts/svclogic.sh;h=b9eef1e70c99ba83cdb5108791938014b94c6c86;hb=33a21fd1ddefe0044ea81686209b9d2f1ef35a41>`__ that ultimately calls some the SLI JAR and its dependencies to load and activate the DGs defined in graph.versions into the DB (NOTE: In order for a new DG to be loaded and activated properly, the attributes mentioned above need to be added in its own separate line as part of the graph.versions script).\r
51     -  The pom.xml in here also takes care of grabbing the above items and dropping them in a specific folder path when the docker image is deployed (in this case, /opt/appc/graphs/appc path).\r
52 \r
53 Loading and Activating a DG in the DB using Platform Logic\r
54 ==========================================================\r
55 \r
56 In order to load a DG into the DB to be loaded and activated for use, follow the next steps:\r
57 \r
58 1.  Need to have the XML version of the Directed Graph script and drop it in the xml folder `here <https://gerrit.onap.org/r/gitweb?p=appc/deployment.git;a=tree;f=platform-logic/appc/src/main;hb=HEAD>`__. Take note of the module name, version number, rpc name, and sync mode inside the "service-logic" tag.\r
59 \r
60 2.  Edit the graph.versions script to add the attributes found in the first step above. Make sure that once this script is modified to not leave any end of lines or spaces. Also, it is important to make sure that the script is in UNIX mode and not DOS mode or the script will not be read correctly.\r
61 \r
62 Checking that the DG has been loaded and activated\r
63 ==================================================\r
64 \r
65 First of all, make sure that the graph.versions has been modified and the XML format of the DG is in the xml folder as pointed out above. Then, confirm that these changes have been commited and integrated into the latest release of the APPC docker image. With this latest release of the APPC docker image, there are a number of things to check:\r
66 \r
67 1.  Check that the docker-compose logs show the output of the SLI JAR execution is successful by filtering in the logs as shown in the example below:\r
68 \r
69   .. code:: bash\r
70   \r
71         # Ex. of the logs shown when the Chef DG is loaded and activated\r
72         [appc_controller_container ... Installing directed graphs for APP-C\r
73         [appc_controller_container ... Loading APP-C Directed Graphs from /opt/onap/appc/svclogic/graphs/appc\r
74         ...\r
75         ...\r
76         # Loading the DG into the DB\r
77         [appc_controller_container ... Loading /opt/onap/appc/svclogic/graphs/appc/APPC_chef.xml ...\r
78         [appc_controller_container ... INFO org.openecomp.sdnc.sli.SvcLogicParser - Saving SvcLogicGraph to database (module:APPC,rpc:chef,version:3.0.0,mode:sync)\r
79         ...\r
80         ...\r
81         # Activating the DG into the DB\r
82         [appc_controller_container ... Activating APP-C DG APPC chef 3.0.0 sync\r
83         [appc_controller_container ... INFO org.openecomp.sdnc.sli.SvcLogicParser - Getting SvcLogicGraph from database - (module:APPC, rpc:chef, version:3.0.0, mode:sync)\r
84 \r
85 2.  Once the logs show no errors related to the load/activation of the DGs in the docker logs & the docker-compose containers have been set up, go into the APPC MySQL DB container and check that the SVC_LOGIC table has the DG:\r
86 \r
87   .. code:: bash\r
88   \r
89         # Log into the MySQL APPC Container\r
90         $ docker exec -it sdnc_db_container bash\r
91         bash-4.2# mysql -u root -p  #Password is openECOMP1.0 by default\r
92         \r
93         # Execute SQL commands as explained below\r
94         mysql> USE sdnctl;  #Enter the sdnctl database\r
95         mysql> SHOW tables;  #Checks all available tables - SVC_LOGIC table is the one\r
96         mysql> DESCRIBE SVC_LOGIC;  #shows the fields/columns in the SVC_LOGIC table within the sdnctl DB\r
97         mysql> SELECT module,rpc,version,mode,active FROM SVC_LOGIC;  #shows all the contents of the fields pertaining to the SVC_LOGIC table - this is where the sdnc/appc DGs are at)\r
98         \r
99         # OUTPUT OF THE SELECT SQL CMD (WE CAN SEE THAT THE CHEF DG IS LOADED IN THE TABLE AND ACTIVATED AS SHOWN IN THE 'active' COLUMN)\r
100         +----------+-------------------------+----------------+------+--------+\r
101         | module   | rpc                     | version        | mode | active |\r
102         +----------+-------------------------+----------------+------+--------+\r
103         | APPC     | ansible-adapter-1.0     | 2.0.1          | sync | Y      |\r
104         | APPC     | chef                    | 3.0.0          | sync | Y      |\r
105         | APPC     | Generic_Restart         | 2.0.1          | sync | Y      |\r
106         | APPC     | topology-operation-all  | 2.0.0          | sync | Y      |\r
107         | Appc-API | legacy_operation        | 2.0.0.0        | sync | Y      |\r
108         | ASDC-API | vf-license-model-update | 0.1.0-SNAPSHOT | sync | Y      |\r
109         | sli      | healthcheck             | 0.1.0-SNAPSHOT | sync | Y      |\r
110         +----------+-------------------------+----------------+------+--------+\r
111 \r
112         # NOTE: do NOT add the "graph" field when selecting the columns from SVC_LOGIC above since this is the actual DG blob content which is not relevant\r
113 \r
114 If the table as shown above does not show the DG you have just loaded or if there is an error in the docker-compose logs, check the reason of the error and if needed, raise an JIRA issue related to it. \r