148ff959cb3a4f719b54b94b6b7f4102aa616ea6
[clamp.git] / README.md
1 # Summary
2
3 CLAMP is a platform for designing and managing control loops. It is used to design a closed loop, configure it with specific parameters for a particular network service, then deploying and undeploying it.  Once deployed, the user can also update the loop with new parameters during runtime, as well as suspending and restarting it.
4
5 It interacts with other systems to deploy and execute the closed loop. For example, it pushes the control loop design to the SDC catalog, associating it with the VF resource.  It requests from DCAE the instantiation of microservices to manage the closed loop flow.  Further, it creates and updates multiple policies in the Policy Engine that define the closed loop flow.
6
7 The ONAP CLAMP platform abstracts the details of these systems under the concept of a control loop model.  The design of a control loop and its management is represented by a workflow in which all relevant system interactions take place.  This is essential for a self-service model of creating and managing control loops, where no low-level user interaction with other components is required.
8
9 At a higher level, CLAMP is about supporting and managing the broad operational life cycle of VNFs/VMs and ultimately ONAP components itself. It will offer the ability to design, test, deploy and update control loop automation - both closed and open. Automating these functions would represent a significant saving on operational costs compared to traditional methods.
10
11 # Developer Contact
12 Owner: ONAP CLAMP Dev team
13 Mailing List : onap-discuss@lists.onap.org
14 Add the following prefix to Subject on the mailing list : [CLAMP]
15 See here to subscribe : https://wiki.onap.org/display/DW/Mailing+Lists
16
17 # Wiki
18 https://wiki.onap.org/display/DW/CLAMP+Project
19
20 # Build
21 Jenkins Job: ${jenkins-joblink}
22
23 CLAMP UI: ${cockpit-link}
24
25 Logs: ${elk-link}
26
27 # Docker image
28
29 ## Building 
30 You can use the following command to build the clamp docker image:
31 ```
32 mvn clean install -P docker
33 ```
34
35 ## Deployment
36 Currently, the clamp docker image can be deployed with small configuration needs. Though, you might need to make small adjustments to the configuration. As clamp is spring based, you can use the SPRING_APPLICATION_JSON environment variable to update its parameters. 
37
38 ### Databases
39 There are two needed datasource for Clamp. By default, both will try to connect to the localhost server using the credentials available in the example SQL files. If you need to change the default database host and/or credentials, you can do it by using the following json as SPRING_APPLICATION_JSON environment variable :
40 Note that all others configurations can be configured in the JSON as well, 
41
42 ```json
43 {
44     "spring.datasource.cldsdb.url": "jdbc:mysql://anotherDB.onap.org:3306/cldsdb4?autoReconnect=true&connectTimeout=10000&socketTimeout=10000&retriesAllDown=3",
45     "spring.datasource.cldsdb.username": "admin",
46     "spring.datasource.cldsdb.password": "password"
47     
48     "clamp.config.dcae.inventory.url": "http://dcaegen2.host:8080",
49     "clamp.config.dcae.dispatcher.url": "http://dcaegen2.host:8080",
50     "clamp.config.policy.pdpUrl1": "https://policy-pdp.host:9091/pdp/ , testpdp, alpha123",
51     "clamp.config.policy.pdpUrl2": "https://policy-pdp.host:9091/pdp/ , testpdp, alpha123",
52     "clamp.config.policy.papUrl": "https://policy-pap.host:8443/pap/ , testpap, alpha123",
53     "clamp.config.policy.clientKey": "5CE79532B3A2CB4D132FC0C04BF916A7"
54     "clamp.config.files.sdcController":"file:/opt/clamp/config/sdc-controllers-config.json"
55 }
56 ```
57 ### SDC-Controllers config
58
59 This file is a JSON that must be specified to Spring config, here is an example:
60
61 ```json
62 {
63   "sdc-connections":{
64     "sdc-controller1":{
65         "user": "clamp",
66         "consumerGroup": "consumerGroup1",
67         "consumerId": "consumerId1",
68         "environmentName": "AUTO",
69         "sdcAddress": "localhost:8443",
70         "password": "b7acccda32b98c5bb7acccda32b98c5b05D511BD6D93626E90D18E9D24D9B78CD34C7EE8012F0A189A28763E82271E50A5D4EC10C7D93E06E0A2D27CAE66B981",
71         "pollingInterval":30,
72         "pollingTimeout":30,
73         "activateServerTLSAuth":"false",
74         "keyStorePassword":"",
75         "keyStorePath":"",
76         "messageBusAddresses":["dmaaphost.com"]
77     },
78     "sdc-controller2":{
79         "user": "clamp",
80         "consumerGroup": "consumerGroup1",
81         "consumerId": "consumerId1",
82         "environmentName": "AUTO",
83         "sdcAddress": "localhost:8443",
84         "password": "b7acccda32b98c5bb7acccda32b98c5b05D511BD6D93626E90D18E9D24D9B78CD34C7EE8012F0A189A28763E82271E50A5D4EC10C7D93E06E0A2D27CAE66B981",
85         "pollingInterval":30,
86         "pollingTimeout":30,
87         "activateServerTLSAuth":"false",
88         "keyStorePassword":"",
89         "keyStorePath":"",
90         "messageBusAddresses":["dmaaphost.com"]
91     }
92   }
93 }
94 ```
95 Multiple controllers can be configured so that Clamp is able to receive the notifications from different SDC servers.
96 Each Clamp existing in a cluster should have different consumerGroup and consumerId so that they can each consume the SDC notification.
97 The environmentName is normally the Dmaap Topic used by SDC. 
98 If the sdcAddress is not specified or not available (connection failure) the messageBusAddresses will be used (Dmaap servers) 
99
100 ### Docker-compose
101
102 A [docker-compose example file](extra/docker/clamp/docker-compose.yml) can be found under the [extra/docker/clamp/ folder](extra/docker/).
103
104 Once the image has been built and is available locally, you can use the `docker-compose up` command to deploy a prepopullated database and a clamp instance available on [http://localhost:8080/designer/index.html](http://localhost:8080/designer/index.html).
105
106
107 ### Logs
108
109 Clamp uses logback framework to generate logs. The logback.xml file can be found under the [src/main/resources/ folder](src/main/resources). 
110
111 With the default log settings, all logs will be generated into console and into root.log file under the Clamp root folder. The root.log file is not allowed to be appended, thus restarting the clamp will result in cleaning of the old log files.
112
113 ### Api
114
115 You can see the swagger definition for the jaxrs apis at `/restservices/clds/v1/openapi.json`
116
117 ## Clamp AAF
118 - Connect to windriver with openvpn
119 - create a folder aaf-renewal and go to it
120 - create a file aaf.props with that content
121     VERSION=2.1.13
122     DOCKER_REPOSITORY=nexus3.onap.org:10001
123     HOSTNAME=
124     CONTAINER_NS=onap
125     AAF_FQDN=aaf-onap-test.osaaf.org
126     AAF_FQDN_IP=10.12.5.145
127     DEPLOY_FQI=deployer@people.osaaf.org
128     APP_FQDN=clamp
129     APP_FQI=clamp@clamp.onap.org
130     VOLUME=clamp_config
131     DRIVER=local
132     LATITUDE=10
133     LONGITUDE=10
134 - wget -O agent.sh 'https://gerrit.onap.org/r/gitweb?p=aaf/authz.git;a=blob_plain;f=auth/docker/agent.sh;h=32910874e01ad13865510091ddd4ef9ae5966410;hb=refs/heads/elalto'
135 - wget https://nexus.onap.org/content/repositories/releases/org/onap/aaf/authz/aaf-auth-cmd/2.1.13/aaf-auth-cmd-2.1.13-full.jar
136 - bash agent.sh bash
137     It's going to ask some questions:
138     Password for deployer@people.osaaf.org: demo123456!
139     AAF Locator URL=https://aaf-onap-test.osaaf.org:8095 
140     # If you do not know your Global Coordinates, we suggest bing.com/maps
141     cadi_latitude[0.000]=10.0
142     cadi_longitude[0.000]=10.0
143 - Certs should created, you can get them in /var/lib/docker/volumes/clamp_config/_data/local
144 - wget https://nexus.onap.org/content/repositories/releases/org/onap/aaf/authz/aaf-cadi-aaf/2.1.13/aaf-cadi-aaf-2.1.13-full.jar
145 - to encrypt or decrypt the store passwords:  java -jar aaf-cadi-aaf-2.1.13-full.jar cadi digest changeit testos.key
146
147 - Extract private key from P12: 'openssl pkcs12 -in org.onap.clamp.p12 -nocerts -nodes > clamp.key'
148 - Extract public certificate from P12: 'openssl pkcs12 -in org.onap.clamp.p12 -clcerts -nokeys > clamp.pem'
149 - Extract CA certificate from P12: 'openssl pkcs12 -in org.onap.clamp.p12 -cacerts -nokeys -chain > ca-certs.pem'
150 - reference wiki: https://wiki.onap.org/display/DW/AAF+Certificate+Management+for+Dummies
151 ## Clamp Credentials
152
153 There are two mechanisms that can enabled for the authentication, one or the other never both at the same time. 
154 They can be enabled in the application.properties.
155
156 1. AAF CA
157 There is a section for SSL enablement and cadi configuration (for AAF) + one spring profile to enable
158
159 server.port=8443
160 server.ssl.key-store=classpath:/clds/aaf/org.onap.clamp.p12
161 server.ssl.key-store-password=China in the Spring
162 server.ssl.key-password=China in the Spring
163 server.ssl.key-store-type=PKCS12
164 server.ssl.key-alias=clamp@clamp.onap.org
165 server.ssl.client-auth=want
166 server.ssl.trust-store=classpath:/clds/aaf/truststoreONAPall.jks
167 server.ssl.trust-store-password=changeit
168
169 server.http-to-https-redirection.port=8080
170 ....
171 spring.profiles.active=clamp-default,clamp-aaf-authentication,clamp-sdc-controller
172 ....
173 clamp.config.cadi.keyFile=classpath:/clds/aaf/org.onap.clamp.keyfile
174 clamp.config.cadi.cadiLoglevel=DEBUG
175 clamp.config.cadi.cadiLatitude=10
176 clamp.config.cadi.cadiLongitude=10
177 clamp.config.cadi.aafLocateUrl=https://aaf.api.simpledemo.onap.org:8095
178 clamp.config.cadi.cadiKeystorePassword=enc:V_kq_EwDNb4itWp_lYfDGXIWJzemHGkhkZOxAQI9IHs
179 clamp.config.cadi.cadiTruststorePassword=enc:Mj0YQqNCUKbKq2lPp1kTFQWeqLxaBXKNwd5F1yB1ukf
180 clamp.config.cadi.aafEnv=DEV
181 clamp.config.cadi.aafUrl=https://AAF_LOCATE_URL/AAF_NS.service:2.0
182 clamp.config.cadi.cadiX509Issuers=CN=intermediateCA_9, OU=OSAAF, O=ONAP, C=US:CN=intermediateCA_1, OU=OSAAF, O=ONAP, C=US
183
184 In that case a certificate must be added in the browser and is required to login properly
185 Please check that section to get the certificate
186 https://wiki.onap.org/display/DW/Control+Loop+Flows+and+Models+for+Casablanca#ControlLoopFlowsandModelsforCasablanca-Configure
187
188 Or it can be found in the Clamp source code folder src/main/resources/clds/aaf
189 (Default Password: "China in the Spring")
190
191 2. Spring authentication
192 It's possible to enable the spring authentication by disabling the "clamp-aaf-authentication" profile and enabling only the "clamp-default-user"
193 spring.profiles.active=clamp-default,clamp-default-user,clamp-sdc-controller
194 In that case, the credentials should be specified in `src/main/resources/clds/clds-users.json`. You might specify you own credential file by redefining the `clamp.config.files.cldsUsers` in `application.properties`.
195
196 Passwords should be hashed using Bcrypt :
197 ```
198 # pip3 install bcrypt  # if you don't have the bcrypt python lib installed, should be done once.
199 # python3 -c 'import bcrypt; print(bcrypt.hashpw("password".encode(), bcrypt.gensalt(rounds=10, prefix=b"2a")))'
200 ```
201
202 Default credentials are admin/password and cs0008/password.
203
204 There is a spring file that disables the AAF and enable the Spring authentication by default. 
205 To use it just add
206
207 --spring.config.name=application-noaaf
208
209 to the jvm parameters. This file is available by default in the java classpath resource folder.