update scripts to be executable
[rec.git] / workflows / ric_automation.sh
diff --git a/workflows/ric_automation.sh b/workflows/ric_automation.sh
new file mode 100755 (executable)
index 0000000..57e53cc
--- /dev/null
@@ -0,0 +1,132 @@
+\r
+#------------------------Pre-Modification----------------------------------------------------\r
+mkdir RIC\r
+cd RIC\r
+\r
+#---------Clone the repo and perform the steps customize the deployment and values files------\r
+git clone https://gerrit.o-ran-sc.org/r/it/dep\r
+#run the localize script\r
+cd /home/cloudadmin/RIC/dep\r
+git checkout 189c974169043e89fa216df5ca638fb550e041e4\r
+cat <<EOF >runric_env.sh\r
+\r
+#!/bin/bash\r
+################################################################################\r
+#   Copyright (c) 2019 AT&T Intellectual Property.                             #\r
+#   Copyright (c) 2019 Nokia.                                                  #\r
+#                                                                              #\r
+#   Licensed under the Apache License, Version 2.0 (the "License");            #\r
+#   you may not use this file except in compliance with the License.           #\r
+#   You may obtain a copy of the License at                                    #\r
+#                                                                              #\r
+#       http://www.apache.org/licenses/LICENSE-2.0                             #\r
+#                                                                              #\r
+#   Unless required by applicable law or agreed to in writing, software        #\r
+#   distributed under the License is distributed on an "AS IS" BASIS,          #\r
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #\r
+#   See the License for the specific language governing permissions and        #\r
+#   limitations under the License.                                             #\r
+################################################################################\r
+\r
+\r
+# customize the following repo info to local infrastructure\r
+export __RICENV_SET__='1'\r
+export __RUNRICENV_GERRIT_HOST__='gerrit-o-ran-sc.org'\r
+export __RUNRICENV_GERRIT_IP__='34.215.66.175'_\r
+\r
+export __RUNRICENV_DOCKER_HOST__='rancodev'\r
+export __RUNRICENV_DOCKER_IP__='127.0.0.1'\r
+export __RUNRICENV_DOCKER_PORT__='5555'\r
+export __RUNRICENV_DOCKER_USER__='docker'\r
+export __RUNRICENV_DOCKER_PASS__='docker'\r
+\r
+export __RUNRICENV_HELMREPO_HOST__='chart-repo.kube-system.svc.rec.io'\r
+export __RUNRICENV_HELMREPO_PORT__='8088/charts'\r
+export __RUNRICENV_HELMREPO_IP__='127.0.0.1'\r
+export __RUNRICENV_HELMREPO_USER__='helm'\r
+export __RUNRICENV_HELMREPO_PASS__='helm'\r
+EOF\r
+\r
+source runric_env.sh\r
+./localize.sh\r
+\r
+cd generated/ricplt\r
+deployment_files="$(find . -name deployment.yaml)"\r
+for file in $deployment_files; do\r
+  sed -i '/restartPolicy/d' "$file"\r
+done\r
+\r
+#------------------Delete the nodeport and privileges lines----------------------------------------\r
+sed -ri 's/^(\s*)(type\s*:\s*NodePort\s*$)/\1type: ClusterIP/' appmgr/charts/appmgr/values.yaml\r
+sed -ri 's/^(\s*)(type\s*:\s*NodePort\s*$)/\1type: ClusterIP/' e2mgr/charts/e2mgr/values.yaml\r
+deployment_files="$(find . -name deployment.yaml)"\r
+for file in $deployment_files; do\r
+  sed -i '/privileged: true/d' "$file"\r
+done\r
+\r
+#------------------Edit the appmgr file including the path of the ca certificate-------------------\r
+cp /etc/openssl/ca.pem preric/resources/helmrepo.crt\r
+sed -i '/hostAliases:/,/system.svc.rec.io"/d' appmgr/charts/appmgr/templates/deployment.yaml\r
+\r
+#-----------------Update tiller container name-----------------------------------------------------\r
+sed -ri 's/^(\s*)("tiller-service"\s*:\s*"tiller-deploy"\s*$)/\1"tiller-service": "tiller"/' appmgr/charts/appmgr/values.yaml\r
+\r
+#-----------------Change the repo location to rec.io----------------------------------------------\r
+values_files="$(find . -name values.yaml)"\r
+for file in $values_files; do\r
+  sed -i 's,rancodev:5555,registry.kube-system.svc.rec.io:5555/ric,g' "$file"\r
+done\r
+\r
+#-----------------Change the repo location to rec.io---------------------------------------------\r
+requirements_files="$(find . -name requirements.yaml)"\r
+for file in $requirements_files; do\r
+  sed -i 's,local,localric,g' "$file"\r
+done\r
+\r
+sed -i 's,rancodev:5555,rancodev,g' ./prepull.sh\r
+sed -i 's/docker logout/#/' ./prepull.sh\r
+sed -i 's/docker login/#/' ./prepull.sh\r
+\r
+#!/bin/bash\r
+#-----------------Installation--------------------------------------------------------------------\r
+#--------------Reloading docker images-----------------------------------------------------------\r
+echo "docker" | sh ./prepull.sh\r
+\r
+#retag scripts\r
+for i in  \\r
+"xapp-manager:latest" \\r
+"e2mgr:1.0.0" \\r
+"e2:1.0.0"  \\r
+"rtmgr:0.0.2"  \\r
+"redis-standalone:latest"\r
+do\r
+echo $i\r
+docker tag  rancodev/${i} registry.kube-system.svc.rec.io:5555/ric/${i}\r
+docker push  registry.kube-system.svc.rec.io:5555/ric/${i}\r
+done\r
+\r
+#-------------create ricplatform namespace------------------------------------------------------\r
+kubectl create namespace ricplatform\r
+\r
+#create ricplatform danmnet\r
+cat <<!   | kubectl apply -f -\r
+apiVersion: danm.k8s.io/v1\r
+kind: DanmNet\r
+metadata:\r
+  name: default\r
+  namespace: ricplatform\r
+spec:\r
+  NetworkID: flannel\r
+  NetworkType: flannel\r
+!\r
+\r
+#------------run ric_install script-----------------------------------------------------------\r
+sed -i 's,http://127.0.0.1:8879,http://127.0.0.1:8879/charts,g' "ric_install.sh"\r
+sed -i 's,local,localric,g' "ric_install.sh"\r
+\r
+bash -x ./ric_install.sh\r
+#-------------checking the output-------------------------------------------------------------\r
+command="$(kubectl get po --no-headers --namespace=ricplatform --field-selector status.phase!=Running 2> /dev/null)"\r
+if [[ $command != "" ]]; then\r
+  exit 1\r
+fi\r