-
Notifications
You must be signed in to change notification settings - Fork 58
607 lines (467 loc) · 26.2 KB
/
odimra_deployment.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
name: odimra_deploy
on:
pull_request:
branches:
- '**'
jobs:
build:
name: Deploy
runs-on: ubuntu-22.04
continue-on-error: false
steps:
- uses: actions/checkout@v2
- name: configure pre-req for odimra deployment
run: |
set +e
echo "[$(date)] -- INFO -- Start pre req conguration"
echo
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
sudo systemctl status docker.service
echo "=========reloading docker ================"
sudo service docker reload
echo "=========checking docker status================"
sudo service docker status
echo "[$(date)] -- INFO -- running actions as ${USER}"
echo
export PASSWD=password
export REDIS_PASSWORD=redis_password
echo "runner:${PASSWD}" > pass
sudo chpasswd < pass
echo "[$(date)] -- INFO -- configure ssh key auth"
sudo sed -i 's/PasswordAuthentication yes/PasswordAuthentication no/g' /etc/ssh/sshd_config
echo
echo "[$(date)] -- INFO -- restart sshd service"
sudo systemctl restart sshd
echo
echo "[$(date)] -- INFO -- create ssh key"
ssh-keygen -t rsa -b 2048 -N "" -f $HOME/.ssh/id_rsa > /dev/null
cat $HOME/.ssh/id_rsa.pub > $HOME/.ssh/authorized_keys
sudo chown runner:runner /home/runner/.ssh/authorized_keys
chmod go-w ~/
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
echo
echo "[$(date)] -- INFO -- set cur_path, VM_IP, host_name, FQDN, SSHPASS env variables"
export cur_path=$(pwd)
export VM_IP=$(hostname -I | awk '{print $1}')
export host_name=$(hostname)
export FQDN="odim.controller.com"
export SSHPASS=${PASSWD}
export ODIMRA_USER_ID=2021
export ODIMRA_GROUP_ID=2021
echo "[$(date)] -- INFO -- add FQDN to /etc/hosts"
cat << EOF | sudo tee -a /etc/hosts
$VM_IP $FQDN $host_name
$DestinationIP $DestinationDomain odim
EOF
echo
echo '127.0.0.1 odim.100.com' | sudo tee -a /etc/hosts
echo '127.0.0.1 odim.test24.com' | sudo tee -a /etc/hosts
echo '127.0.0.1 odim.destination.com' sudo tee -a /etc/hosts
echo '127.0.0.1 odim.test1.com' sudo tee -a /etc/hosts
echo '127.0.0.1 odim.ip.com' sudo tee -a /etc/hosts
echo "[$(date)] -- INFO -- configure golang"
sudo rm -rf /usr/bin/go
wget -q https://dl.google.com/go/go1.19.5.linux-amd64.tar.gz -P /var/tmp
sudo tar -C /usr/local -xzf /var/tmp/go1.19.5.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
export GO111MODULE=on
export GOROOT=/usr/local/go
export PATH=$PATH:${GOROOT}/bin
echo
echo "[$(date)] -- INFO -- configured golang version"
go version
echo
echo "[$(date)] -- INFO -- install required linux packages"
sudo apt-get -qq update
sudo apt-get -qq install sshpass -y
sudo apt-get -qq install python3.8 -y
sudo apt-get -qq install python3-pip -y
sudo apt-get -qq install python3-setuptools -y
sudo apt-get -qq install software-properties-common -y
sudo apt-get -qq install openjdk-11-jre-headless -y
sudo -E apt-add-repository ppa:ansible/ansible -y
echo
echo "[$(date)] -- INFO -- install required python packages"
python3 -m pip install --upgrade pip
pip3 install pycrypto==2.6.1
pip3 install pycryptodome==3.9.8
pip3 install ansible==5.7.1
pip3 install jinja2==2.11.1
pip3 install netaddr==0.7.19
pip3 install pbr==5.4.4
pip3 install hvac==0.10.0
pip3 install jmespath==0.9.5
pip3 install ruamel.yaml==0.16.10
pip3 install pyyaml==5.3.1
pip3 install cryptography==3.4.8
echo
echo "[$(date)] -- INFO -- installed python version"
python3 --version
echo
export ODIM_SOURCE_PATH=${cur_path}
export ODIM_CONTROLLER_PATH=${ODIM_SOURCE_PATH}/odim-controller
cd ${ODIM_CONTROLLER_PATH}/scripts/
cp kube_deploy_nodes.yaml.tmpl kube_deploy_nodes.yaml
echo ${PASSWD} > node_pass
echo ${PASSWD} > vault_pass
echo ${REDIS_PASSWORD} > redis_inmemory_pass
echo ${REDIS_PASSWORD} > redis_ondisk_pass
ls -ltra
echo
echo "[$(date)] -- INFO -- build odim-vault binary"
export GO111MODULE=off
go get golang.org/x/crypto/pbkdf2
echo "GO111MODULE : " $GO111MODULE
go build -ldflags "-s -w" -o odim-vault odim-vault.go
echo
echo "[$(date)] -- INFO -- encrypt passwords"
./odim-vault -encode ${ODIM_CONTROLLER_PATH}/scripts/vault_pass
./odim-vault -key ${ODIM_CONTROLLER_PATH}/scripts/vault_pass -encrypt ${ODIM_CONTROLLER_PATH}/scripts/node_pass
./odim-vault -key ${ODIM_CONTROLLER_PATH}/scripts/vault_pass -encrypt ${ODIM_CONTROLLER_PATH}/scripts/redis_inmemory_pass
./odim-vault -key ${ODIM_CONTROLLER_PATH}/scripts/vault_pass -encrypt ${ODIM_CONTROLLER_PATH}/scripts/redis_ondisk_pass
mkdir -p ${cur_path}/k8s_images ${cur_path}/odim_images ${cur_path}/odim_plugins
export rootServiceUUID=$(uuidgen)
export NODE_PASS_FILEPATH=${ODIM_CONTROLLER_PATH}/scripts/node_pass
export VAULTKEY_FILEPATH=${ODIM_CONTROLLER_PATH}/scripts/vault_pass
export REDIS_INMEMORY_FILEPATH=${ODIM_CONTROLLER_PATH}/scripts/redis_inmemory_pass
export REDIS_ONDISK_FILEPATH=${ODIM_CONTROLLER_PATH}/scripts/redis_ondisk_pass
export K8S_IMAGE_PATH=${cur_path}/k8s_images
export ODIM_IMAGE_PATH=${cur_path}/odim_images
export ODIM_PLUGIN_PATH=${cur_path}/odim_plugins
sed -i "/Node[23]_/d; /kubernetesImagePath:/d; /odimraImagePath:/d; s#.*deploymentID.*#deploymentID: OneNodeDeployment#; \
s#.*httpProxy.*#httpProxy: \"\"#; s#.*httpsProxy.*#httpsProxy: \"\"#; s#.*noProxy.*#noProxy: \"\"#; \
s#.*nodePasswordFilePath.*#nodePasswordFilePath: ${NODE_PASS_FILEPATH}#; \
s#.*redisInMemoryPasswordFilePath.*#redisInMemoryPasswordFilePath: ${REDIS_INMEMORY_FILEPATH}#; \
s#.*redisOnDiskPasswordFilePath.*#redisOnDiskPasswordFilePath: ${REDIS_ONDISK_FILEPATH}#; \
s#.*odimControllerSrcPath.*#odimControllerSrcPath: ${ODIM_CONTROLLER_PATH}#; \
s#.*odimVaultKeyFilePath.*#odimVaultKeyFilePath: ${VAULTKEY_FILEPATH}#; \
s#.*odimCertsPath.*#odimCertsPath: \"\"#; s#.*odimPluginPath.*#odimPluginPath: ${ODIM_PLUGIN_PATH}#; \
s#.*<Node1_Hostname>.*# ${host_name}:#; s/ip:\s*<Node1_IPAddress>/ip: ${VM_IP}/; \
s#username:\s*<Node1_Username>#username: ${USER}#; s#.*fqdn.*# fqdn: \"${FQDN}\"#; \
s#.*groupID.*# groupID: ${ODIMRA_GROUP_ID}#; s#.*userID.*# userID: ${ODIMRA_USER_ID}#; \
s#.*rootServiceUUID.*# rootServiceUUID: ${rootServiceUUID}#; s#.*haDeploymentEnabled.*# haDeploymentEnabled: false#; \
s#.*messageBusType.*# messageBusType: "Kafka"#; \
s#.*odimraServerCertFQDNSan.*# odimraServerCertFQDNSan: \"redis-inmemory,redis-ondisk\"#; s#.*odimraServerCertIPSan.*# odimraServerCertIPSan: \"\"#; \
s#.*odimraKafkaClientCertFQDNSan.*# odimraKafkaClientCertFQDNSan: \"\"#; \
s#.*odimraKafkaClientCertIPSan.*# odimraKafkaClientCertIPSan: \"\"#; \
s#.*imageRegistryAddress.*# imageRegistryAddress: \"\"#; \
s#.*etcHostsEntries.*# etcHostsEntries: \"\"#" kube_deploy_nodes.yaml
echo "[$(date)] -- INFO -- configured values in kube_deploy_nodes.yaml"
cat kube_deploy_nodes.yaml
echo
cd ${ODIM_SOURCE_PATH}/
time ./build_images.sh
echo "the images that got built are :"
sleep 30
docker images
mkdir ${ODIM_SOURCE_PATH}/odimra_images
cd ${ODIM_SOURCE_PATH}/odimra_images
for i in `echo lenovoplugin dellplugin grfplugin urplugin licenses update task systems managers telemetry fabrics events api aggregation account-session zookeeper kafka redis etcd`
do
echo $i
docker save -o ${i}.tar $i
done
ls -l
echo "==============updating the docker handler========="
cd ${ODIM_CONTROLLER_PATH}/kubespray
tar -xvzf kubespray-2.20.0.tar.gz
cd kubespray-2.20.0/roles/container-engine/docker/handlers
sed -i "22,32d" main.yml
sed -i "7,8d" main.yml
cat main.yml
cd ${ODIM_CONTROLLER_PATH}/kubespray
tar -cvzf kubespray-2.20.0.tar.gz kubespray-2.20.0
rm -rf kubespray-2.20.0
ls
sudo service docker stop
sudo apt-get remove -y --allow-change-held-packages containerd.io docker-ce docker-ce-cli docker-ce-rootless-extras
cd ${ODIM_CONTROLLER_PATH}/scripts/
echo "[$(date)] -- INFO -- install kubernetes using odim-controller"
python3 odim-controller.py --deploy kubernetes --config ${ODIM_CONTROLLER_PATH}/scripts/kube_deploy_nodes.yaml
if [ $? -eq 0 ];
then
echo "Kubernetes installation is successful"
else
echo "Kubernetes installation failed..."
exit 1
fi
echo "[$(date)] -- INFO -- configure docker and kubectl commands"
sudo usermod -aG docker $USER
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
echo
echo "[$(date)] -- INFO -- list pods in kube-system namespace"
kubectl get pods -n kube-system -o wide
echo
#cd ${ODIM_SOURCE_PATH}/
#time ./build_images.sh
#echo "the images that got built are :"
#docker images
cd ${ODIM_SOURCE_PATH}/odimra_images
for i in `echo lenovoplugin dellplugin grfplugin urplugin licenses update task systems managers telemetry fabrics events api aggregation account-session zookeeper kafka redis etcd`
do
echo $i
sudo ctr -n=k8s.io images list
echo sudo ctr -n=k8s.io images import ${ODIM_SOURCE_PATH}/odimra_images/${i}.tar
sudo ctr -n=k8s.io images import ${ODIM_SOURCE_PATH}/odimra_images/${i}.tar
done
sleep 60
sudo ctr -n=k8s.io images list
cd ${ODIM_CONTROLLER_PATH}/scripts/
python3 odim-controller.py --deploy odimra --config ${ODIM_CONTROLLER_PATH}/scripts/kube_deploy_nodes.yaml
if [ $? -eq 0 ];
then
echo "Odimra installation is successful"
else
echo "Odimra installation failed..."
exit 1
fi
echo
echo "[$(date)] -- INFO -- list pods in odim namespace"
count=0
while [[ $(kubectl get pods -n odim -o wide | grep "Running" | wc -l) -ne 15 ]]; do
if [[ $count -eq 6 ]]; then
break
fi
sleep 10
count=$((count+1))
done
kubectl get pods -n odim -o wide
echo "============Checking Node status================"
kubectl get node -o wide
echo "===========Checking for services=============="
kubectl get svc -n odim
echo "$VM_IP"
echo " ====================== Adding URP Plugin ==================================="
sudo mkdir -p /var/log/urplugin_logs/
sudo chown odimra:odimra /var/log/urplugin_logs/
odimPassword=`echo -n 'Od!m12$4' |openssl pkeyutl -encrypt -inkey ${ODIM_CONTROLLER_PATH}/scripts/certs/OneNodeDeployment/odimra_rsa.private -pkeyopt rsa_padding_mode:oaep -pkeyopt rsa_oaep_md:sha512|openssl base64 -A`
cd ${ODIM_CONTROLLER_PATH}/helmcharts/urplugin/
sed -i "s#.*groupID.*# groupID: ${ODIMRA_GROUP_ID}#" urplugin-config.yaml
sed -i "s#.*odimPassword.*# odimPassword: ${odimPassword}#" urplugin-config.yaml
sed -i "s#.*urPluginRootServiceUUID.*# urPluginRootServiceUUID: ${rootServiceUUID}#" urplugin-config.yaml
sed -i "s#.*odimUsername.*# odimUsername: admin#" urplugin-config.yaml
mkdir -p ${ODIM_PLUGIN_PATH}/urplugin
helm package ${ODIM_CONTROLLER_PATH}/helmcharts/urplugin/urplugin -d ${ODIM_PLUGIN_PATH}/urplugin
cp urplugin-config.yaml ${ODIM_PLUGIN_PATH}/urplugin
echo "Checking the list of images available after the odimra build..."
docker images
docker save urplugin -o ${ODIM_PLUGIN_PATH}/urplugin/urplugin.tar
cat urplugin-config.yaml
cd ${ODIM_CONTROLLER_PATH}/scripts
odimraKafkaClientCertFQDNSan=odim-controller.odim.com,grfplugin,grfplugin-events,urplugin,api
odimraServerCertFQDNSan=odim-controller.odim.com,grfplugin,grfplugin-events,urplugin,api
ConnectionMethodType=Redfish
ConnectionMethodVariant=Compute:BasicAuth:URP_v2.0.0
sed -i "s#.*odimraKafkaClientCertFQDNSan.*# odimraKafkaClientCertFQDNSan: ${odimraKafkaClientCertFQDNSan}#" kube_deploy_nodes.yaml
sed -i "s#.*odimraKafkaClientCertIPSan.*# odimraKafkaClientCertIPSan: ${odimraServerCertFQDNSan}#" kube_deploy_nodes.yaml
sed -i "s#.*ConnectionMethodType.*# \ \- \ConnectionMethodType: ${ConnectionMethodType}#" kube_deploy_nodes.yaml
sed -i "s#.*ConnectionMethodVariant.*# \ \ \ \ConnectionMethodVariant: ${ConnectionMethodVariant}#" kube_deploy_nodes.yaml
cat kube_deploy_nodes.yaml
python3 odim-controller.py --config ${ODIM_CONTROLLER_PATH}/scripts/kube_deploy_nodes.yaml --add plugin --plugin urplugin
python3 odim-controller.py --config ${ODIM_CONTROLLER_PATH}/scripts/kube_deploy_nodes.yaml --upgrade odimra-config
echo
echo "[$(date)] -- INFO -- list pods in odim namespace"
count=0
while [[ $(kubectl get pods -n odim -o wide | grep "Running" | wc -l) -ne 15 ]]; do
if [[ $count -eq 6 ]]; then
break
fi
sleep 10
count=$((count+1))
done
kubectl get pods -n odim -o wide | grep urplugin*
sleep 30s
urplugin=`curl -i -s -k -X GET -H "Authorization:Basic YWRtaW46T2QhbTEyJDQ=" 'https://'$FQDN':30080/redfish/v1/AggregationService/ConnectionMethods/' | awk 'BEGIN{FS=":"; OFS=":"} {print $8}' | cut -d '"' -f 2`
echo $urplugin
urplugin_taskid=`curl -i -s -k -X POST -H "Authorization:Basic YWRtaW46T2QhbTEyJDQ=" -H "Content-Type:application/json" -d '{"HostName":"urplugin:45007", "UserName":"admin", "Password":"Plug!n12$4", "Links":{ "ConnectionMethod": {"@odata.id": "${urplugin}" }}}' 'https://'$FQDN':30080/redfish/v1/AggregationService/AggregationSources/' | grep Location | awk '{print $2}' | cut -d '/' -f2-`
echo $?
echo $urplugin_taskid
task=`curl -i -s -k -X GET -H "Authorization:Basic YWRtaW46T2QhbTEyJDQ=" 'https://'$FQDN':30080/${urplugin_taskid}' | grep -oe 202`
echo $task
while [[ $(task) -eq 202 ]]; do
if [[ $task -eq 201 ]]; then
break
fi
sleep 5
done
echo " ====================== Adding Dell Plugin ==================================="
sudo mkdir -p /var/log/dellplugin_logs/
sudo chown odimra:odimra /var/log/dellplugin_logs
cd ${ODIM_CONTROLLER_PATH}/helmcharts/dellplugin/
lbPort=45005
sed -i "s#.*groupID.*# groupID: ${ODIMRA_GROUP_ID}#" dellplugin-config.yaml
sed -i "s#.*hostname.*# ${host_name}:#" dellplugin-config.yaml
sed -i "s#.*dellPluginRootServiceUUID.*# dellPluginRootServiceUUID: ${rootServiceUUID}#" dellplugin-config.yaml
sed -i "s#.*lbHost.*# lbHost: ${VM_IP}#" dellplugin-config.yaml
sed -i "s#.*lbPort.*# lbPort: ${lbPort}#" dellplugin-config.yaml
mkdir -p ${ODIM_PLUGIN_PATH}/dellplugin
helm package ${ODIM_CONTROLLER_PATH}/helmcharts/dellplugin/dellplugin -d ${ODIM_PLUGIN_PATH}/dellplugin
cp dellplugin-config.yaml ${ODIM_PLUGIN_PATH}/dellplugin
echo "Checking the list of images available after the odimra build..."
docker images
docker save dellplugin -o ${ODIM_PLUGIN_PATH}/dellplugin/dellplugin.tar
cat dellplugin-config.yaml
cd ${ODIM_CONTROLLER_PATH}/scripts
ConnectionMethodType=Redfish
ConnectionMethodVariant_GRF=Compute:BasicAuth:DELL_v2.0.0
python3 odim-controller.py --config ${ODIM_CONTROLLER_PATH}/scripts/kube_deploy_nodes.yaml --add plugin --plugin dellplugin
python3 odim-controller.py --config ${ODIM_CONTROLLER_PATH}/scripts/kube_deploy_nodes.yaml --upgrade odimra-config
echo
echo "[$(date)] -- INFO -- dellplugin pods in odim namespace"
count=0
while [[ $(kubectl get pods -n odim -o wide | grep "Running" | wc -l) -ne 15 ]]; do
if [[ $count -eq 6 ]]; then
break
fi
sleep 10
count=$((count+1))
done
kubectl get pods -n odim -o wide | grep dellplugin*
sleep 30s
dellplugin=`curl -i -s -k -X GET -H "Authorization:Basic YWRtaW46T2QhbTEyJDQ=" 'https://'$FQDN':30080/redfish/v1/AggregationService/ConnectionMethods/' | awk 'BEGIN{FS=":"; OFS=":"} {print $9}' | cut -d '"' -f 2`
echo $dellplugin
dellplugin_taskid=`curl -i -s -k -X POST -H "Authorization:Basic YWRtaW46T2QhbTEyJDQ=" -H "Content-Type:application/json" -d '{"HostName":"dellplugin:45005", "UserName":"admin", "Password":"Plug!n12$4", "Links":{ "ConnectionMethod": {"@odata.id": "${dellplugin}" }}}' 'https://'$FQDN':30080/redfish/v1/AggregationService/AggregationSources/' | grep Location | awk '{print $2}' | cut -d '/' -f2-`
echo $?
echo $dellplugin_taskid
task_dell=`curl -i -s -k -X GET -H "Authorization:Basic YWRtaW46T2QhbTEyJDQ=" 'https://'$FQDN':30080/${dellplugin_taskid}' | grep -oe 202`
echo $task_dell
while [[ $(task_dell) -eq 202 ]]; do
if [[ $task_dell -eq 201 ]]; then
break
fi
sleep 5
done
echo " ====================== Adding GRF Plugin ==================================="
sudo mkdir -p /var/log/grfplugin_logs/
sudo chown odimra:odimra /var/log/grfplugin_logs
cd ${ODIM_CONTROLLER_PATH}/helmcharts/grfplugin/
sed -i "s#.*groupID.*# groupID: ${ODIMRA_GROUP_ID}#" grfplugin-config.yaml
sed -i "s#.*rootServiceUUID.*# rootServiceUUID: ${rootServiceUUID}#" grfplugin-config.yaml
sed -i "s#.*haDeploymentEnabled.*# haDeploymentEnabled: true#" grfplugin-config.yaml
sed -i "s#.*lbHost.*# lbHost: ${VM_IP}#" grfplugin-config.yaml
sed -i "s#.*lbPort.*# lbPort: 45001#" grfplugin-config.yaml
mkdir -p ${ODIM_PLUGIN_PATH}/grfplugin
helm package ${ODIM_CONTROLLER_PATH}/helmcharts/grfplugin/grfplugin -d ${ODIM_PLUGIN_PATH}/grfplugin
cp grfplugin-config.yaml ${ODIM_PLUGIN_PATH}/grfplugin
echo "Checking the list of images available after the odimra build..."
docker images
docker save grfplugin -o ${ODIM_PLUGIN_PATH}/grfplugin/grfplugin.tar
cat grfplugin-config.yaml
cd ${ODIM_CONTROLLER_PATH}/scripts
ConnectionMethodType=Redfish
ConnectionMethodVariant_GRF=Compute:BasicAuth:GRF_v2.0.0
sed -i "s#.*ConnectionMethodType.*# \ \- \ConnectionMethodType: ${ConnectionMethodType}#" kube_deploy_nodes.yaml
sed -i "s#.*ConnectionMethodVariant.*# \ \ \ \ConnectionMethodVariant: ${ConnectionMethodVariant_GRF}#" kube_deploy_nodes.yaml
python3 odim-controller.py --config ${ODIM_CONTROLLER_PATH}/scripts/kube_deploy_nodes.yaml --add plugin --plugin grfplugin
python3 odim-controller.py --config ${ODIM_CONTROLLER_PATH}/scripts/kube_deploy_nodes.yaml --upgrade odimra-config
echo
echo "[$(date)] -- INFO -- grfplugin pods in odim namespace"
count=0
while [[ $(kubectl get pods -n odim -o wide | grep "Running" | wc -l) -ne 15 ]]; do
if [[ $count -eq 6 ]]; then
break
fi
sleep 10
count=$((count+1))
done
kubectl get pods -n odim -o wide | grep grfplugin*
grfplugin=`curl -i -s -k -X GET -H "Authorization:Basic YWRtaW46T2QhbTEyJDQ=" 'https://'$FQDN':30080/redfish/v1/AggregationService/ConnectionMethods/' | awk 'BEGIN{FS=":"; OFS=":"} {print $10}' | cut -d '"' -f 2`
echo $grfplugin
grfplugin_taskid=`curl -i -s -k -X POST -H "Authorization:Basic YWRtaW46T2QhbTEyJDQ=" -H "Content-Type:application/json" -d '{"HostName":"grfplugin:45001", "UserName":"admin", "Password":"GRFPlug!n12$4", "Links":{ "ConnectionMethod": {"@odata.id": "${grfplugin}" }}}' 'https://'$FQDN':30080/redfish/v1/AggregationService/AggregationSources/' | grep Location | awk '{print $2}' | cut -d '/' -f2-`
echo $?
echo $grfplugin_taskid
task_grf=`curl -i -s -k -X GET -H "Authorization:Basic YWRtaW46T2QhbTEyJDQ=" 'https://'$FQDN':30080/${grfplugin_taskid}' | grep -oe 202`
echo $task_grf
while [[ $(task_grf) -eq 202 ]]; do
if [[ $task_grf -eq 201 ]]; then
break
fi
sleep 5
done
sleep 50s
curl -i -s -k -X GET -H "Authorization:Basic YWRtaW46T2QhbTEyJDQ=" 'https://'$FQDN':30080/redfish/v1/AggregationService/ConnectionMethods/'
echo "====================Sanity test==========================="
- name: Test
run: |
flag=0
echo "Create Session using the URI /redfish/v1/Sessionservice/Sessions"
sudo kubectl get pods -n odim
sudo kubectl describe pod `sudo kubectl get pods -n odim|grep account|awk '{print $1}'` -n odim
echo ls -l /var/log/odimra/
ls -l /var/log/odimra/
cat /etc/hosts
echo "==========================================================="
export FQDN="odim.controller.com"
run=$(curl -i -s -k -X POST -H "Authorization:Basic YWRtaW46T2QhbTEyJDQ=" -H "Content-Type:application/json" -d '{"UserName": "admin","Password": "Od!m12$4"}' 'https://'$FQDN':30080/redfish/v1/SessionService/Sessions' | head -1 | awk '{print $2}')
echo $run
if [[ $run -eq 201 ]];
then
echo "Session Created Sucessfully"
echo "---------------------------"
else
echo "Session Creation Failed with status code $run"
echo "---------------------------------------------"
flag=1
fi
echo "========================= Session Checked=================================="
echo "POST Admin creating account - (args - username, password, roleID)"
run2=$(curl -i -s -k -X POST -H "Authorization:Basic YWRtaW46T2QhbTEyJDQ=" -H "Content-Type:application/json" -d '{"UserName":"SanityUser","Password":"San!ty123$45","RoleId":"Administrator"}' 'https://'$FQDN':30080/redfish/v1/AccountService/Accounts' | head -1 | awk '{print $2}')
if [[ $run2 -eq 201 ]];
then
echo "Account Created Sucessfully"
echo "---------------------------"
else
echo "Account Creation Failed with status code $run2"
echo "----------------------------------------------"
flag=1
fi
echo "========================Account Checked==================================="
if [ $flag -eq 1 ];
then
echo "Sanity Tests Failed"
#exit 1
else
echo "ALL Sanity Tests Passed Sucessfully"
fi
- name: Prepare Build Artifacts
run: |
set +e
sudo mkdir /artifacts
sudo chmod 777 /artifacts
output=$(kubectl get pods -n odim | grep -v NAME | awk '{print $1}')
if [[ $? -ne 0 ]]; then
echo "[$(date)] -- ERROR -- failed to get list pods in odim namespace"
echo "${output}"
fi
pods_list=(${output})
for pod in "${pods_list[@]}"; do
echo "[$(date)] -- INFO -- Collecting logs of ${pod} pod"
output=$(kubectl -n odim get pods ${pod} -o jsonpath='{.spec.containers[*].name}')
if [[ $? -ne 0 ]]; then
echo "[$(date)] -- ERROR -- failed to get the list containers in $(pod) pod"
echo "${output}"
fi
containers_list=(${output})
for container in "${containers_list[@]}"; do
echo "[$(date)] -- INFO -- Collecting logs of ${container} container in ${pod} pod"
kubectl logs -n odim ${pod} -c ${container} > /artifacts/${pod}-${container}.log
if [[ $? -ne 0 ]]; then
echo "[$(date)] -- ERROR - failed to collect log of ${container} container in ${pod} pod"
fi
done
done
#sudo cp /var/log/grfplugin_logs/grfplugin.log /artifacts/grfplugin.log
#sudo cp /var/log/dellplugin_logs/dellplugin.log /artifacts/dellplugin.log
#sudo cp /var/log/odimra/* /artifacts/
- name: Upload Build Artifact
uses: actions/upload-artifact@v2
if: always()
with:
name: my-artifact
path: /artifacts