Added Ampere_Openedge hardware type
[rec.git] / workflows / nanobot.sh
1 #!/bin/bash
2 #------------------nanobot Pre-modification------------------------------------------------------------
3 cd RIC/test/ric_robot_suite
4 #------------------Build the robot suite---------------------------------------------------------------
5 docker build -t nanobot:latest -f docker/Dockerfile.nanobot .
6
7 #---------pre-create the log file directory- find the value from the values.yaml-----------------------
8 sudo chown -R cloudadmin /opt
9 mkdir -p /opt/ric/robot/log
10
11 kubectl create namespace rictest
12 kubectl create namespace ricxapp
13
14 #----------create ricplatform danmnet-------------------------------------------------------------------
15 cat <<!   | kubectl apply -f -
16 apiVersion: danm.k8s.io/v1
17 kind: DanmNet
18 metadata:
19   name: default
20   namespace: rictest
21 spec:
22   NetworkID: flannel
23   NetworkType: flannel
24 !
25
26 docker tag nanobot:latest registry.kube-system.svc.rec.io:5555/rictest/nanobot:latest
27 docker push registry.kube-system.svc.rec.io:5555/rictest/nanobot:latest
28 pwd
29 cd helm/nanobot
30 #--------edit the values.yaml file in the helm chart for nanobot to point to local registry--------------
31 values_files="$(find . -name values.yaml)"
32 for file in $values_files; do
33   #sed -ri 's/^(\s*)(run\s*:\s*nanobot\s*$)/\1run: registry.kube-system.svc.rec.io:5555/rictest/nanobot/' "$file"
34   sed -i 's/  domain: cluster.local/  domain: rec.io/' "$file"
35   sed -i 's/     repository: .*$/     repository: registry.kube-system.svc.rec.io:5555/' "$file"
36   sed -i 's/     name: test\/nanobot/     name: rictest\/nanobot/' "$file"
37 done
38
39
40 deployment_files="$(find . -name job-ric-robot-run.yaml)"
41 for file in $deployment_files; do
42   sed -i "/restartPolicy: Never/s//&\\n\      nodeSelector:\n        nodename: caas_master1\n/" "$file"
43 done
44
45 #-------------------------add the helm chart to the repo-------------------------------------------------
46 cd ../
47 mkdir -p dist/packages
48 pkill helm
49 helm package -d dist/packages nanobot
50 helm serve --repo-path dist/packages &
51 sleep 2
52 helm repo update
53
54 #-----------------------install the helm chart-----------------------------------------------------------
55 helm install localric/nanobot --namespace rictest --name nanobot
56
57 nanobot_pod=$(kubectl get pods -n rictest -o go-template --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}')
58 sleep 10
59 kubectl logs $nanobot_pod -n rictest
60 #--------------kill helm---------------------------------------------------------------------
61 pkill helm
62 #------------checking the status of the rictest pod--------------------------------------
63 sleep 30
64 command="$(kubectl get po --no-headers --namespace=rictest --field-selector status.phase=Completed 2> /dev/null)"
65 if [[ $command != "" ]]; then
66   exit 1
67 fi
68
69