Add "code moved" warning to old CLAMP repo readme
[clamp.git] / README.md
1 > **Attention: Unsupported Code**: CLAMP has been moved to the policy framework at https://gerrit.onap.org/r/admin/repos/policy/clamp and is mirrored in github at https://github.com/onap/policy-clamp. The repository has been marked read-only. The code in this repository is held for archive purposes only.
2
3 # Summary
4
5 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.
6
7 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.
8
9 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.
10
11 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.
12
13 # Developer Contact
14 Owner: ONAP CLAMP Dev team
15 Mailing List : onap-discuss@lists.onap.org
16 Add the following prefix to Subject on the mailing list : [CLAMP]
17 See here to subscribe : https://wiki.onap.org/display/DW/Mailing+Lists
18
19 # Wiki
20 https://wiki.onap.org/display/DW/CLAMP+Project
21
22 # Build
23 Jenkins Job: ${jenkins-joblink}
24
25 CLAMP UI: ${cockpit-link}
26
27 Logs: ${elk-link}
28
29 # Docker image
30
31 ## Building 
32 You can use the following command to build the clamp docker image:
33 ```
34 mvn clean install -P docker
35 ```
36
37 ## Deployment
38 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. 
39
40 ### Databases
41 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 :
42 Note that all others configurations can be configured in the JSON as well, 
43
44 ```json
45 {
46     "spring.datasource.url": "jdbc:mysql://anotherDB.onap.org:3306/cldsdb4?autoReconnect=true&connectTimeout=10000&socketTimeout=10000&retriesAllDown=3",
47     "spring.datasource.username": "admin",
48     "spring.datasource.password": "password"
49     
50     "clamp.config.dcae.inventory.url": "http://dcaegen2.host:8080",
51     "clamp.config.dcae.dispatcher.url": "http://dcaegen2.host:8080",
52     "clamp.config.policy.pdpUrl1": "https://policy-pdp.host:9091/pdp/ , testpdp, alpha123",
53     "clamp.config.policy.pdpUrl2": "https://policy-pdp.host:9091/pdp/ , testpdp, alpha123",
54     "clamp.config.policy.papUrl": "https://policy-pap.host:8443/pap/ , testpap, alpha123",
55     "clamp.config.policy.clientKey": "5CE79532B3A2CB4D132FC0C04BF916A7"
56     "clamp.config.files.sdcController":"file:/opt/clamp/config/sdc-controllers-config.json"
57 }
58 ```
59 ### SDC-Controllers config
60
61 This file is a JSON that must be specified to Spring config, here is an example:
62
63 ```json
64 {
65   "sdc-connections":{
66     "sdc-controller1":{
67         "user": "clamp",
68         "consumerGroup": "consumerGroup1",
69         "consumerId": "consumerId1",
70         "environmentName": "AUTO",
71         "sdcAddress": "localhost:8443",
72         "password": "b7acccda32b98c5bb7acccda32b98c5b05D511BD6D93626E90D18E9D24D9B78CD34C7EE8012F0A189A28763E82271E50A5D4EC10C7D93E06E0A2D27CAE66B981",
73         "pollingInterval":30,
74         "pollingTimeout":30,
75         "activateServerTLSAuth":"false",
76         "keyStorePassword":"",
77         "keyStorePath":"",
78         "messageBusAddresses":["dmaaphost.com"]
79     },
80     "sdc-controller2":{
81         "user": "clamp",
82         "consumerGroup": "consumerGroup1",
83         "consumerId": "consumerId1",
84         "environmentName": "AUTO",
85         "sdcAddress": "localhost:8443",
86         "password": "b7acccda32b98c5bb7acccda32b98c5b05D511BD6D93626E90D18E9D24D9B78CD34C7EE8012F0A189A28763E82271E50A5D4EC10C7D93E06E0A2D27CAE66B981",
87         "pollingInterval":30,
88         "pollingTimeout":30,
89         "activateServerTLSAuth":"false",
90         "keyStorePassword":"",
91         "keyStorePath":"",
92         "messageBusAddresses":["dmaaphost.com"]
93     }
94   }
95 }
96 ```
97 Multiple controllers can be configured so that Clamp is able to receive the notifications from different SDC servers.
98 Each Clamp existing in a cluster should have different consumerGroup and consumerId so that they can each consume the SDC notification.
99 The environmentName is normally the Dmaap Topic used by SDC. 
100 If the sdcAddress is not specified or not available (connection failure) the messageBusAddresses will be used (Dmaap servers) 
101
102 ### Docker-compose
103
104 A [docker-compose example file](extra/docker/clamp/docker-compose.yml) can be found under the [extra/docker/clamp/ folder](extra/docker/).
105
106 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 [https://localhost:3000](https://localhost:3000).
107
108
109 ### Logs
110
111 Clamp uses logback framework to generate logs. The logback.xml file can be found under the [src/main/resources/ folder](src/main/resources). 
112
113 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.
114
115 ### Api
116
117 You can see the swagger definition for the jaxrs apis at `/restservices/clds/v1/openapi.json`
118
119 ## Clamp AAF - Renew Certificates
120 - Connect to windriver with openvpn
121 - create a folder aaf-renewal and go to it
122 - create a file aaf.props with that content (or run the agent.sh script below, it will prompt you for values at first run)
123     VERSION=2.1.13
124     DOCKER_REPOSITORY=nexus3.onap.org:10001
125     HOSTNAME=
126     CONTAINER_NS=onap
127     AAF_FQDN=aaf-onap-test.osaaf.org
128     AAF_FQDN_IP=10.12.5.145
129     DEPLOY_FQI=deployer@people.osaaf.org
130     APP_FQDN=clamp
131     APP_FQI=clamp@clamp.onap.org
132     VOLUME=clamp_config
133     DRIVER=local
134     LATITUDE=10
135     LONGITUDE=10
136 - 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'
137 - 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
138 - bash agent.sh bash
139     It's going to ask some questions:
140     Password for deployer@people.osaaf.org: demo123456!
141     AAF Locator URL=https://aaf-onap-test.osaaf.org:8095 
142     # If you do not know your Global Coordinates, we suggest bing.com/maps
143     cadi_latitude[0.000]=10.0
144     cadi_longitude[0.000]=10.0
145 - Certs should created, you can get them in /var/lib/docker/volumes/clamp_config/_data/local
146     If you want to recreate the certs, you have to delete the docker volume (otherwise it will be re used) : docker volume rm clamp_config
147 - 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
148 - to encrypt or decrypt the store passwords:  java -jar aaf-cadi-aaf-2.1.13-full.jar cadi digest changeit testos.key
149 - you can also use the agent.sh script to decrypt the passwords, by running the showpass commands (see wiki below) 
150 - Extract private key from P12: 'openssl pkcs12 -in org.onap.clamp.p12 -nocerts -nodes > clamp.key'
151 - Extract public certificate from P12: 'openssl pkcs12 -in org.onap.clamp.p12 -clcerts -nokeys > clamp.pem'
152 - Extract CA certificate from P12: 'openssl pkcs12 -in org.onap.clamp.p12 -cacerts -nokeys -chain > ca-certs.pem'
153 - reference wiki: https://wiki.onap.org/display/DW/AAF+Certificate+Management+for+Dummies
154 - you need to place new clamp.key, clamp.pem and ca-certs.pem into src/main/resources/clds/aaf/ssl, this will be used by the FrontEnd
155 - you need to replace the password of the generated keystore (clamp uses the p12 keystore), we want to keep the same demo password across release
156    to do so, you can use keytool to update the password and set it back to 'China in the Spring'
157    keytool -storepasswd -keystore ./org.onap.clamp.p12
158 - this will prompt for the current keystore password (the one generated by the aaf script that you can get from the above)
159 - you can then set it to 'China in the Spring'
160 - once done, you can replace : org.onap.clamp.p12 into src/main/resources/clds/aaf
161 - rebuild Clamp Docker containers, they should be updated with the renewed certificates
162
163
164 ## Clamp Credentials
165
166 There are two mechanisms that can enabled for the authentication, one or the other never both at the same time. 
167 They can be enabled in the application.properties.
168
169 1. AAF CA
170 There is a section for SSL enablement and cadi configuration (for AAF) + one spring profile to enable
171
172 server.port=8443
173 server.ssl.key-store=classpath:/clds/aaf/org.onap.clamp.p12
174 server.ssl.key-store-password=enc:WWCxchk4WGBNSvuzLq3MLjMs5ObRybJtts5AI0XD1Vc
175 server.ssl.key-password=enc:WWCxchk4WGBNSvuzLq3MLjMs5ObRybJtts5AI0XD1Vc
176 server.ssl.key-store-type=PKCS12
177 server.ssl.key-alias=clamp@clamp.onap.org
178 clamp.config.keyFile=classpath:/clds/aaf/org.onap.clamp.keyfile
179 server.ssl.client-auth=want
180 server.ssl.trust-store=classpath:/clds/aaf/truststoreONAPall.jks
181 server.ssl.trust-store-password=enc:iDnPBBLq_EMidXlMa1FEuBR8TZzYxrCg66vq_XfLHdJ
182 server.http-to-https-redirection.port=8080
183 ....
184 spring.profiles.active=clamp-default,clamp-aaf-authentication,clamp-sdc-controller-new,clamp-ssl-config
185 ....
186 clamp.config.cadi.keyFile=classpath:/clds/aaf/org.onap.clamp.keyfile
187 clamp.config.cadi.cadiLoglevel=DEBUG
188 clamp.config.cadi.cadiLatitude=10
189 clamp.config.cadi.cadiLongitude=10
190 clamp.config.cadi.aafLocateUrl=https://aaf.api.simpledemo.onap.org:8095
191 clamp.config.cadi.cadiKeystorePassword=enc:V_kq_EwDNb4itWp_lYfDGXIWJzemHGkhkZOxAQI9IHs
192 clamp.config.cadi.cadiTruststorePassword=enc:Mj0YQqNCUKbKq2lPp1kTFQWeqLxaBXKNwd5F1yB1ukf
193 clamp.config.cadi.aafEnv=DEV
194 clamp.config.cadi.aafUrl=https://AAF_LOCATE_URL/AAF_NS.service:2.0
195 clamp.config.cadi.cadiX509Issuers=CN=intermediateCA_9, OU=OSAAF, O=ONAP, C=US:CN=intermediateCA_1, OU=OSAAF, O=ONAP, C=US
196
197 In that case a certificate must be added in the browser and is required to login properly
198 Please check that section to get the certificate
199 https://wiki.onap.org/display/DW/Control+Loop+Flows+and+Models+for+Casablanca#ControlLoopFlowsandModelsforCasablanca-Configure
200
201 Or it can be found in the Clamp source code folder src/main/resources/clds/aaf
202 (Default Password: "China in the Spring")
203
204 2. Spring authentication
205 It's possible to enable the spring authentication by disabling the "clamp-aaf-authentication" profile and enabling only the "clamp-default-user"
206 spring.profiles.active=clamp-default,clamp-default-user,clamp-sdc-controller
207 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`.
208
209 Passwords should be hashed using Bcrypt :
210 ```
211 # pip3 install --no-cache-dir bcrypt  # if you don't have the bcrypt python lib installed, should be done once.
212 # python3 -c 'import bcrypt; print(bcrypt.hashpw("password".encode(), bcrypt.gensalt(rounds=10, prefix=b"2a")))'
213 ```
214
215 Default credentials are admin/password and cs0008/password.
216
217 There is a spring file that disables the AAF and enable the Spring authentication by default. 
218 To use it just add
219
220 --spring.config.name=application-noaaf
221
222 to the jvm parameters. This file is available by default in the java classpath resource folder.