Add install/uninstall scripts for SMO
[it/dep.git] / smo / bin / install
1 #!/bin/bash
2 ################################################################################
3 #   Copyright (c) 2020 AT&T Intellectual Property.                             #
4 #                                                                              #
5 #   Licensed under the Apache License, Version 2.0 (the "License");            #
6 #   you may not use this file except in compliance with the License.           #
7 #   You may obtain a copy of the License at                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
11 #   Unless required by applicable law or agreed to in writing, software        #
12 #   distributed under the License is distributed on an "AS IS" BASIS,          #
13 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
14 #   See the License for the specific language governing permissions and        #
15 #   limitations under the License.                                             #
16 ################################################################################
17
18 echo "===> Starting at $(date)"
19
20 # to run in backgroudn nohup:
21 #   nohup bash -c "./install && date"  &
22
23
24 # where this scrpt is located
25 SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
26 # where we are when starting
27 STARTDIR="$(pwd)"
28
29 if [ "$1" == "initlocalrepo" ]; then
30   echo && echo "===> Initialize local Helm repo"
31   rm -rf ~/.helm && helm init -c  # without this step helm serve may not work.
32   helm serve &
33   helm repo add local http://127.0.0.1:8879
34 fi
35
36 echo && echo "===> Cleaning up any previous deployment"
37 echo "======> Deleting all Helm deployments"
38 helm list | sed -e 1d | cut -f1 | xargs helm delete --purge
39
40 echo "======> Clearing out all ONAP deployment resources"
41 kubectl delete ns onap
42 kubectl get pv --all-namespaces |cut -f1 -d' ' |xargs kubectl delete pv 
43 kubectl get clusterrolebindings | grep onap | cut -f1 -d' '  |xargs kubectl delete clusterrolebindings 
44 rm -rf /dockerdata-nfs
45
46 echo "======> Clearing out all RICAUX deployment resources"
47 kubectl delete ns ricaux
48 kubectl delete ns ricinfra
49 rm -rf /opt/data/dashboard-data
50
51 echo "======> Clearing out all NONRTRIC deployment resources"
52 kubectl delete ns nonrtric
53
54 echo "======> Preparing for redeployment"
55 mkdir -p /dockerdata-nfs
56 mkdir -p /opt/data/dashboard-data
57 kubectl label --overwrite nodes "$(hostname)" local-storage=enable
58 kubectl label --overwrite nodes "$(hostname)" aaf-storage=enable
59 kubectl label --overwrite nodes "$(hostname)" portal-storage=enable
60
61 echo "======> Preparing working directory"
62 mkdir -p smo-deploy
63 cd smo-deploy
64 WORKINGDIR=$(pwd)
65 CURDIR="$(pwd)"
66
67
68 echo && echo "===> Deploying OAM (ONAP Lite)"
69 if [ ! -d smo-oom ]
70 then
71   echo "======> Building ONAP helm charts.  !! This will take very long time (hours)."
72   cat << EOF >> override-oam.yaml
73 global:
74   aafEnabled: false
75   masterPassword: Berlin1234!
76 cassandra:
77   enabled: false
78 mariadb-galera:
79   enabled: true
80 aaf:
81   enabled: false
82 aai:
83   enabled: false
84 appc:
85   enabled: false
86 clamp:
87   enabled: false
88 cli:
89   enabled: false
90 consul:
91   enabled: true
92 contrib:
93   enabled: false
94 dcaegen2:
95   enabled: false
96 dmaap:
97   enabled: true
98   message-router:
99     enabled: true
100   dmaap-bc:
101     enabled: false
102   dmaap-dr-node:
103     enabled: false
104   dmaap-dr-prov:
105     enabled: false
106 esr:
107   enabled: false
108 log:
109   enabled: false
110 sniro-emulator:
111   enabled: false
112 oof:
113   enabled: false
114 msb:
115   enabled: true
116 multicloud:
117   enabled: false
118 nbi:
119   enabled: false
120 policy:
121   enabled: false
122 pomba:
123   enabled: false
124 portal:
125   enabled: false
126 robot:
127   enabled: false
128 sdc:
129   enabled: false
130 sdnc:
131   enabled: true
132   replicaCount: 1
133   config:
134     sdnr:
135       sdnrwt: true 
136       sdnronly: true
137       sdnrmode: dm
138       mountpointRegistrarEnabled: true
139       mountpointStateProviderEnabled: true
140   cds:
141     enabled: false
142   dmaap-listener:
143     enabled: true
144   ueb-listener:
145     enabled: false
146   sdnc-portal:
147     enabled: false
148   sdnc-ansible-server:
149     enabled: false
150   dgbuilder:
151     enabled: false
152   sdnc-web:
153     enabled: false
154 so:
155   enabled: false
156 uui:
157   enabled: false
158 vfc:
159   enabled: false
160 vid:
161   enabled: false
162 vnfsdk:
163   enabled: false
164 modeling:
165   enabled: false
166 EOF
167
168   git clone -b frankfurt http://gerrit.onap.org/r/oom --recurse-submodules smo-oom
169   cd smo-oom
170   REPOROOTDIR=$(git rev-parse --show-toplevel)
171   git fetch "https://gerrit.onap.org/r/oom" refs/changes/31/106331/6 && git checkout FETCH_HEAD
172   # HEAD is now at 275f7de9 [SDNC] oom for clustered disaggregated SDN-R
173   cp -R ./kubernetes/helm/plugins/ ~/.helm
174
175   cd kubernetes
176   make all; make onap
177   # take a coffee
178   # should see 35 charts
179   helm search onap
180
181   cd $WORKINGDIR
182 fi
183
184 echo "======> Deploying ONAP-lite"
185 helm deploy dev local/onap --namespace onap -f ./override-oam.yaml
186
187 echo "======> Waiting ONAP-lite to reach operatoinal state"
188 NUM_SDNR_RUNNING_PODS="0"
189 NUM_MR_RUNNING_PODS="0"
190
191 while [ "$NUM_MR_RUNNING_PODS" -lt "7" ] || [ "$NUM_SDNR_RUNNING_PODS" -lt "7" ]
192 do
193   sleep 5
194   NUM_SDNR_RUNNING_PODS=$(kubectl get pods --all-namespaces | grep "sdn[\/0-9a-z \-]*Running" | wc -l)
195   NUM_SDNC_COMPLETED_JOBS=$(kubectl get pods --all-namespaces | grep "sdn[\/0-9a-z \-]*Completed" | wc -l)
196   NUM_MR_RUNNING_PODS=$(kubectl get pods --all-namespaces | grep "message-router[\/0-9a-z \-]*Running" | wc -l)
197
198   echo "${NUM_SDNR_RUNNING_PODS}/7 SDNC-SDNR pods and ${NUM_MR_RUNNING_PODS}/7 Message Router pods running"
199 done
200
201
202 echo && echo "===> Deploy NONRTRIIC"
203 git clone http://gerrit.o-ran-sc.org/r/it/dep smo-dep
204 cd smo-dep
205 REPOROOTDIR=$(git rev-parse --show-toplevel)
206
207 cd bin
208 ./deploy-nonrtric -f ${REPOROOTDIR}/RECIPE_EXAMPLE/NONRTRIC/example_recipe.yaml 
209 echo "======> Waiting NONRTRIC to reach operatoinal state"
210 NUM_A1C_RUNNING_PODS="0"
211 NUM_A1SIM_RUNNING_PODS="0"
212 NUM_CP_RUNNING_PODS="0"
213 NUM_DB_RUNNING_PODS="0"
214 NUM_PMS_RUNNING_PODS="0"
215
216 while [ "$NUM_A1C_RUNNING_PODS" -lt "1" ] || [ "$NUM_CP_RUNNING_PODS" -lt "1" ] || \
217       [ "$NUM_DB_RUNNING_PODS" -lt "1" ]|| [ "$NUM_PMS_RUNNING_PODS" -lt "1" ] || \
218       [ "$NUM_A1SIM_RUNNING_PODS" -lt "4" ]
219 do
220   sleep 5
221   NUM_A1C_RUNNING_PODS=$(kubectl get pods -n nonrtric | grep "a1controller[\/0-9a-z \-]*Running" | wc -l)
222   NUM_A1SIM_RUNNING_PODS=$(kubectl get pods -n nonrtric | grep "a1-sim[\/0-9a-z \-]*Running" | wc -l)
223   NUM_CP_RUNNING_PODS=$(kubectl get pods -n nonrtric  | grep "controlpanel[\/0-9a-z \-]*Running" | wc -l)
224   NUM_DB_RUNNING_PODS=$(kubectl get pods -n nonrtric  | grep "db[\/0-9a-z \-]*Running" | wc -l)
225   NUM_PMS_RUNNING_PODS=$(kubectl get pods -n nonrtric  | grep "policymanagementservice[\/0-9a-z \-]*Running" | wc -l)
226
227   echo "${NUM_A1C_RUNNING_PODS}/1 A1Controller pods, ${NUM_CP_RUNNING_PODS}/1 ControlPanel pods, "
228   echo "${NUM_DB_RUNNING_PODS}/1 DB pods, ${NUM_PMS_RUNNING_PODS}/1 PolicyManagementService pods, "
229   echo "and ${NUM_A1SIM_RUNNING_PODS}/4 A1Sim pods  running"
230 done
231
232
233
234 echo && echo "===> Deploying VES collector"
235 cd ${REPOROOTDIR}/ric-aux/helm/ves
236 helm dep update
237 cd ..
238 helm install -f ${REPOROOTDIR}/RECIPE_EXAMPLE/AUX/example_recipe.yaml --name onap-ves --namespace onap ./ves
239
240
241 # edit RECIPE_EXAMPLE/AUX/example_recipe.yaml file
242 #./bin/prepare-common-templates
243 #cd ric-aux/bin
244 #./install -f ${REPOROOTDIR}/RECIPE_EXAMPLE/AUX/example_recipe.yaml -c "ves"
245
246 cd $STARTDIR
247 kubectl get pods --all-namespaces
248
249 echo "===> Completing at $(date)"