Added Ampere_Openedge hardware type
[rec.git] / workflows / ric_automation.sh
1 #!/bin/bash
2 set -xe
3 #------------------------Pre-Modification----------------------------------------------------
4 mkdir RIC
5 cd RIC
6
7 #---------Clone the repo and perform the steps customize the deployment and values files------
8 git clone https://gerrit.o-ran-sc.org/r/it/dep
9 #run the localize script
10 cd /home/cloudadmin/RIC/dep
11 git checkout 189c974169043e89fa216df5ca638fb550e041e4
12 cat <<EOF >runric_env.sh
13
14 #!/bin/bash
15 ################################################################################
16 #   Copyright (c) 2019 AT&T Intellectual Property.                             #
17 #   Copyright (c) 2019 Nokia.                                                  #
18 #                                                                              #
19 #   Licensed under the Apache License, Version 2.0 (the "License");            #
20 #   you may not use this file except in compliance with the License.           #
21 #   You may obtain a copy of the License at                                    #
22 #                                                                              #
23 #       http://www.apache.org/licenses/LICENSE-2.0                             #
24 #                                                                              #
25 #   Unless required by applicable law or agreed to in writing, software        #
26 #   distributed under the License is distributed on an "AS IS" BASIS,          #
27 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
28 #   See the License for the specific language governing permissions and        #
29 #   limitations under the License.                                             #
30 ################################################################################
31
32
33 # customize the following repo info to local infrastructure
34 export __RICENV_SET__='1'
35 export __RUNRICENV_GERRIT_HOST__='gerrit-o-ran-sc.org'
36 export __RUNRICENV_GERRIT_IP__='34.215.66.175'_
37
38 export __RUNRICENV_DOCKER_HOST__='rancodev'
39 export __RUNRICENV_DOCKER_IP__='127.0.0.1'
40 export __RUNRICENV_DOCKER_PORT__='5555'
41 export __RUNRICENV_DOCKER_USER__='docker'
42 export __RUNRICENV_DOCKER_PASS__='docker'
43
44 export __RUNRICENV_HELMREPO_HOST__='chart-repo.kube-system.svc.rec.io'
45 export __RUNRICENV_HELMREPO_PORT__='8088/charts'
46 export __RUNRICENV_HELMREPO_IP__='127.0.0.1'
47 export __RUNRICENV_HELMREPO_USER__='helm'
48 export __RUNRICENV_HELMREPO_PASS__='helm'
49 EOF
50
51 source runric_env.sh
52 ./localize.sh
53
54 cd generated/ricplt
55 deployment_files="$(find . -name deployment.yaml)"
56 for file in $deployment_files; do
57   sed -i '/restartPolicy/d' "$file"
58 done
59
60 #------------------Delete the nodeport and privileges lines----------------------------------------
61 sed -ri 's/^(\s*)(type\s*:\s*NodePort\s*$)/\1type: ClusterIP/' appmgr/charts/appmgr/values.yaml
62 sed -ri 's/^(\s*)(type\s*:\s*NodePort\s*$)/\1type: ClusterIP/' e2mgr/charts/e2mgr/values.yaml
63 deployment_files="$(find . -name deployment.yaml)"
64 for file in $deployment_files; do
65   sed -i '/privileged: true/d' "$file"
66 done
67
68 #------------------Edit the appmgr file including the path of the ca certificate-------------------
69 cp /etc/openssl/ca.pem preric/resources/helmrepo.crt
70 sed -i '/hostAliases:/,/system.svc.rec.io"/d' appmgr/charts/appmgr/templates/deployment.yaml
71
72 #-----------------Update tiller container name-----------------------------------------------------
73 sed -ri 's/^(\s*)("tiller-service"\s*:\s*"tiller-deploy"\s*$)/\1"tiller-service": "tiller"/' appmgr/charts/appmgr/values.yaml
74
75 #-----------------Change the repo location to rec.io----------------------------------------------
76 values_files="$(find . -name values.yaml)"
77 for file in $values_files; do
78   sed -i 's,rancodev:5555,registry.kube-system.svc.rec.io:5555/ric,g' "$file"
79 done
80
81 #-----------------Change the repo location to rec.io---------------------------------------------
82 requirements_files="$(find . -name requirements.yaml)"
83 for file in $requirements_files; do
84   sed -i 's,local,localric,g' "$file"
85 done
86
87 sed -i 's,rancodev:5555,rancodev,g' ./prepull.sh
88 sed -i 's/docker logout/#/' ./prepull.sh
89 sed -i 's/docker login/#/' ./prepull.sh
90
91 #!/bin/bash
92 #-----------------Installation--------------------------------------------------------------------
93 #--------------Reloading docker images-----------------------------------------------------------
94 echo "docker" | sh ./prepull.sh
95
96 #retag scripts
97 for i in  \
98 "xapp-manager:latest" \
99 "e2mgr:1.0.0" \
100 "e2:1.0.0"  \
101 "rtmgr:0.0.2"  \
102 "redis-standalone:latest"
103 do
104 echo $i
105 docker tag  rancodev/${i} registry.kube-system.svc.rec.io:5555/ric/${i}
106 docker push  registry.kube-system.svc.rec.io:5555/ric/${i}
107 done
108
109 #-------------create ricplatform namespace------------------------------------------------------
110 kubectl create namespace ricplatform
111
112 #create ricplatform danmnet
113 cat <<!   | kubectl apply -f -
114 apiVersion: danm.k8s.io/v1
115 kind: DanmNet
116 metadata:
117   name: default
118   namespace: ricplatform
119 spec:
120   NetworkID: flannel
121   NetworkType: flannel
122 !
123
124 #------------run ric_install script-----------------------------------------------------------
125 sed -i 's,http://127.0.0.1:8879,http://127.0.0.1:8879/charts,g' "ric_install.sh"
126 sed -i 's,local,localric,g' "ric_install.sh"
127
128 bash -x ./ric_install.sh
129 #--------------kill helm---------------------------------------------------------------------
130 pkill helm
131 #-------------checking the output-------------------------------------------------------------
132 for i in `seq 1 10`
133 do
134 command="$(kubectl get po --no-headers --namespace=ricplatform --field-selector status.phase!=Running 2> /dev/null)"
135 if [[ $command != "" ]]; then
136         sleep 30
137 else
138         exit 0
139 fi
140 done
141 exit 1
142
143
144
145