Update OOF config file
[demo.git] / heat / ONAP / cloud-config / oof_vm_init.sh
1 #!/bin/bash
2
3
4 NEXUS_USERNAME=$(cat /opt/config/nexus_username.txt)
5 NEXUS_PASSWD=$(cat /opt/config/nexus_password.txt)
6 NEXUS_DOCKER_REPO=$(cat /opt/config/nexus_docker_repo.txt)
7 CASS_MUSIC_IMAGE_VERSION=$(cat /opt/config/cass_version.txt)
8 MUSIC_IMAGE_VERSION=$(cat /opt/config/music_version.txt)
9 HAS_IMAGE_VERSION=$(cat /opt/config/has_docker_version.txt)
10 OSDF_IMAGE_VERSION=$(cat /opt/config/osdf_docker_version.txt)
11
12 cd /opt/optf-has
13 git pull
14
15 COND_CONF=/opt/optf-has/conductor.conf
16 LOG_CONF=/opt/optf-has/log.conf
17
18 # Certification file for OOF-HAS
19 AAI_cert=/usr/local/bin/AAF_RootCA.cer
20 BUNDLE=/opt/optf-has/AAF_RootCA.cer
21
22 OSDF_IMG=${NEXUS_DOCKER_REPO}/onap/optf-osdf:${OSDF_IMAGE_VERSION}
23 HAS_IMG=${NEXUS_DOCKER_REPO}/onap/optf-has:${HAS_IMAGE_VERSION}
24
25 # pull OOF images from repo
26 docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO
27 docker pull ${OSDF_IMG}
28 docker pull ${HAS_IMG}
29
30 # Install MUSIC
31 # MUSIC parameters
32 CASS_IMG=${NEXUS_DOCKER_REPO}/onap/music/cassandra_music:$CASS_MUSIC_IMAGE_VERSION
33 MUSIC_IMG=${NEXUS_DOCKER_REPO}/onap/music/music:$MUSIC_IMAGE_VERSION
34 TOMCAT_IMG=library/tomcat:8.5
35 ZK_IMG=library/zookeeper:3.4
36 WORK_DIR=/opt/optf-has
37 CASS_USERNAME=cassandra1
38 CASS_PASSWORD=cassandra1
39
40 # pull MUSIC images
41 docker pull ${ZK_IMG}
42 docker pull ${TOMCAT_IMG}
43 docker pull ${CASS_IMG}
44 docker pull ${MUSIC_IMG}
45
46 # create directory for music properties and logs
47 mkdir -p /opt/optf-has/music/properties
48 mkdir -p /opt/optf-has/music/logs
49
50 # add music.properties file
51 cat > /opt/optf-has/music/properties/music.properties<<NEWFILE
52 my.id=0
53 all.ids=0
54 my.public.ip=localhost
55 all.public.ips=localhost
56
57 #######################################
58
59 # Optional current values are defaults
60
61 #######################################
62 zookeeper.host=music-zk
63 cassandra.host=music-db
64 #music.ip=localhost
65 #debug=true
66 #music.rest.ip=localhost
67 #lock.lease.period=6000
68 cassandra.user=cassandra1
69 cassandra.password=cassandra1
70
71 # AAF Endpoint if using AAF
72 aaf.endpoint.url=https://aaf.api.simpledemo.onap.org
73 NEWFILE
74
75 # Create Volume for mapping war file and tomcat
76 docker volume create music-vol
77
78 # Create a network for all the containers to run in.
79 docker network create music-net
80
81 # Start Cassandra
82 docker run -d --rm --name music-db --network music-net -p "7000:7000" -p "7001:7001" -p "7199:7199" -p "9042:9042" -p "9160:9160" -e CASSUSER=${CASS_USERNAME} -e CASSPASS=${CASS_PASSWORD} ${CASS_IMG}
83
84 # Start Music war
85 docker run -d --rm --name music-war -v music-vol:/app ${MUSIC_IMG}
86
87 # Start Zookeeper
88 docker run -d --rm --name music-zk --network music-net -p "2181:2181" -p "2888:2888" -p "3888:3888" ${ZK_IMG}
89
90 # Delay for Cassandra
91 sleep 20;
92
93 # Start Up tomcat - Needs to have properties,logs dir and war file volume mapped.
94 docker run -d --rm --name music-tomcat --network music-net -p "8080:8080" -v music-vol:/usr/local/tomcat/webapps -v ${WORK_DIR}/music/properties:/opt/app/music/etc:ro -v ${WORK_DIR}/music/logs:/opt/app/music/logs ${TOMCAT_IMG}
95
96 # Connect tomcat to host bridge network so that its port can be seen.
97 docker network connect bridge music-tomcat;
98 sleep 6;
99 echo "Running onboarding curl command"
100 curl -X POST \
101   http://localhost:8080/MUSIC/rest/v2/admin/onboardAppWithMusic \
102   -H 'Cache-Control: no-cache' \
103   -H 'Content-Type: application/json' \
104   -H 'Postman-Token: 7d2839f4-b032-487a-8998-4d1b27a932d7' \
105   -d '{
106 "appname": "conductor",
107 "userId" : "conductor",
108 "isAAF"  : false,
109 "password" : "c0nduct0r"
110 }
111 '
112 echo "Onboarding curl complete"
113
114 # Get MUSIC url
115 MUSIC_URL=$(docker inspect --format '{{ .NetworkSettings.Networks.bridge.IPAddress}}' music-tomcat)
116
117 # Run OOF-HAS
118 # Set A&AI and MUSIC url inside OOF-HAS conductor.conf
119 sed -i "147 s%.*%aaf_url = http://aaf.api.simpledemo.onap.org:8100/authz/perms/user/%" $COND_CONF
120 sed -i "167 s%.*%aaf_sms_url = http://aaf-sms.api.simpledemo.onap.org:10443%" $COND_CONF
121 sed -i "202 s%.*%server_url = https://aai.api.simpledemo.onap.org:8443/aai%" $COND_CONF
122 sed -i "211 s%.*%server_url_version = v14%" $COND_CONF
123 sed -i "382 s%.*%server_url = http://msb.api.simpledemo.onap.org/api/multicloud%" $COND_CONF
124 sed -i "401 s%.*%server_url = http://$MUSIC_URL:8080/MUSIC/rest/v2%" $COND_CONF
125 sed -i "433 s%.*%replication_factor = 1%" $COND_CONF
126 sed -i "536 s%.*%server_url = https://sdnc.api.simpledemo.onap.org:8282/restconf/%" $COND_CONF
127
128 # Set A&AI and SMS authentication file locations inside OOF-HAS conductor.conf
129 sed -i "174 s%.*%aaf_ca_certs = $AAI_cert%" $COND_CONF
130 sed -i "225 s%.*%certificate_authority_bundle_file = $AAI_cert%" $COND_CONF
131
132
133 echo "Values to data component"
134 echo $BUNDLE
135
136 # run optf-has
137 docker run -d --name controller -v $COND_CONF:/usr/local/bin/conductor.conf -v $LOG_CONF:/usr/local/bin/log.conf ${HAS_IMG} python /usr/local/bin/conductor-controller --config-file=/usr/local/bin/conductor.conf
138
139 docker run -d --name api -p "8091:8091" -v $COND_CONF:/usr/local/bin/conductor.conf -v $LOG_CONF:/usr/local/bin/log.conf ${HAS_IMG} python /usr/local/bin/conductor-api --port=8091 -- --config-file=/usr/local/bin/conductor.conf
140
141 docker run -d --name solver -v $COND_CONF:/usr/local/bin/conductor.conf -v $LOG_CONF:/usr/local/bin/log.conf ${HAS_IMG} python /usr/local/bin/conductor-solver --config-file=/usr/local/bin/conductor.conf
142
143 docker run -d --name reservation -v $COND_CONF:/usr/local/bin/conductor.conf -v $LOG_CONF:/usr/local/bin/log.conf ${HAS_IMG} python /usr/local/bin/conductor-reservation --config-file=/usr/local/bin/conductor.conf
144
145 docker run -d --name data -v $COND_CONF:/usr/local/bin/conductor.conf -v $LOG_CONF:/usr/local/bin/log.conf -v $BUNDLE:/usr/local/bin/AAF_RootCA.cer ${HAS_IMG} python /usr/local/bin/conductor-data --config-file=/usr/local/bin/conductor.conf
146
147 sleep 10
148
149 echo "Inserting healthcheck plan"
150
151 curl -X POST \
152   http://$MUSIC_URL:8080/MUSIC/rest/v2/keyspaces/conductor/tables/plans/rows/ \
153   -H 'Cache-Control: no-cache' \
154   -H 'Content-Type: application/json' \
155   -H 'Postman-Token: 502781e8-d588-475d-b181-c2e26625ac95' \
156   -H 'X-minorVersion: 3' \
157   -H 'X-patchVersion: 0' \
158   -H 'ns: conductor' \
159   -H 'password: c0nduct0r' \
160   -H 'userId: conductor' \
161   -d '{
162     "consistencyInfo": {
163         "type": "eventual"
164     },
165     "values": {
166         "id" : "healthcheck",
167         "created": 1479482603641,
168         "message": "",
169         "name": "foo",
170         "recommend_max": 1,
171         "solution": "{\"healthcheck\": \" healthcheck\"}",
172         "status": "done",
173         "template": "{\"healthcheck\": \"healthcheck\"}",
174         "timeout": 3600,
175         "translation": "{\"healthcheck\": \" healthcheck\"}",
176         "updated": 1484324150629
177     }
178 }
179 '
180
181 echo "Healthcheck plan inserted"
182
183
184 #run optf-osdf
185 OSDF_CONFIG=/opt/optf-osdf/config/osdf_config.yaml
186 HAS_HOST=$(docker inspect --format '{{ .NetworkSettings.Networks.bridge.IPAddress}}' api)
187
188 mkdir -p /opt/optf-osdf/config
189
190 cat > $OSDF_CONFIG<<NEWFILE
191
192 placementVersioningEnabled: False
193
194 # Placement API latest version numbers to be set in HTTP header
195 placementMajorVersion: "1"
196 placementMinorVersion: "0"
197 placementPatchVersion: "0"
198
199 # Placement API default version numbers to be set in HTTP header
200 placementDefaultMajorVersion: "1"
201 placementDefaultMinorVersion: "0"
202 placementDefaultPatchVersion: "0"
203
204 # Credentials for SO
205 soUsername: ""   # SO username for call back.
206 soPassword: ""   # SO password for call back.
207
208 # Credentials for Conductor
209 conductorUrl: http://$HAS_HOST:8091/v1/plans/
210 conductorUsername: admin1
211 conductorPassword: plan.15
212 conductorPingWaitTime: 60  # seconds to wait before calling the conductor retry URL
213 conductorMaxRetries: 30  # if we don't get something in 30 minutes, give up
214 # versions to be set in HTTP header
215 conductorMinorVersion: 0
216
217 # Policy Platform -- requires ClientAuth, Authorization, and Environment
218 policyPlatformUrl: http://policy.api.simpledemo.onap.org:8081/pdp/api/getConfig # Policy Dev platform URL
219 policyPlatformEnv: TEST  # Environment for policy platform
220 policyPlatformUsername: testpdp   # Policy platform username.
221 policyPlatformPassword: alpha123   # Policy platform password.
222 policyClientUsername: python   # For use with ClientAuth
223 policyClientPassword: test   # For use with ClientAuth
224
225 # Credentials for DMaaP
226 messageReaderHosts: NA
227 messageReaderTopic: NA
228 messageReaderAafUserId: NA
229 messageReaderAafPassword: NA
230
231 # Credentials for SDC
232 sdcUrl: NA
233 sdcUsername: NA
234 sdcPassword: NA
235 sdcONAPInstanceID: NA
236
237 # Credentials for the OOF placement service - Generic
238 osdfPlacementUsername: test
239 osdfPlacementPassword: testpwd
240
241 # Credentials for the OOF placement service - SO
242 osdfPlacementSOUsername: so_test
243 osdfPlacementSOPassword: so_testpwd
244
245 # Credentials for the OOF placement service - VFC
246 osdfPlacementVFCUsername: vfc_test
247 osdfPlacementVFCPassword: vfc_testpwd
248
249 # Credentials for the OOF CM scheduling service - Generic
250 osdfCMSchedulerUsername: test1
251 osdfCMSchedulerPassword: testpwd1
252
253 is_aaf_enabled: False
254 aaf_cache_expiry_hrs: 3
255 aaf_url: https://aaf.api.simpledemo.onap.org:8100
256 aaf_user_roles:
257     - /api/oof/v1/placement:org.onap.osdf.access|*|read ALL
258
259 # Secret Management Service from AAF
260 aaf_sms_url: https://aaf-sms.api.simpledemo.onap.org:10443
261 aaf_sms_timeout: 30
262 secret_domain: osdf
263 aaf_ca_certs: ssl_certs/aaf_root_ca.cer
264
265 # config db api
266 configDbUrl: http://config.db.url:8080
267 configDbUserName: osdf
268 configDbPassword: passwd
269 configDbGetCellListUrl: 'SDNCConfigDBAPI/getCellList'
270 configDbGetNbrListUrl: 'SDNCConfigDBAPI/getNbrList'
271
272 # Credentials for PCIHandler
273 pciHMSUsername: ""   # pcihandler username for call back.
274 pciHMSPassword: ""   # pcihandler password for call back.
275
276 # Credentials for the OOF PCI Opt service
277 osdfPCIOptUsername: pci_test
278 osdfPCIOptPassword: pci_testpwd
279
280
281 NEWFILE
282
283 docker run -d --name osdf -v $OSDF_CONFIG:/opt/app/config/osdf_config.yaml -p 8698:8699 ${OSDF_IMG}