Proposal to remove OSGi dependencies from the CCSDK project
[ccsdk/distribution.git] / lighty / docs / README.md
1 ## Integration of the lighty.io with the CCSDK
2
3 These artifacts contain the examples of how can be the CCSDK integrated with the lighty.io. This
4 integration removes the dependency on the OSGi framework (Karaf) and the Blueprint 
5 dependency injection - instead it uses only the plain java like _main_ method to start
6 the application and plain java constructors as DI (but it is ready to be integrated with
7 other frameworks).
8
9 The CCSDK lighty.io modules can be all started at once (as in this example) or only the
10 selected group of them - in case there is no need to run them all.
11
12 For more information about the lighty.io visit the official web-page 
13 [https://lighty.io](https://lighty.io) or the 
14 [GitHub repository](https://github.com/PantheonTechnologies/lighty-core).
15
16
17 ### Artifact `ccsdk-lighty-module`
18
19 The artifact `ccsdk-lighty-module` contains implementation of the lighty.io module that groups
20 all the other lighty.io modules from the other repositories (core, adaptors, plugins,
21 northbound). These grouped modules can be started all at once using just a few lines of code.
22
23 In addition it contains implementation of the lighty.io module that
24 groups the lighty.io controller (base services from the ODL), the RESTCONF lighty.io module 
25 (the RESTCONF from the ODL integrated with the lighty.io) and the CCSDK lighty.io module
26
27 ### Artifact `ccsdk-lighty-distribution`
28
29 The CCSDK lighty.io application can be started via _main_ method from the _Main_ class.
30 This artifact generates the _.zip_ file containing the _.jar_ file and all other necessary
31 libraries.
32
33 The path to the lighty.io configuration file can be passed to the _main_ method (or to
34 the _.jar_ file) as an argument. This configuration file contains configuration for the
35 lighty.io controller and the RESTCONF (for example the port or the IP address where should
36 the RESTCONF listen or the yang modules that should be imported into the application).
37 The example of the configuration file can be found in the _resources_ directory.
38 If path to the configuration file will not be passed through the _main_ method then
39 the default configuration will be used.
40
41
42 ### Artifact `distribution-lighty-ubuntu-docker`
43
44 The artifact `distribution-lighty-ubuntu-docker` contains the _Dockerfile_ and the _docker-compose.yml_
45 files for the CCSDK lighty.io. _Dockerfile_ is very similar to the original file from
46 the `distribution-odlsli-ubuntu` artifact and the _docker-compose.yml_ to the original file from the 
47 `src/main/yaml` directory in the root of this repository.
48
49 Necessary configuration files and the _.zip_ file containing the CCSDK lighty.io application
50 are copied by the maven plugins into the respective directories during the the maven build.
51
52 The _Dockerfile_ unpacks the _.zip_ distribution generated by the `ccsdk-lighty-distribution`
53 artifact and runs the _startODL.sh_ script that starts the CCSDK lighty.io _.jar_ file using
54 the `src/main/properties/lightyCcsdkConfig.json` configuration file.
55  
56 The _docker-compose.yml_ file contains three images - database, CCSDK lighty.io application
57 and the _DG builder_.
58
59 ### How to run
60
61 In order to run the CCSDK lighty.io application build the `distribution-lighty` repository
62 using the maven with the _docker_ profile enabled (command: `mvn clean install -P docker`).
63 Then run the _docker-compose_ from  the `src/main/docker` directory 
64 (command: `docker-compose -f docker-compose.yml up`).
65
66 After a few seconds CCSDK lighty.io application should be up and running together with the
67 database and the _DG builder_.
68
69 _DG builder_ web UI can be accessed through the `http://localhost:3000` address and RESTCONF at
70 the `http://localhost:8383/restconf` address.
71
72
73 #### DG Builder and the CCSDK lighty.io application example
74
75 In the browser open the `localhost:3000` URL. Login with the default username `dguser` and
76 the password `test123`. In the top right corner click on the menu -> import -> Clipboard.
77 Copy and paste the content of the `hello_world.json` file (from the same directory where is
78 this readme file located) to the text box. Then click on the OK button and place the graph
79 to the sheet.
80
81 To upload and activate the imported graph click on the small empty square on the left side
82 of the `DGSTART` node and then click on the `Upload XML` button. Then click on the `ViewDG List`
83 button and on the `Activate` link in the row where imported graph is.
84
85 After the graph is activated it can be called using the POST REST request on the address:
86
87 `http://<restconf_address:port>/restconf/operations/SLI-API:execute-graph`
88
89 With the body like:
90
91 ```
92 {
93   "input": {
94     "module-name": "<name of the module (service-logic type node)>",
95     "rpc-name": "<name of the rpc (method type node)>",
96     "mode": "sync",
97     "sli-parameter": [
98     ]
99   }
100 }
101 ```
102
103 So in order to call imported _hello world_ graph send the POST request to the address:
104
105 `http://localhost:8383/restconf/operations/SLI-API:execute-graph`
106
107 with the body:
108
109 ```
110 {
111   "input": {
112     "module-name": "Test",
113     "rpc-name": "helloWorld",
114     "mode": "sync",
115     "sli-parameter": [
116     ]
117   }
118 }
119 ```
120
121 Now the _hello world_ message should be displayed in the console where the CCSDK lighty.io
122 application is running.