ACI で APIC / スイッチを初期化するコマンドのまとめ
以前に Cisco ACI で「APIC」「Spine/Leaf」を初期化する というメモを書きました。 Cisco Community に APIC・スイッチの初期化 という記事がありますが、改めて初期化コマンドをまとめておきます。
コマンドのまとめ
APIC
APIC の初期化は 3 つのコマンドを連続して実行します。
コマンド |
説明 |
acidiag touch clean |
次回、再起動時に「ポリシーデータを削除する」フラグを立てる |
acidiag touch setup |
次回、再起動時に「ネットワーク構成データとポリシーデータを削除する」フラグを立てる |
acidiag reboot |
APIC を再起動する |
スイッチ
スイッチの初期化には 3 つの方法があり、場合に応じていずれか 1 つを実施します。
コマンド |
説明 |
acidiag touch clean |
再起動後、APIC から設定ファイルを再ダウンロードする初期化後、同一ファブリックに再参加させる場合はこのコマンドを実行する |
setup-clean-config.sh |
設定ファイルとハードウェアの状態を削除する初期化後、異なるファブリックに参加させる場合はこのコマンドを実行する |
prepare-mfg.sh |
工場出荷状態時に戻す |
APIC の初期化
APIC の初期化では acidiag touch clean
と acidiag touch setup
というコマンドを使います。 これらは「実行時に初期化している」わけでは無く、「次の再起動時に初期化を行う為のフラグを立てている」という処理をしています。 その為、これらのコマンドの実行自体はすぐに完了します。
実際の実行例は以下の通りです。 コマンド実行時は y/N
を確認されますので、一度に全てのコマンドを流し込まないように注意します。
| APIC# acidiag touch clean
This command will wipe out this device, Proceed? [y/N] y
APIC# acidiag touch setup
This command will reset the device configuration, Proceed? [y/N] y
APIC# acidiag reboot
This command will restart this device, Proceed? [y/N] y
|
スイッチの初期化
スイッチを初期化する方法は 3 種類、存在します。 目的・状況に応じて使い分けます。 よく分からない場合、通常は setup-clean-config.sh
を利用しておけば多くの場合、問題にならないと思います。
いずれのコマンドも実行後は reload
で筐体を再起動させる必要があります。
方法1:acidiag touch clean
「初期化したスイッチを再度、同じファブリックに参加させる為、APIC から設定を再ダウンロードさせたい」場合は acidiag touch clean
を利用します。
| Switch# acidiag touch clean
This command will wipe out this device, Proceed? [y/N] y
Switch# reload
This command will reload the chassis, Proceed (y/n)? [n]: y
|
方法2:setup-clean-config.sh
「初期化したスイッチを異なるファブリックに参加させる」場合は setup-clean-config.sh
を利用します。 ACIでのリーフ/スパイン交換の設定 では以下のように説明されています。
これにより、新しいスイッチが以前に別のACIファブリックを使用して設定されていた場合でも、新しいスイッチにすでに存在する一部の設定が現在のファブリックと競合することが原因で発生する問題が回避されます。
1
2
3
4
5
6
7
8
9
10
11
12
13 | Switch# setup-clean-config.sh
In progress
(snip)
In progress
Done
Switch# reload
This command will reload the chassis, Proceed (y/n)? [n]: y
|
方法3:prepare-mfg.sh
出番は少ないと思いますが「スイッチを工場出荷時に戻す」場合は prepare-mfg.sh
を利用します。 このスクリプトを実行するには OS イメージのバイナリ名を指定する必要があります。 スイッチから確認するには dir /bootflash/*.bin
などを実行します。
| Switch# dir /bootflash/*.bin
/bootflash/aci-n9000-dk9.16.0.4c.bin
|
例えば aci-n9000-dk9.16.0.4c.bin
という OS で工場出荷された状態に戻すには以下のように実行します。
1
2
3
4
5
6
7
8
9
10
11
12
13 | Switch# prepare-mfg.sh aci-n9000-dk9.16.0.4c.bin
In progress
(snip)
In progress
Done
Switch# reload
This command will reload the chassis, Proceed (y/n)? [n]: y
|
参考
参考リンク
Leaf
/bin/setup-clean-config.sh
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 | #!/bin/bash
# Copyright (c) 2001,2002,2003,2004,2005, 2017, 2022 by cisco Systems, Inc.
. /etc/isim_include
if [ $# -gt 0 ]; then
if [ "$1" != "--keep-port-profile" -a "$1" != "-k" ]; then
echo "Usage: setup-clean-config.sh [--keep-port-profile|-k]"
exit 1
fi
fi
usr=`id -un `
if [ $usr == "root" ]; then
if [ "$1" = "" ]; then
if [ -e "/bootflash/user_config_port_profile.json" ]
then
chattr -i /bootflash/user_config_port_profile.json
fi
rm -rf /bootflash/user_config_port_profile.json
rm -f /bootflash/.user_config_port_profile.json
rm -f /bootflash/stats_pref.txt
rm -f /bootflash/.stats_pref.txt
rm -f /mnt/ifc/cfg/fwd_scale_prof.txt
rm -f /mnt/pss/lcm_port_type.config
rm -f /mnt/pss/mac_pool_dry_*.pss
rm -f /mnt/ifc/cfg/lbx_pp_share_mode.cfg
rm -f /mnt/ifc/cfg/fast_link_failover_mode.txt
rm -f /mnt/ifc/cfg/fast_link_failover_mode_latest.txt
rm -f $PREV_BOOT_IMAGE_SIGNATURE_FILE
rm -f /bootflash/high_power_optics_macsec.cfg
fi
touch /mnt/pss/.clean
sync
sleep 10
sync
date >> /bootflash/clean-config-log
if [ "$1" == "--keep-port-profile" -o "$1" == "-k" ]; then
if [ "$1" == "--keep-port-profile" ]; then
echo "setup-clean-config.sh --keep-port-profile is executed" >> /bootflash/clean-config-log
elif [ "$1" == "-k" ]; then
echo "setup-clean-config.sh -k is executed" >> /bootflash/clean-config-log
fi
else
echo "setup-clean-config.sh is executed" >> /bootflash/clean-config-log
fi
PARENT_COMMAND=$(ps -o args= $PPID)
echo "Caller process of setup-clean-config.sh: $PARENT_COMMAND" >> /bootflash/clean-config-log
echo >> /bootflash/clean-config-log
if [ -f /bootflash/clean-config-log ]; then
chmod 777 /bootflash/clean-config-log
fi
else
PARENT_COMMAND=$(ps -o args= $PPID)
bg_action /tmp/setup-clean-config $1
#date >> /bootflash/clean-config-log
#echo "Caller process of setup-clean-config.sh: $PARENT_COMMAND" >> /bootflash/clean-config-log
#echo >> /bootflash/clean-config-log
fi
|
/etc/isim_include
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
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594 | #! /bin/sh
####################################################################
#
# File: isim_include
#
# Copyright (c) 1985-2004, 2022-2023 by Cisco Systems, Inc.
# All rights reserved.
#
#####################################################################
. /etc/ins_card_index
ISIM_FILE=/bootflash/isim.conf
CARD_INDEX_TOR=$CARD_INDEX_NAGANO
SSD_PART1_ENFORCE_FILE="/bootflash/ssd_partition1"
TOR_CARD="TOR"
#fast_boot
PREV_BOOT_IMAGE_SIGNATURE_FILE="/mnt/pss/prev_boot_img_hdr"
PREV_SYSTEM_IMAGE_UNCOMPRESS_LOGFILE="/mnt/pss/prev_autos_uncompress.log"
FAST_BOOT_LOG_FILE="/tmp/fast_boot.log"
PREV_CORE_PLUGIN_EXTRACTION_LOG_FILE="/mnt/ifc/cfg/isan/plugin_extract_log/0"
PREV_ETH_PLUGIN_EXTRACTION_LOG_FILE="/mnt/ifc/cfg/isan/plugin_extract_log/1"
PREV_CORE_PLUGIN_SRG_FILE="/mnt/pss/.plugin_core_imgsrg.sro"
PREV_ETH_PLUGIN_SRG_FILE="/mnt/pss/.plugin_eth_imgsrg.sro"
PREV_UNKNOWN_PLUGIN_SRG_FILE="/mnt/pss/.plugin_unknown.sro"
SYSSRVC_CCTRL_RELOAD_MOD_STUB=0x59C
SYSSRV_CCTRL_GET_STATS_STUB=0x58F
SYSSRVC_CCTRL_SWITCH_RESET_STUB=0x58D
export ISANLOG_FILE=/var/log/isan.log
export log_it="/isanboot/bin/blogger -l$ISANLOG_FILE -- "
SYSMGR_LOG_FILE="/mnt/pss/bootlogs/current/sysmgr.log"
sysmgr_log() {
echo `date`: $1 >> $SYSMGR_LOG_FILE
}
bg_action() {
touch $1
echo ${@:2} > $1
while true
do
echo "In progress"
if [ -f $1 ]; then
sleep 5;
else
break
fi
done
echo "Done"
}
ins_clear_config() {
echo "Wipe out config as requested by earlier run"
/bin/rm -rf /mnt/ifc/cfg/db/*
/bin/rm -rf /logflash/log/*
# /bin/rm -rf /mnt/ifc/log/*
#do not delete last_run, lc_log dir created by S26check-flash-insime
#double checking for dir existance
if [ ! -d /mnt/ifc/log/last_run ]; then
mkdir -p /mnt/ifc/log/last_run
chmod 755 /mnt/ifc/log/last_run
echo "still missing last_run directory. created again..." >> /tmp/presysmgr.log
fi
for r in $(find /mnt/ifc/log -maxdepth 10 -type f);do rm -f $r;done
echo "Deleted all files in /mnt/ifc/log and sub-dir..." >> /tmp/presysmgr.log
used=`df -h /mnt/pss/logs | awk 'NR!=1 {print $5}' | cut -d'%' -f 1`
if [ $used -gt 70 ]; then
files=`ls -tr /mnt/pss/logs`
for file in $files;
do
/bin/rm -rf /mnt/pss/logs/$file
used=`df -h /mnt/pss/logs | awk 'NR!=1 {print $5}' | cut -d'%' -f 1`
if [ $used -lt 70 ]; then
break
fi
done
fi
/bin/rm -rf /mnt/ifc/cfg/avdb
if [ -f /mnt/pss/.debugMaintenanceMode ]; then
echo "Maintenance Mode - Debug - reload"
elif [ -f /mnt/pss/cleanup_flag ]; then
cp -pf /mnt/ifc/cfg/.apicConnectivity.xml /dev/shm/
/bin/rm -f /mnt/ifc/cfg/.apic*
cp -pf /dev/shm/.apicConnectivity.xml /mnt/ifc/cfg/
else
/bin/rm -f /mnt/ifc/cfg/.apic*
fi
# /bin/rm -f /mnt/ifc/cfg/fwd_scale_prof.txt
}
ins_clear_config_nxos_to_aci_conv() {
echo "NXOS to ACI conversion: deleting /mnt/ifc/cfg/db/*" | tee -a /mnt/pss/nxos_to_aci_conv.log
/bin/rm -rf /mnt/ifc/cfg/db/*
echo "NXOS to ACI conversion: deleting /mnt/ifc/cfg/avdb/*" | tee -a /mnt/pss/nxos_to_aci_conv.log
/bin/rm -rf /mnt/ifc/cfg/avdb/*
echo "NXOS to ACI conversion: deleting /mnt/ifc/log/*" | tee -a /mnt/pss/nxos_to_aci_conv.log
/bin/rm -rf /mnt/ifc/log/*
echo "NXOS to ACI conversion: deleting /logflash/log/*" | tee -a /mnt/pss/nxos_to_aci_conv.log
/bin/rm -rf /logflash/log/*
echo "NXOS to ACI conversion: deleting /logflash/core/*" | tee -a /mnt/pss/nxos_to_aci_conv.log
/bin/rm -rf /logflash/core/*
echo "NXOS to ACI conversion: deleting /mnt/pss/*" | tee -a /mnt/pss/nxos_to_aci_conv.log
/bin/mv /mnt/pss/nxos_to_aci_conv.log /tmp/nxos_to_aci_conv.log
/bin/rm -rf /mnt/pss/*
/bin/mv /tmp/nxos_to_aci_conv.log /mnt/pss/nxos_to_aci_conv.log
echo "NXOS to ACI conversion: deleting /bootflash/*.log *.LOG *.txt *.json *.gz" | tee -a /mnt/pss/nxos_to_aci_conv.log
/bin/rm -rf /bootflash/*.log
/bin/rm -rf /bootflash/*.Log
/bin/rm -rf /bootflash/*.txt
/bin/rm -rf /bootflash/*.json
/bin/rm -rf /bootflash/*.gz
echo "NXOS to ACI conversion: purging NVRAM data" | tee -a /mnt/pss/nxos_to_aci_conv.log
/isanboot/bin/pfm_nvram_purge
echo "NXOS to ACI conversion: deleting /mnt/cfg/0/* files" | tee -a /mnt/pss/nxos_to_aci_conv.log
mv /mnt/cfg/0/boot/grub/menu.lst.local /tmp/menu.lst.local
/bin/rm -rf /mnt/cfg/0/*
mkdir -p /mnt/cfg/0/boot/grub
mv /tmp/menu.lst.local /mnt/cfg/0/boot/grub/menu.lst.local
echo "NXOS to ACI conversion: deleting /mnt/cfg/1/* files" | tee -a /mnt/pss/nxos_to_aci_conv.log
mv /mnt/cfg/1/boot/grub/menu.lst.local /tmp/menu.lst.local
/bin/rm -rf /mnt/cfg/1/*
mkdir -p /mnt/cfg/1/boot/grub
mv /tmp/menu.lst.local /mnt/cfg/1/boot/grub/menu.lst.local
}
get_sanos_debug_from_cmdline() {
sanos_debug=0
for arg in $(cat /proc/cmdline); do
echo $arg | grep -q sanos_debug;
if [ $? == 0 ]; then
echo "Found $arg"
sanos_debug=`echo $arg | sed s/=/" "/ | awk '{print $2}'`
fi
done
}
get_kickstart_bash_from_cmdline() {
kickstart_bash=0
for arg in $(cat /proc/cmdline); do
echo $arg | grep -q kickstart_bash;
if [ $? == 0 ]; then
echo "Found $arg"
kickstart_bash=`echo $arg | sed s/=/" "/ | awk '{print $2}'`
fi
done
}
get_server_ip_from_cmdline() {
my_card_index=$(cat /sys/kernel/cisco_board_info/card_index)
if [ $my_card_index -eq $CARD_INDEX_MOFF_GIDEON ]; then
ACTIVE_SUP_MOD_NUM=$(cat /sys/module/klm_cctrli/parameters/cctrl_cur_active_sup)
ACTIVE_SUP_MOD_NUM=$((ACTIVE_SUP_MOD_NUM+26))
server_ip="127.1.1.${ACTIVE_SUP_MOD_NUM}"
else
for arg in $(cat /proc/cmdline); do
echo $arg | grep -q server_ip;
if [ $? == 0 ]; then
echo "Found $arg"
server_ip=`echo $arg | sed s/=/" "/ | awk '{print $2}'`
fi
done
fi
}
get_loader_ver_from_cmdline() {
loader_ver=0
for arg in $(cat /proc/cmdline); do
echo $arg | grep -q loader_ver;
if [ $? == 0 ]; then
loader_ver=`echo $arg | sed s/=/" "/ | awk '{print $2}'`
loader_ver=`echo $loader_ver | sed s/\"//g`
fi
done
}
isan_debug_isim() {
echo $1
if [ $sanos_debug -ge 2 ]; then
$log_it echo $1
fi
}
isan_error_isim() {
/isanboot/bin/blogger -V -l$ISANLOG_FILE -- echo $1
}
get_hw_changes_bits() {
HW_CHANGES_BITS=65535
if [[ -e /sys/kernel/cisco_board_info/hw_change_bits ]] ; then
HW_CHANGES_BITS=$(cat /sys/kernel/cisco_board_info/hw_change_bits)
fi
}
is_tor_ch() {
# check for valetine FPGA
pcino=$(/usr/bin/lspci -v | grep -i cisco | grep "177" | awk '{print $1}')
if [ ! -n "$pcino" ]; then
return 0
fi
addr=$(echo $pcino | xargs /usr/bin/lspci -v -s | grep "Memory at" | sed -n 2p | awk '{print $3}')
addr='0x'$addr
addr=`printf "0x%X\n" $((addr + 0x10bc))`
fpga_id1=`/usr/sbin/iorw r $addr w | awk '{print $2}'`
fpga_id1='0x'$fpga_id1
# check for churchill FPGA
pcino=$(/usr/bin/lspci -v | grep -i cisco | grep "17a" | awk '{print $1}')
if [ ! -n "$pcino" ]; then
return 0
fi
addr=$( echo $pcino | xargs /usr/bin/lspci -v -s | grep "Memory at" | awk '{print $3}')
addr='0x'$addr
addr=`printf "0x%X\n" $((addr + 0x10bc))`
fpga_id2=`/usr/sbin/iorw r $addr w | awk '{print $2}'`
fpga_id2='0x'$fpga_id2
if [[ $fpga_id1 == '0x10900177' ]] && [[ $fpga_id2 == '0x1070017a' ]]; then
return 1
fi
return 0
}
is_sup_the_child() {
# check for valetine FPGA
pcino=$(/usr/bin/lspci -v | grep -i cisco | grep "177" | awk '{print $1}')
if [ ! -n "$pcino" ]; then
return 0
fi
addr=$(echo $pcino | xargs /usr/bin/lspci -v -s | grep "Memory at" | sed -n 2p | awk '{print $3}')
addr='0x'$addr
addr=`printf "0x%X\n" $((addr + 0x10bc))`
fpga_id1=`/usr/sbin/iorw r $addr w | awk '{print $2}'`
fpga_id1='0x'$fpga_id1
# check for the_child FPGA
pcino=$(/usr/bin/lspci -v | grep -i cisco | grep "17e" | awk '{print $1}')
if [ ! -n "$pcino" ]; then
return 0
fi
addr=$( echo $pcino | xargs /usr/bin/lspci -v -s | grep "Memory at" | sed -n 1p | awk '{print $3}')
addr='0x'$addr
addr=`printf "0x%X\n" $((addr + 0x10bc))`
fpga_id2=`/usr/sbin/iorw r $addr w | awk '{print $2}'`
fpga_id2='0x'$fpga_id2
if [[ $fpga_id1 == '0x22000177' ]] && [[ $fpga_id2 == '0x2210017e' ]]; then
return 1
fi
return 0
}
get_card_index_from_cmdline() {
card_index=65535
is_tor_ch
ch_sts=$?
is_sup_the_child
child_sts=$?
if [[ -e /sys/kernel/cisco_board_info/card_index ]] ; then
card_index=$(cat /sys/kernel/cisco_board_info/card_index)
elif [ $ch_sts -eq 1 ]; then
card_index=$CARD_INDEX_CHURCHILL
echo "assigning card_index to $CARD_INDEX_CHURCHILL"
elif [ $child_sts -eq 1 ]; then
card_index=$CARD_INDEX_THE_CHILD_RP_1
echo "assigning card_index to $CARD_INDEX_THE_CHILD_RP_1"
else
for arg in $(cat /proc/cmdline); do
echo $arg | grep -q card_index;
if [ $? == 0 ]; then
echo "Found $arg"
card_index=`echo $arg | sed s/=/" "/ | awk '{print $2}'`
# this is a hack remove it
if [ $card_index -eq 21008 ]; then
card_index=$CARD_INDEX_CORTINA1
sed -i '/ISIM_CARD_INDEX/d' $ISIM_FILE
echo "ISIM_CARD_INDEX=21500" >> $ISIM_FILE
sync
fi
fi
done
fi
}
# For TORs that support dual-mode (can be either leaf or spine),
# the mode config file must exist; otherwise, defaulted to spine.
get_crdcfg_tor_card_mode()
{
local retval=0
# card_mode available only after FS mounted
if [[ ! -d "/mnt/ifc/cfg" ]]
then
echo " /mnt/ifc/cfg not exist " >> /tmp/presysmgr.log
retval=1
return $retval
fi
card_mode_file=/bootflash/crdcfg_card_mode.cfg
if [[ ! -f $card_mode_file ]]
then
echo -n "File $card_mode_file not found, " >> /tmp/presysmgr.log
echo "creating default mode for card_index $card_index" >> /tmp/presysmgr.log
if [ $card_index -eq $CARD_INDEX_SCULPIN ]; then
echo 0 > $card_mode_file
elif [ $card_index -eq $CARD_INDEX_MARIPOSA ]; then
echo 1 > $card_mode_file
elif [ $card_index -eq $CARD_INDEX_RED_HORSE ]; then
echo 1 > $card_mode_file
elif [ $card_index -eq $CARD_INDEX_DUVEL ]; then
echo 0 > $card_mode_file
elif [ $card_index -eq $CARD_INDEX_COASTAL_FOG ]; then
echo 1 > $card_mode_file
elif [ $card_index -eq $CARD_INDEX_PETRUS ]; then
echo 0 > $card_mode_file
elif [ $card_index -eq $CARD_INDEX_EDELWEISS ]; then
echo 0 > $card_mode_file
else
echo 1 > $card_mode_file
fi
fi
chattr -i $card_mode_file
current_card_mode=$(cat $card_mode_file)
if [[ "$current_card_mode" == "0" ]]; then
retval=0
elif [[ "$current_card_mode" == "1" ]]; then
retval=1
else
# Should not be here...something went wrong, the cfg file
# has invalid card mode value, recover it to spine mode
echo -n "Invalid card_mode $current_card_mode " >> /tmp/presysmgr.log
echo -n "found in file $card_mode_file, " >> /tmp/presysmgr.log
echo "default mode for card_index $card_index" >> /tmp/presysmgr.log
if [ $card_index -eq $CARD_INDEX_SCULPIN ]; then
echo 0 > $card_mode_file
retval=0
elif [ $card_index -eq $CARD_INDEX_MARIPOSA ]; then
echo 1 > $card_mode_file
retval=1
elif [ $card_index -eq $CARD_INDEX_RED_HORSE ]; then
echo 1 > $card_mode_file
retval=1
elif [ $card_index -eq $CARD_INDEX_DUVEL ]; then
echo 0 > $card_mode_file
retval=0
elif [ $card_index -eq $CARD_INDEX_COASTAL_FOG ]; then
echo 1 > $card_mode_file
retval=1
elif [ $card_index -eq $CARD_INDEX_PETRUS ]; then
echo 0 > $card_mode_file
retval=0
elif [ $card_index -eq $CARD_INDEX_EDELWEISS ]; then
echo 0 > $card_mode_file
retval=0
else
echo 1 > $card_mode_file
retval=1
fi
current_card_mode=$(cat $card_mode_file)
fi
chattr +i $card_mode_file
return $retval
}
COORS_FPGA_ID="0x1323826"
COORSPLUS_FPGA_ID="0x1497692"
MILLER_FPGA_ID="0x1263589"
get_mpa_id_from_cmdline() {
mpa_id=0
for arg in $(cat /proc/cmdline); do
echo $arg | grep -q mpa_index;
if [ $? == 0 ]; then
echo "Found $arg"
mpa_id=`echo $arg | sed s/=/" "/ | awk '{print $2}'`
fi
done
if [ $card_index -ne $CARD_INDEX_OSLO -a $card_index -ne $CARD_INDEX_CALGARY -a $card_index -ne $CARD_INDEX_SAPPORO ]; then
if [ $mpa_id -eq 0 ]; then
# Try reading fpga_id to identify the MPA ID
don_addr=$(/usr/bin/lspci -v -d 1137:102 | grep "Memory"| awk '{print $3}')
don_addr_hex=0x$(echo | awk '{print substr("'"$don_addr"'",0,5)"004"}')
fpga_id=$(iorw r $don_addr_hex w | awk '{print $2}')
fpga_id="0x"$fpga_id
if [ "$fpga_id" == $COORS_FPGA_ID -o "$fpga_id" == $COORSPLUS_FPGA_ID ]; then
#COORS/COORS+
mpa_id=2
elif [ "$fpga_id" == $MILLER_FPGA_ID ]; then
#MILLER
mpa_id=1
fi
fi
fi
}
get_image_name_from_cmdline() {
image_name=0
for arg in $(cat /proc/cmdline); do
echo $arg | grep -q ksimg;
if [ $? == 0 ]; then
echo "Found $arg"
image_name=`echo $arg | sed s/=/" "/ | awk '{print $2}'`
fi
done
}
get_is_recovery_img_from_cmdline() {
recovery_img=0
for arg in $(cat /proc/cmdline); do
echo $arg | grep -q recovery;
if [ $? == 0 ]; then
echo "Found $arg"
recovery_img=`echo $arg | sed s/=/" "/ | awk '{print $2}'`
fi
done
}
get_first_setup_from_cmdline() {
first_setup=0
for arg in $(cat /proc/cmdline); do
echo $arg | grep -q first_setup;
if [ $? == 0 ]; then
echo "Found $arg"
first_setup=`echo $arg | sed s/=/" "/ | awk '{print $2}'`
fi
done
}
get_sflc_debug_from_cmdline() {
sflc_debug=0
for arg in $(cat /proc/cmdline); do
echo $arg | grep -q sflc_debug;
if [ $? == 0 ]; then
echo "Found $arg"
sflc_debug=`echo $arg | sed s/=/" "/ | awk '{print $2}'`
fi
done
}
get_hap_reset_from_cmdline() {
no_hap_reset_persist=0
no_hap_reset=0
for arg in $(cat /proc/cmdline); do
echo $arg | grep -q no_hap_reset_persist;
if [ $? == 0 ]; then
echo "Found $arg"
no_hap_reset_persist=1
no_hap_reset=1
else
echo $arg | grep -q no_hap_reset;
if [ $? == 0 ]; then
echo "Found $arg"
no_hap_reset=1
fi
fi
done
}
mark_image_location() {
# Remove existing markings
rm -rf /mnt/cfg/0/recovery
rm -rf /mnt/cfg/1/recovery
rm -rf /mnt/cfg/0/main
rm -rf /mnt/cfg/1/main
# Mark it accordingly
get_is_recovery_img_from_cmdline
if [ $recovery_img -eq 1 ]; then
echo "Recovery image"
touch /mnt/cfg/0/recovery
touch /mnt/cfg/1/recovery
echo "Wipe out config"
rm -rf /mnt/ifc/cfg/db/*
else
echo "Main image"
touch /mnt/cfg/0/main
touch /mnt/cfg/1/main
fi
if [ -f /mnt/cfg/0/clean-config -o -f /mnt/cfg/1/clean-config ]; then
/bin/rm -rf /mnt/cfg/0/clean-config
/bin/rm -rf /mnt/cfg/1/clean-config
ins_clear_config
fi
if [ -f /mnt/pss/.clean ]; then
ins_clear_config
else
/bin/rm -f /mnt/pss/.debugMaintenanceMode
fi
}
create_conf_file() {
echo "Will generate isim.conf file for ToR simulation"
echo "ISIM_CHASSIS_MODEL=""TOR" > $ISIM_FILE
echo "ISIM_SLOT_ID=0" >> $ISIM_FILE
echo "ISIM_CARD_INDEX=$CARD_INDEX_TOR" >> $ISIM_FILE
echo "ISIM_CARD_TYPE=TOR" >> $ISIM_FILE
echo "ISIM_BASE_MAC=00:BA:5E:0D:00:00" >> $ISIM_FILE
}
get_chassis_model_from_conf_file() {
if [ -f $ISIM_FILE ]; then
chassis_model=`grep ISIM_CHASSIS_MODEL $ISIM_FILE | sed s/=/\ / | awk '{print $2}' `
fi
}
get_nxos_pe_from_conf_file() {
if [ -f $ISIM_FILE ]; then
nxos_pe=`grep ISIM_INXOS_PE $ISIM_FILE | sed s/=/\ / | awk '{print $2}' `
fi
}
get_slot_id_from_conf_file() {
if [ -f $ISIM_FILE ]; then
slot_id=`grep ISIM_SLOT_ID $ISIM_FILE | sed s/=/\ / | awk '{print $2}' `
fi
}
get_card_index_from_conf_file() {
if [ -f $ISIM_FILE ]; then
card_index=`grep ISIM_CARD_INDEX $ISIM_FILE | sed s/=/\ / | awk '{print $2}' `
fi
# this is a hack remove it
if [ $card_index -eq 21008 ]; then
card_index=$CARD_INDEX_CORTINA1
sed -i '/ISIM_CARD_INDEX/d' $ISIM_FILE
echo "ISIM_CARD_INDEX=21500" >> $ISIM_FILE
sync
fi
}
get_card_type_from_conf_file() {
if [ -f $ISIM_FILE ]; then
card_type=`grep ISIM_CARD_TYPE $ISIM_FILE | sed s/=/\ / | awk '{print $2}' `
fi
}
get_base_mac_from_conf_file() {
if [ -f $ISIM_FILE ]; then
base_mac=`grep ISIM_BASE_MAC $ISIM_FILE | sed s/=/\ / | awk '{print $2}' `
fi
}
get_mpa_id_from_conf_file() {
if [ -f $ISIM_FILE ]; then
mpa_id=`grep ISIM_MPA_ID $ISIM_FILE | sed s/=/\ / | awk '{print $2}' `
fi
}
get_isim_ctrl_intf_from_conf_file() {
if [ -f $ISIM_FILE ]; then
isim_ctrl_intf=`grep ISIM_CTRL_INTERFACE $ISIM_FILE | sed s/=/\ / | awk '{print $2}' `
fi
}
get_isim_infra_vlan_from_conf_file() {
if [ -f $ISIM_FILE ]; then
isim_infra_vlan=`grep ISIM_INFRA_VLAN $ISIM_FILE | sed s/=/\ / | awk '{print $2}' `
fi
}
get_isim_global_accel_mode_from_conf_file() {
if [ -f $ISIM_FILE ]; then
isim_gl_accel_mode=`grep ISIM_ACCEL_MODE $ISIM_FILE | sed s/=/\ / | awk '{print $2}' `
fi
}
publish_sim_pd_procfs() {
#Empty old content
echo -n "" > /proc/sim_pd
while read line
do
echo $line >> /proc/sim_pd
done </tmp/scale_phy_cfg_misc.out
}
get_env_platform() {
sim=0
IS_HW=1
#KIRKWOOD_SUP=0
TOR=0
TOR_LP=0
CORTINA1=0
CORTINA1_SDK=0
TOR_NG=0
TOR_OL=0
TOR_CY=0
TOR_SP=0
TOR_SQ=0
mpa_id=0
nxos_pe="na"
IS_TOR=0
IS_LEAF=0
SUPERVISOR=0
IS_SUP2=0
IS_ML=0
IS_LEM_CARD=0
TOR_GNBL=0
TOR_SLCITY=0
TOR_SEOUL=0
TOR_SEOUL2=0
TOR_TURIN=0
TOR_DEERVALLEY=0
IS_ATOM=0
IS_TACOMA=0
TOR_SUMPIN=0
TOR_DOPPLEBOCK=0
TOR_SHUGGA=0
TOR_FOSTERS=0
TOR_PIPEWORKS=0
TOR_PIPEDREAM=0
TOR_GRACELAND=0
SUP_ZION=0
TOR_SCRIMSHAW=0
TOR_SOUTHLAKE=0
TOR_MAIBOCK=0
TOR_KRIEK=0
TOR_TRUMER=0
TOR_ELYSIAN=0
TOR_TECATE=0
TOR_SCULPIN=0
TOR_SCULPIN_LEAF=0
TOR_MARIPOSA=0
TOR_MARIPOSA_SPINE=0
TOR_RED_HORSE=0
TOR_RED_HORSE_SPINE=0
TOR_ST_ARCHER=0
TOR_TUCHER=0
IS_FC_MT_BRAVE=0
IS_LC_BRASSWOOD=0
IS_FC_SHELDON=0
TOR_DUVEL=0
TOR_DUVEL_LEAF=0
TOR_COASTAL_FOG=0
TOR_COASTAL_FOG_SPINE=0
TOR_STELLER=0
TOR_PETRUS=0
TOR_PETRUS_LEAF=0
TOR_CHURCHILL=0
SUP_THE_CHILD=0
TOR_EDELWEISS=0
TOR_EDELWEISS_SPINE=0
IS_EDELWEISS=0
TOR_TRAPPIST=0
TOR_TRIPEL=0
IS_LC_BLACKBIRD=0
SR_CAPABLE=0
USE_PART_TYPE_V1=0
IS_SPINE=0
ENABLE_BIN_BASH=0
IS_LEM_CARD=0
IS_THE_CHILD_RP_1=0
IS_LC_MOFF_GIDEON=0
get_card_index_from_cmdline
if [ $card_index -eq 65535 ]; then
IS_HW=0
sim=1
get_card_index_from_conf_file
fi
# if cmdline is not set, look at isim.conf
if [ $nxos_pe == "na" ]; then
get_nxos_pe_from_conf_file
fi
if [ $nxos_pe == "MOCK" ]; then
INXOS_PE_MOCK=1
INXOS_PE_IFC=0
USE_PART_TYPE_V1=1
echo "*** Running INXOS PE MOCK image ***"
else
INXOS_PE_IFC=1
INXOS_PE_MOCK=0
nxos_pe="IFC"
fi
if [ -f /bootflash/platform.inf ]; then
if [ ! -z $(grep "ssd_partition=1" /bootflash/platform.inf 2>/dev/null) ]; then
USE_PART_TYPE_V1=1
fi
fi
if [ -f ${SSD_PART1_ENFORCE_FILE} ]; then
USE_PART_TYPE_V1=1
fi
if [ $card_index -eq $CARD_INDEX_KIRKWOOD ]; then
SUPERVISOR=1
usr_card_type=3
card_name="sup"
elif [ $card_index -eq $CARD_INDEX_KEYSTONE ]; then
SUPERVISOR=1
usr_card_type=3
card_name="sup2"
IS_SUP2=1
elif [ $card_index -eq $CARD_INDEX_ZION_A ]; then
SUPERVISOR=1
usr_card_type=3
card_name="sup2"
IS_SUP2=1
SUP_ZION=1
elif [ $card_index -eq $CARD_INDEX_ZION_B ]; then
SUPERVISOR=1
usr_card_type=3
card_name="sup2"
IS_SUP2=1
SUP_ZION=1
elif [ $card_index -eq $CARD_INDEX_SOCHI ]; then
TOR=1
usr_card_type=5
card_name="tor"
NS_FPORT=49
elif [ $card_index -eq $CARD_INDEX_PLACID ]; then
TOR_LP=1
usr_card_type=6
card_name="tor_lp"
NS_FPORT=49
elif [ $card_index -eq $CARD_INDEX_NAGANO ]; then
TOR_NG=1
usr_card_type=7
card_name="tor_ng"
NS_FPORT=97
elif [ $card_index -eq $CARD_INDEX_CORTINA1 ]; then
sim=0
IS_HW=1
CORTINA1=1
usr_card_type=9
card_name="c1"
elif [ $card_index -eq $CARD_INDEX_OSLO ]; then
TOR_OL=1
usr_card_type=10
card_name="tor_ol"
NS_FPORT=49
elif [ $card_index -eq $CARD_INDEX_CALGARY ]; then
TOR_CY=1
usr_card_type=11
card_name="tor_cy"
NS_FPORT=99
elif [ $card_index -eq $CARD_INDEX_SAPPORO ]; then
TOR_SP=1
usr_card_type=12
card_name="tor_sp"
NS_FPORT=49
elif [ $card_index -eq $CARD_INDEX_ML_BANFF ]; then
IS_ML=1
elif [ $card_index -eq $CARD_INDEX_GRENOBLE ]; then
TOR_GNBL=1
usr_card_type=13
card_name="tor_gnbl"
NS_FPORT=49
elif [ $card_index -eq $CARD_INDEX_SLCITY ]; then
TOR_SLCITY=1
usr_card_type=14
card_name="tor_slcity"
NS_FPORT=49
elif [ $card_index -eq $CARD_INDEX_SEOUL ]; then
TOR_SEOUL=1
usr_card_type=15
card_name="tor_seoul"
NS_FPORT=49
elif [ $card_index -eq $CARD_INDEX_SEOUL2 ]; then
TOR_SEOUL2=1
usr_card_type=25
card_name="tor_seoul2"
NS_FPORT=49
elif [ $card_index -eq $CARD_INDEX_TURIN ]; then
TOR_TURIN=1
usr_card_type=24
card_name="tor_turin"
NS_FPORT=49
elif [ $card_index -eq $CARD_INDEX_SQUAWVALLEY ]; then
TOR_SQ=1
usr_card_type=16
card_name="tor_sq"
NS_FPORT=97
elif [ $card_index -eq $CARD_INDEX_CANYON ]; then
IS_ATOM=1
usr_card_type=17
elif [ $card_index -eq $CARD_INDEX_MT_KATO ]; then
IS_ATOM=1
usr_card_type=18
elif [ $card_index -eq $CARD_INDEX_COPPER_MTN ]; then
IS_ATOM=1
usr_card_type=19
elif [ $card_index -eq $CARD_INDEX_SHAWNEE ]; then
IS_ATOM=1
usr_card_type=20
elif [ $card_index -eq $CARD_INDEX_CASCADES ]; then
IS_ATOM=1
usr_card_type=21
elif [ $card_index -eq $CARD_INDEX_TACOMA ]; then
IS_ATOM=1
IS_TACOMA=1
usr_card_type=23
elif [ $card_index -eq $CARD_INDEX_DEERVALLEY ]; then
TOR_DEERVALLEY=1
usr_card_type=22
card_name="tor_deervalley"
NS_FPORT=49
elif [ $card_index -eq $CARD_INDEX_SUMPIN ]; then
TOR_SUMPIN=1
usr_card_type=26
card_name="tor_sumpin"
NS_FPORT=49
elif [ $card_index -eq $CARD_INDEX_SHUGGA ]; then
TOR_SHUGGA=1
usr_card_type=27
card_name="tor_shugga"
NS_FPORT=49
elif [ $card_index -eq $CARD_INDEX_FOSTERS ]; then
TOR_FOSTERS=1
usr_card_type=28
card_name="tor_fosters"
NS_FPORT=49
elif [ $card_index -eq $CARD_INDEX_BLUEWOOD ]; then
IS_ATOM=1
usr_card_type=30
elif [ $card_index -eq $CARD_INDEX_DOPPLEBOCK ]; then
TOR_DOPPLEBOCK=1
usr_card_type=29
card_name="tor_dopplebock"
CORTINA1_SDK=1
NS_FPORT=66
elif [ $card_index -eq $CARD_INDEX_MT_BAKER ]; then
IS_ATOM=1
usr_card_type=31
elif [ $card_index -eq $CARD_INDEX_PIPEWORKS ]; then
TOR_PIPEWORKS=1
usr_card_type=32
card_name="tor_pipeworks"
NS_FPORT=54
elif [ $card_index -eq $CARD_INDEX_PIPEDREAM ]; then
TOR_PIPEDREAM=1
usr_card_type=33
card_name="tor_pipedream"
NS_FPORT=54
elif [ $card_index -eq $CARD_INDEX_GRACELAND ]; then
TOR_GRACELAND=1
usr_card_type=45
card_name="tor_graceland"
NS_FPORT=10
elif [ $card_index -eq $CARD_INDEX_MT_EVEREST ]; then
IS_ATOM=1
usr_card_type=34
elif [ $card_index -eq $CARD_INDEX_SCRIMSHAW ]; then
TOR_SCRIMSHAW=1
usr_card_type=35
card_name="tor_scrimshaw"
NS_FPORT=36
elif [ $card_index -eq $CARD_INDEX_KRIEK ]; then
TOR_KRIEK=1
usr_card_type=38
card_name="tor_kriek"
NS_FPORT=108
elif [ $card_index -eq $CARD_INDEX_TRUMER ]; then
TOR_TRUMER=1
usr_card_type=39
card_name="tor_trumer"
NS_FPORT=108
elif [ $card_index -eq $CARD_INDEX_SOUTHLAKE ]; then
TOR_SOUTHLAKE=1
usr_card_type=36
card_name="tor_southlake"
NS_FPORT=66
elif [ $card_index -eq $CARD_INDEX_MAIBOCK ]; then
TOR_MAIBOCK=1
usr_card_type=37
card_name="tor_maibock"
CORTINA1_SDK=1
NS_FPORT=34
elif [ $card_index -eq $CARD_INDEX_ELYSIAN ]; then
TOR_ELYSIAN=1
usr_card_type=40
card_name="tor_elysian"
NS_FPORT=54
SR_CAPABLE=1
elif [ $card_index -eq $CARD_INDEX_TECATE ]; then
TOR_TECATE=1
usr_card_type=41
card_name="tor_tecate"
NS_FPORT=54
SR_CAPABLE=1
elif [ $card_index -eq $CARD_INDEX_SCULPIN ]; then
get_crdcfg_tor_card_mode
current_mode=$?
if [ $current_mode -eq 0 ]; then
TOR_SCULPIN=1
CORTINA1_SDK=1
else
TOR_SCULPIN_LEAF=1
fi
usr_card_type=42
card_name="tor_sculpin"
NS_FPORT=16
SR_CAPABLE=1
elif [ $card_index -eq $CARD_INDEX_MARIPOSA ]; then
get_crdcfg_tor_card_mode
current_mode=$?
if [ $current_mode -eq 0 ]; then
TOR_MARIPOSA_SPINE=1
CORTINA1_SDK=1
else
TOR_MARIPOSA=1
fi
usr_card_type=43
card_name="tor_mariposa"
NS_FPORT=36
SR_CAPABLE=1
elif [ $card_index -eq $CARD_INDEX_ST_ARCHER ]; then
TOR_ST_ARCHER=1
usr_card_type=46
card_name="tor_st_archer"
NS_FPORT=108
SR_CAPABLE=1
elif [ $card_index -eq $CARD_INDEX_TUCHER ]; then
TOR_TUCHER=1
usr_card_type=47
card_name="tor_tucher"
NS_FPORT=108
SR_CAPABLE=1
elif [ $card_index -eq $CARD_INDEX_MT_BRAVE ]; then
IS_ATOM=1
IS_FC_MT_BRAVE=1
usr_card_type=48
elif [ $card_index -eq $CARD_INDEX_BRASSWOOD ]; then
IS_ATOM=1
IS_LC_BRASSWOOD=1
usr_card_type=49
elif [ $card_index -eq $CARD_INDEX_SHELDON ]; then
IS_ATOM=1
IS_FC_SHELDON=1
usr_card_type=50
elif [ $card_index -eq $CARD_INDEX_RED_HORSE ]; then
get_crdcfg_tor_card_mode
current_mode=$?
if [ $current_mode -eq 0 ]; then
TOR_RED_HORSE_SPINE=1
CORTINA1_SDK=1
else
TOR_RED_HORSE=1
fi
usr_card_type=44
card_name="tor_red_horse"
NS_FPORT=64
SR_CAPABLE=1
elif [ $card_index -eq $CARD_INDEX_DUVEL ]; then
get_crdcfg_tor_card_mode
current_mode=$?
if [ $current_mode -eq 0 ]; then
TOR_DUVEL=1
CORTINA1_SDK=1
else
TOR_DUVEL_LEAF=1
fi
usr_card_type=51
card_name="tor_duvel"
NS_FPORT=66
SR_CAPABLE=1
elif [ $card_index -eq $CARD_INDEX_COASTAL_FOG ]; then
get_crdcfg_tor_card_mode
current_mode=$?
if [ $current_mode -eq 0 ]; then
TOR_COASTAL_FOG_SPINE=1
CORTINA1_SDK=1
else
TOR_COASTAL_FOG=1
fi
usr_card_type=52
card_name="tor_coastal_fog"
NS_FPORT=34
SR_CAPABLE=1
elif [ $card_index -eq $CARD_INDEX_STELLER ]; then
TOR_STELLER=1
usr_card_type=53
card_name="tor_steller"
NS_FPORT=36
SR_CAPABLE=1
elif [ $card_index -eq $CARD_INDEX_PETRUS ]; then
get_crdcfg_tor_card_mode
current_mode=$?
if [ $current_mode -eq 0 ]; then
TOR_PETRUS=1
CORTINA1_SDK=1
else
TOR_PETRUS_LEAF=1
fi
usr_card_type=54
card_name="tor_petrus"
NS_FPORT=48
SR_CAPABLE=1
elif [ $card_index -eq $CARD_INDEX_CHURCHILL ]; then
TOR_CHURCHILL=1
usr_card_type=55
card_name="tor_churchill"
CORTINA1_SDK=1 # Radha TODO
NS_FPORT=32 # Radha TODO
elif [ $card_index -eq $CARD_INDEX_THE_CHILD_RP_1 ]; then
SUPERVISOR=1
usr_card_type=56
card_name="mando_the_child"
IS_SUP2=1
SUP_THE_CHILD=1
IS_LEM_CARD=1
IS_THE_CHILD_RP_1=1
elif [ $card_index -eq $CARD_INDEX_MOFF_GIDEON ]; then
# IS_ATOM=1
IS_LC_MOFF_GIDEON=1
usr_card_type=58
elif [ $card_index -eq $CARD_INDEX_EDELWEISS ]; then
get_crdcfg_tor_card_mode
current_mode=$?
if [ $current_mode -eq 0 ]; then
TOR_EDELWEISS_SPINE=1
CORTINA1_SDK=1
else
TOR_EDELWEISS=1
fi
IS_LEM_CARD=1
IS_EDELWEISS=1
usr_card_type=57
card_name="tor_edelweiss"
NS_FPORT=8
SR_CAPABLE=1
elif [ $card_index -eq $CARD_INDEX_TRAPPIST ]; then
TOR_TRAPPIST=1
usr_card_type=60
card_name="tor_trappist"
NS_FPORT=54
SR_CAPABLE=1
elif [ $card_index -eq $CARD_INDEX_TRIPEL ]; then
TOR_TRIPEL=1
usr_card_type=61
card_name="tor_tripel"
NS_FPORT=54
SR_CAPABLE=1
elif [ $card_index -eq $CARD_INDEX_BLACKBIRD ]; then
IS_ATOM=1
IS_LC_BLACKBIRD=1
usr_card_type=62
fi
if [ $card_index -eq $CARD_INDEX_NAGANO -o $card_index -eq $CARD_INDEX_SOCHI -o $card_index -eq $CARD_INDEX_PLACID -o \
$card_index -eq $CARD_INDEX_OSLO -o $card_index -eq $CARD_INDEX_CALGARY -o $card_index -eq $CARD_INDEX_SAPPORO -o \
$card_index -eq $CARD_INDEX_GRENOBLE -o $card_index -eq $CARD_INDEX_SLCITY -o $card_index -eq $CARD_INDEX_SQUAWVALLEY -o \
$card_index -eq $CARD_INDEX_SUMPIN -o $card_index -eq $CARD_INDEX_SHUGGA -o $card_index -eq $CARD_INDEX_FOSTERS -o \
$card_index -eq $CARD_INDEX_SEOUL -o $card_index -eq $CARD_INDEX_DEERVALLEY -o $card_index -eq $CARD_INDEX_TURIN -o \
$card_index -eq $CARD_INDEX_SEOUL2 -o $card_index -eq $CARD_INDEX_DOPPLEBOCK -o $card_index -eq $CARD_INDEX_PIPEWORKS -o \
$card_index -eq $CARD_INDEX_SCRIMSHAW -o $card_index -eq $CARD_INDEX_PIPEDREAM -o $card_index -eq $CARD_INDEX_SOUTHLAKE -o \
$card_index -eq $CARD_INDEX_GRACELAND -o $card_index -eq $CARD_INDEX_MARIPOSA -o \
$card_index -eq $CARD_INDEX_KRIEK -o $card_index -eq $CARD_INDEX_TRUMER -o $card_index -eq $CARD_INDEX_ELYSIAN -o \
$card_index -eq $CARD_INDEX_TECATE -o $card_index -eq $CARD_INDEX_MAIBOCK -o $card_index -eq $CARD_INDEX_SCULPIN -o \
$card_index -eq $CARD_INDEX_ST_ARCHER -o $card_index -eq $CARD_INDEX_TUCHER -o $card_index -eq $CARD_INDEX_RED_HORSE -o \
$card_index -eq $CARD_INDEX_DUVEL -o $card_index -eq $CARD_INDEX_COASTAL_FOG -o $card_index -eq $CARD_INDEX_STELLER -o \
$card_index -eq $CARD_INDEX_PETRUS -o $card_index -eq $CARD_INDEX_EDELWEISS -o $card_index -eq $CARD_INDEX_TRAPPIST -o \
$card_index -eq $CARD_INDEX_CHURCHILL -o $card_index -eq $CARD_INDEX_TRIPEL ]; then
IS_TOR=1
fi
if [ $IS_TOR -eq 1 -a $card_index -ne $CARD_INDEX_DOPPLEBOCK -a $card_index -ne $CARD_INDEX_MAIBOCK -a \
$card_index -ne $CARD_INDEX_SCULPIN -a $card_index -ne $CARD_INDEX_DUVEL -a \
$card_index -ne $CARD_INDEX_PETRUS -a $card_index -ne $CARD_INDEX_CHURCHILL ]; then
IS_LEAF=1
fi
if [ $card_index -eq $CARD_INDEX_ML_BANFF ]; then
TOR=1
IS_TOR=1
usr_card_type=5
card_name="tor"
INXOS_PE_MOCK=1
INXOS_PE_IFC=0
nxos_pe="MOCK"
NS_FPORT=33
fi
if [ $IS_TOR -eq 1 ]; then
if [ $card_index -eq $CARD_INDEX_DOPPLEBOCK ] || \
[ $card_index -eq $CARD_INDEX_CHURCHILL ] || \
[ $card_index -eq $CARD_INDEX_MAIBOCK ] || \
[ $TOR_DUVEL -eq 1 ] || \
[ $TOR_COASTAL_FOG_SPINE -eq 1 ] || \
[ $TOR_SCULPIN -eq 1 ] || \
[ $TOR_MARIPOSA_SPINE -eq 1 ] || \
[ $TOR_EDELWEISS_SPINE -eq 1 ] || \
[ $TOR_RED_HORSE_SPINE -eq 1 ] || \
[ $TOR_PETRUS -eq 1 ] || \
[ $card_index -eq $CARD_INDEX_CORTINA1 ]; then
IS_SPINE=1
fi
else
IS_SPINE=1
fi
minicore=false
for arg in `cat /proc/cmdline`
do
case "${arg}" in
minicore)
minicore=true;
esac
done
if [ -f /bootflash/platform.inf ]; then
if [ ! -z $(grep "enable_bin_bash=1" /bootflash/platform.inf) ]; then
ENABLE_BIN_BASH=1
fi
fi
if [ -f /bootflash/enable_bin_bash ] && [ "`/isanboot/bin/bldreport type`" = "gdb" ]; then
ENABLE_BIN_BASH=1
fi
}
get_hw_sup_slots()
{
my_card_index=$(cat /sys/kernel/cisco_board_info/card_index)
if [ $my_card_index -eq $CARD_INDEX_THE_CHILD_RP_1 ]; then
# slot_id=$(cat /sys/kernel/cisco_board_info/slot_index)
slot_id_data=`/usr/sbin/iorw r 0xb1031080 w`
slot_id=`echo $slot_id_data | awk '{print substr($0, 7, 2)}'`
slot_id_hex=$((slot_id + 27))
else
slot_id_data=`/usr/sbin/iorw r 0xe800000c b`
slot_id=`echo $slot_id_data | awk '{print substr($0, 7, 2)}'`
slot_id_hex='0x'$slot_id
# Make sure to take only the 5 least significant bits.
slot_id_hex=$((slot_id_hex&0x1f))
fi
sup_slot_id=$slot_id_hex
if [ $sup_slot_id -eq 27 ]; then
other_sup_slot_id=28
else
other_sup_slot_id=27
fi
}
setup_diag_bootup_level_file()
{
if [ -f /mnt/bootflash/diag_bootup ]; then
cp /mnt/bootflash/diag_bootup /tmp/diag_bootup
rm -rf /mnt/bootflash/diag_bootup
fi
}
# cleanup all files not needed by tahoe platforms on line cards
ins_clean_non_tahoe_files() {
echo "Cleaning up non tahoe specific files" >> /tmp/presysmgr.log
rm -rf /lc/isan/bin/ishell*
rm -rf /lc/isan/bin/nsausd
rm -rf /lc/isan/bin/t2usd
rm -rf /lc/isan/bin/inssim.exe
rm -rf /lc/isan/bin/lcm_itest
rm -rf /lc/isan/sdkbin.tar.gz
rm -rf /lc/isan/sdktools.tar.gz
rm -rf /lc/isan/sdklib.tar.gz
rm -rf /lc/isan/sdkconf.tar.gz
rm -rf /lc/isan/lib/libbcm*
rm -rf /usr/lib/perl
rm -rf /lc/isan/lib/libtahoe_dummy.so
}
# Not all sim setups support 9 partitions
# On the ones there is support map paritions like in hw so that
# ifc mode works seamlessly.
ins_sim_supports_sda9() {
sda9_present=0
if [ -e /dev/sda9 ]; then
sda9_present=1
fi
echo "Checking for /dev/sda9 for sim : $sda9_present"
}
collect_stby_logs() {
echo "Collecting logs on stby"
if [[ -e /tmp/stby_logs ]] ; then
echo "stby logs are already collected"
return
fi
touch /tmp/stby_logs
rm -rf /bootflash/tmp
mkdir /bootflash/tmp
cd /bootflash/tmp
dmesg > dmesg
tar czf mnt_pss.tar.gz /mnt/pss
tar czf mnt_pstore.tar.gz /mnt/pstore
tar czf mnt_ifc_log.tar.gz /mnt/ifc/log/last_run
rm /bootflash-remote/stby_tech_*
tar czf stby_tech_$(date +%Y%m%d-%H%M%S).tar.gz .
#copy the file if more than 20% available on remote bootflash after copy
remote_size=$(df -B 1024 /bootflash-remote | grep bootflash | awk '{print $2}')
remote_available_size=$(df -B 1024 /bootflash-remote | grep bootflash | awk '{print $4}')
tar_file_size=$(du -s -B 1024 stby_tech* | awk '{print $1}')
if [[ ( $tar_file_size -lt $remote_available_size ) &&
( $(( (remote_available_size - tar_file_size) * 100 / remote_size )) -gt 20 )]] ; then
cp stby_tech* /bootflash-remote
else
echo "not enough memory to copy stby logs"
fi
cd ..
rm -rf /bootflash/tmp
}
clear_n9k_cpa_files() {
# clear n9k_cpa files
#[ ! -d /isan/lib/n9k_cpa ] || rm -rf /isan/lib/n9k_cpa
#[ ! -d /isan/bin/n9k_cpa ] || rm -rf /isan/bin/n9k_cpa
[ ! -d /usr/lib64/n9k_cpa ] || rm -rf /usr/lib64/n9k_cpa
[ ! -d /usr/bin/n9k_cpa ] || rm -rf /usr/bin/n9k_cpa
[ ! -d /usr/local/etc/n9k-cpa-data ] || rm -rf /usr/local/etc/n9k-cpa-data
[ ! -d /lc/isan/lib/n9k_cpa ] || rm -rf /lc/isan/lib/n9k_cpa
[ ! -d /lc/isan/bin/n9k_cpa ] || rm -rf /lc/isan/bin/n9k_cpa
}
setup_xrcpa_sb_lib_files() {
lib_path=$1
sb_lib=$2
sb_sprom_lib=$3
# setup xr_cpa file
if [ -f $lib_path/xr_cpa/$sb_lib ] ; then
rm -rf $lib_path/xr_cpa/libcpa_sb.so*
rm -rf $lib_path/xr_cpa/libplatform-cpa-sb-sprom.so*
ln -s $lib_path/xr_cpa/$sb_lib $lib_path/xr_cpa/libcpa_sb.so.0.0.0
ln -s $lib_path/xr_cpa/$sb_lib $lib_path/xr_cpa/libcpa_sb.so.0
ln -s $lib_path/xr_cpa/$sb_lib $lib_path/xr_cpa/libcpa_sb.so
ln -s $lib_path/xr_cpa/$sb_sprom_lib $lib_path/xr_cpa/libplatform-cpa-sb-sprom.so.0.0.0
ln -s $lib_path/xr_cpa/$sb_sprom_lib $lib_path/xr_cpa/libplatform-cpa-sb-sprom.so
ln -s $lib_path/xr_cpa/$sb_sprom_lib $lib_path/xr_cpa/libplatform-cpa-sb-sprom.so.0
#boot_debug "Linked $lib_path/xr_cpa/$sb_lib"
else
echo "Error: CPA SB lib not found"
fi
}
setup_xrcpa_lib_symlinks() {
target_path=$1
typ=$2
link_path=$3
# setup xr_cpa file
for f in $target_path/$typ/xr_cpa/*
do
# TO DO MANDO/XR: Checking if file exists should not be needed
# Check why there are multiple libraries.
[ -e $link_path/${f##*/} ] || ln -s $f $link_path/${f##*/}
# TO DO MANDO/XR: some libraries are dlopened as so.1 change to .so if possible
if [ "$typ" = "lib" ] || [ "$typ" = "lib64" ]; then
[ -e $link_path/${f##*/}.1 ] || ln -s $f $link_path/${f##*/}.1
fi
done
}
xr_iofpga_wr()
{
base_addr=$1
offset=$2
val=$3
echo "CHASSIS SYNC: writing $val to $offset" >> /tmp/chassis_sync.log 2>&1
/lc/isan/bin/iorw w $(printf "0x%x" $(($base_addr + $offset))) $val w >> /tmp/chassis_sync.log 2>&1
}
xr_chassis_sync()
{
io_base_addr=$((0x$(cat /proc/bus/pci/devices | grep 1137017a | cut -f4 | tr -d ' ') & 0xfffffff0))
xr_iofpga_wr $io_base_addr 0x1108 0xa0602
xr_iofpga_wr $io_base_addr 0x110c 0x10000
xr_iofpga_wr $io_base_addr 0x1110 0x38303838
xr_iofpga_wr $io_base_addr 0x1114 0x0
xr_iofpga_wr $io_base_addr 0x1118 0x0
xr_iofpga_wr $io_base_addr 0x111c 0x0
xr_iofpga_wr $io_base_addr 0x1120 0x0
xr_iofpga_wr $io_base_addr 0x1124 0x32584f46
xr_iofpga_wr $io_base_addr 0x1128 0x50323135
xr_iofpga_wr $io_base_addr 0x112c 0x4d5830
xr_iofpga_wr $io_base_addr 0x1104 0x01000001
# Reset/Restore correct block offsets for kirkwall
xr_iofpga_wr $io_base_addr 0x44 0x00100010
xr_iofpga_wr $io_base_addr 0x48 0x001000d0
xr_iofpga_wr $io_base_addr 0x4c 0x00100010
xr_iofpga_wr $io_base_addr 0x50 0x00100010
xr_iofpga_wr $io_base_addr 0x54 0x00100010
xr_iofpga_wr $io_base_addr 0x58 0x00100010
xr_iofpga_wr $io_base_addr 0x5c 0x00100020
xr_iofpga_wr $io_base_addr 0x60 0x00100010
xr_iofpga_wr $io_base_addr 0x64 0x00100010
xr_iofpga_wr $io_base_addr 0x68 0x00100010
xr_iofpga_wr $io_base_addr 0x6c 0x00200010
xr_iofpga_wr $io_base_addr 0x70 0x00800010
xr_iofpga_wr $io_base_addr 0x74 0x00300010
xr_iofpga_wr $io_base_addr 0x78 0x00200030
xr_iofpga_wr $io_base_addr 0x7c 0x00800080
xr_iofpga_wr $io_base_addr 0x80 0x00100080
xr_iofpga_wr $io_base_addr 0x84 0x00200010
xr_iofpga_wr $io_base_addr 0x88 0x00200020
xr_iofpga_wr $io_base_addr 0x8c 0x00200020
xr_iofpga_wr $io_base_addr 0x90 0x00200020
xr_iofpga_wr $io_base_addr 0x94 0x00200020
xr_iofpga_wr $io_base_addr 0x98 0x00200020
xr_iofpga_wr $io_base_addr 0x9c 0x00200020
xr_iofpga_wr $io_base_addr 0xa0 0x00200020
xr_iofpga_wr $io_base_addr 0xa4 0x00200020
xr_iofpga_wr $io_base_addr 0xa8 0x001000c0
xr_iofpga_wr $io_base_addr 0xac 0x01800010
xr_iofpga_wr $io_base_addr 0xb0 0x01800180
xr_iofpga_wr $io_base_addr 0xb4 0x01800180
xr_iofpga_wr $io_base_addr 0xb8 0x00100010
xr_iofpga_wr $io_base_addr 0xbc 0x00100010
xr_iofpga_wr $io_base_addr 0xc0 0x00000030
xr_iofpga_wr $io_base_addr 0xc4 0x00000000
xr_iofpga_wr $io_base_addr 0xc8 0x00000000
xr_iofpga_wr $io_base_addr 0xcc 0x00000000
xr_iofpga_wr $io_base_addr 0xd0 0x00000000
xr_iofpga_wr $io_base_addr 0xd4 0x00000000
xr_iofpga_wr $io_base_addr 0xd8 0x00000000
xr_iofpga_wr $io_base_addr 0xdc 0x00000000
xr_iofpga_wr $io_base_addr 0xe0 0x00000000
xr_iofpga_wr $io_base_addr 0xe4 0x00000000
xr_iofpga_wr $io_base_addr 0xe8 0x00000000
xr_iofpga_wr $io_base_addr 0xec 0x00000000
xr_iofpga_wr $io_base_addr 0xf0 0x00000000
xr_iofpga_wr $io_base_addr 0xf4 0x00000000
xr_iofpga_wr $io_base_addr 0xf8 0x00000000
}
setup_xr_cpa() {
local card_index=$1
platform="XR platform"
clear_n9k_cpa_files
ln -s /usr/local/etc/xr-cpa-data/fru-db.json /usr/local/etc/fru-db.json
ln -s /usr/local/etc/xr-cpa-data/cpa-yaml /usr/local/etc/cpa-yaml
xrcpa_dest_libpath=/usr/lib64
xrcpa_dest_binpath=/usr/bin
echo "setup_xr_cpa:1300" >> /tmp/presysmgr.log
if [ $card_index -eq $CARD_INDEX_THE_CHILD_RP_1 ]; then
echo "setup_xr_cpa:1310" >> /tmp/presysmgr.log
setup_xrcpa_sb_lib_files $xrcpa_dest_libpath libcpa_sb_8800_rp_1_0_x86_api.so.0.0.0 libidprom-platform-8800-rp.so.0.0.0
#setup_xrcpa_lib_symlinks /isan lib /isan/lib
#setup_xrcpa_lib_symlinks /isan lib /usr/lib64/
#setup_xrcpa_lib_symlinks /isan bin /isan/bin
##setup_xrcpa_lib_symlinks /isan bin /usr/lib64/
setup_xrcpa_lib_symlinks /usr lib64 /usr/lib64/
setup_xrcpa_lib_symlinks /usr bin /usr/bin/
$xrcpa_dest_binpath/spitfire_bootstrap > /tmp/bootstrap.log 2>&1
platform="MANDO RP"
elif [ $card_index -eq $CARD_INDEX_MOFF_GIDEON ]; then
setup_xrcpa_sb_lib_files /lc/isan/lib libcpa_sb_vanguard_1_0_x86_api.so.0.0.0 libidprom-platform-8800-lc-36fh-m.so.0.0.0
setup_xrcpa_lib_symlinks /lc/isan lib /lc/isan/lib
setup_xrcpa_lib_symlinks /lc/isan lib /usr/lib64/
setup_xrcpa_lib_symlinks /lc/isan bin /lc/isan/bin
# MANDO TO DO: temporary chassis_sync change
xr_chassis_sync
/lc/isan/bin/spitfire_bootstrap > /tmp/bootstrap.log 2>&1
platform="MANDO LC VG"
elif [ $card_index -eq $CARD_INDEX_AXE_WOVES ]; then
setup_xrcpa_sb_lib_files /lc/isan/lib libcpa_sb_lancer_1_0_x86_api.so.0.0.0 libidprom-platform-8800-lc-36fh-m.so.0.0.0
setup_xrcpa_lib_symlinks /lc/isan lib /lc/isan/lib
setup_xrcpa_lib_symlinks /lc/isan lib /usr/lib64/
setup_xrcpa_lib_symlinks /lc/isan bin /lc/isan/bin
# MANDO TO DO: temporary chassis_sync change
xr_chassis_sync
/lc/isan/bin/spitfire_bootstrap > /tmp/bootstrap.log 2>&1
platform="MANDO LC LN"
else
#Assume TORs (sup only)
if [ $card_index -eq $CARD_INDEX_CHURCHILL ]; then
# sup
setup_xrcpa_sb_lib_files $xrcpa_dest_libpath libcpa_sb_8201_32fh_1_0_x86_api.so.0.0.0 libidprom-platform-8201-32fh.so.0.0.0
platform="Churchill"
fi
# TO DO: Review if seperate lc/sup is necessary for TORs
#setup_xrcpa_lib_symlinks /isan lib /isan/lib
#setup_xrcpa_lib_symlinks /isan lib /usr/lib64/
#setup_xrcpa_lib_symlinks /isan bin /isan/bin
setup_xrcpa_lib_symlinks /usr lib64 /usr/lib64/
setup_xrcpa_lib_symlinks /usr bin /usr/bin
#/isanboot/bin/spitfire_bootstrap > /tmp/bootstrap.log 2>&1
fi
echo "$platform CPA setup done"
}
setup_xr_cpa_tor_lc() {
local card_index=$1
platform="XR platform"
clear_n9k_cpa_files
if [ $card_index -eq $CARD_INDEX_CHURCHILL ]; then
# lc
setup_xrcpa_sb_lib_files /lc/isan/lib libcpa_sb_8201_32fh_1_0_x86_api.so.0.0.0 libidprom-platform-8201-32fh.so.0.0.0
platform="Churchill LC"
fi
# TO DO: Review if seperate lc/sup is necessary for TORs
setup_xrcpa_lib_symlinks /lc/isan lib /lc/isan/lib
setup_xrcpa_lib_symlinks /lc/isan bin /lc/isan/bin
echo "$platform CPA setup done"
}
clear_xr_cpa() {
# clear xr_cpa files
#[ ! -d /isan/lib/xr_cpa ] || rm -rf /isan/lib/xr_cpa
#[ ! -d /isan/bin/xr_cpa ] || rm -rf /isan/bin/xr_cpa
[ ! -d /usr/lib64/xr_cpa ] || rm -rf /usr/lib64/xr_cpa
[ ! -d /usr/bin/xr_cpa ] || rm -rf /usr/bin/xr_cpa
[ ! -d /usr/local/etc/xr-cpa-data ] || rm -rf /usr/local/etc/xr-cpa-data
[ ! -d /lc/isan/lib/xr_cpa ] || rm -rf /lc/isan/lib/xr_cpa
[ ! -d /lc/isan/bin/xr_cpa ] || rm -rf /lc/isan/bin/xr_cpa
}
setup_n9k_cpa() {
local card_index=$1
# clear xr_cpa files
clear_xr_cpa
# setup n9k_cpa files (Default behavior)
#[ ! -d /isan/lib/n9k_cpa ] || mv /isan/lib/n9k_cpa/* /isan/lib/
#[ ! -d /isan/bin/n9k_cpa ] || mv /isan/bin/n9k_cpa/* /isan/bin/
[ ! -d /usr/lib64/n9k_cpa ] || mv /usr/lib64/n9k_cpa/* /isan/lib/
[ ! -d /usr/bin/n9k_cpa ] || mv /usr/bin/n9k_cpa/* /isan/bin/
[ ! -d /usr/local/etc/n9k-cpa-data ] || mv /usr/local/etc/n9k-cpa-data/* /usr/local/etc/
#[ ! -d /lc/isan/lib/n9k_cpa ] || mv /lc/isan/lib/n9k_cpa/* /lc/isan/lib/
#[ ! -d /lc/isan/bin/n9k_cpa ] || mv /lc/isan/bin/n9k_cpa/* /lc/isan/bin/
if [ $card_index == 21223 ]; then
cp /isan/lib/libcpa_sb_nxos_exa.so /isan/lib/libcpa_sb_nxos.so
#cp /usr/lib64/libcpa_sb_nxos_exa.so /usr/lib64/libcpa_sb_nxos.so
#cp /lc/isan/lib/libcpa_sb_nxos_exa.so /lc/isan/lib/libcpa_sb_nxos.so
fi
if [ -f "/isan/lib/libcpa_sb_nxos.so.0.0.0" ]; then
rm /isan/lib/libcpa_sb.so.0.0.0
ln -s /isan/lib/libcpa_sb_nxos.so.0.0.0 /isan/lib/libcpa_sb.so.0.0.0
#rm /usr/lib64/libcpa_sb.so
#ln -s /usr/lib64/libcpa_sb_nxos.so /usr/lib64/libcpa_sb.so
#boot_debug "Linked /isan/lib/libcpa_sb_nxos.so"
fi
echo "N9K CPA setup done"
}
setup_n9k_cpa_tor_lc() {
local card_index=$1
# clear xr_cpa files
clear_xr_cpa
# setup n9k_cpa files
#[ ! -d /isan/lib/n9k_cpa ] || mv /isan/lib/n9k_cpa/* /isan/lib/
#[ ! -d /isan/bin/n9k_cpa ] || mv /isan/bin/n9k_cpa/* /isan/bin/
#[ ! -d /usr/local/etc/n9k-cpa-data ] || mv /usr/local/etc/n9k-cpa-data/* /usr/local/etc/
[ ! -d /lc/isan/lib/n9k_cpa ] || mv /lc/isan/lib/n9k_cpa/* /lc/isan/lib/
[ ! -d /lc/isan/bin/n9k_cpa ] || mv /lc/isan/bin/n9k_cpa/* /lc/isan/bin/
[ ! -d /usr/local/etc/n9k-cpa-data/cpa-yaml ] || mv /usr/local/etc/n9k-cpa-data/cpa-yaml /usr/local/etc/
[ ! -f /usr/local/etc/n9k-cpa-data/fru-db.json ] || mv /usr/local/etc/n9k-cpa-data/fru-db.json /usr/local/etc/
if [ $card_index == 21223 ]; then
#cp /isan/lib/libcpa_sb_nxos_exa.so /isan/lib/libcpa_sb_nxos.so
cp /lc/isan/lib/libcpa_sb_nxos_exa.so /lc/isan/lib/libcpa_sb_nxos.so
fi
if [ -f "/lc/isan/lib/libcpa_sb_nxos.so.0.0.0" ]; then
rm /lc/isan/lib/libcpa_sb.so.0.0.0
ln -s /lc/isan/lib/libcpa_sb_nxos.so.0.0.0 /lc/isan/lib/libcpa_sb.so.0.0.0
#boot_debug "Linked /lc/isan/lib/libcpa_sb_nxos.so"
fi
echo "N9K TOR LC CPA setup done"
}
setup_cpa_sup_boot() {
local card_index=$1
case $card_index in
$CARD_INDEX_THE_CHILD_RP_1 | $CARD_INDEX_CHURCHILL )
setup_xr_cpa $card_index
ln -s /usr/lib64/xr_cpa/libpal_cpa.so.0.0.0 /isanboot/lib/libpal_cpa.so.0.0.0
ln -s /usr/lib64/xr_cpa/libpal_cpa.so.0.0.0 /isanboot/lib/libpal_cpa.so.0
ln -s /usr/lib64/xr_cpa/libpal_cpa.so.0.0.0 /isanboot/lib/libpal_cpa.so
;;
$CARD_INDEX_MOFF_GIDEON | $CARD_INDEX_AXE_WOVES )
;;
*)
#setup_n9k_cpa $card_index
;;
esac
}
setup_cpa_sup_isan() {
local card_index=$1
case $card_index in
$CARD_INDEX_THE_CHILD_RP_1 | $CARD_INDEX_CHURCHILL )
#setup_xr_cpa $card_index
ln -s /usr/lib64/xr_cpa/libpal_cpa.so.0.0.0 /isan/lib/libpal_cpa.so.0.0.0
ln -s /usr/lib64/xr_cpa/libpal_cpa.so.0.0.0 /isan/lib/libpal_cpa.so.0
ln -s /usr/lib64/xr_cpa/libpal_cpa.so.0.0.0 /isan/lib/libpal_cpa.so
;;
$CARD_INDEX_MOFF_GIDEON | $CARD_INDEX_AXE_WOVES )
;;
*)
setup_n9k_cpa $card_index
;;
esac
}
setup_cpa_sup_isan_bootlinks() {
local card_index=$1
case $card_index in
$CARD_INDEX_THE_CHILD_RP_1 | $CARD_INDEX_CHURCHILL )
#setup_xr_cpa $card_index
ln -s /usr/lib64/xr_cpa/libpal_cpa.so.0.0.0 /isanboot/lib/libpal_cpa.so.0.0.0
ln -s /usr/lib64/xr_cpa/libpal_cpa.so.0.0.0 /isanboot/lib/libpal_cpa.so.0
ln -s /usr/lib64/xr_cpa/libpal_cpa.so.0.0.0 /isanboot/lib/libpal_cpa.so
;;
$CARD_INDEX_MOFF_GIDEON | $CARD_INDEX_AXE_WOVES )
;;
*)
;;
esac
}
setup_cpa_lc() {
local card_index=$1
case $card_index in
$CARD_INDEX_THE_CHILD_RP_1 )
;;
$CARD_INDEX_MOFF_GIDEON )
setup_xr_cpa $card_index
;;
*)
setup_n9k_cpa_tor_lc $card_index
;;
esac
}
setup_cpa_tor_lc() {
local card_index=$1
case $card_index in
$CARD_INDEX_CHURCHILL )
setup_xr_cpa_tor_lc $card_index
;;
$CARD_INDEX_THE_CHILD_RP_1 |$CARD_INDEX_MOFF_GIDEON | $CARD_INDEX_AXE_WOVES )
;;
*)
setup_n9k_cpa_tor_lc $card_index
;;
esac
}
|
/bin/prepare-mfg.sh
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 | #!/bin/bash
. /etc/isim_include
if [ -z $1 ]; then
echo "No image?"
echo "Usage: prepare-mfg.sh <image> "
echo "image should be in bootflash, do not give /bootflash/<image>"
exit
else
if [ ! -f /bootflash/$1 ]; then
echo "Cant find image"
exit
fi
fi
usr=`id -un `
if [ $usr == "root" ]; then
echo "Preparing to erase all config"
rm -rf /bootflash/isim.conf
touch /mnt/pss/.clean
touch /mnt/cfg/0/clean-config
touch /mnt/cfg/1/clean-config
#rm -rf /mnt/ifc/cfg/db/*
echo "Cleanup cores"
rm -rf /logflash/core/*
rm -rf /logflash/log/*
rm -rf /mnt/pss/logs/*
rm -rf /mnt/ifc/log/*
rm -rf /recovery/*
echo "Setting up recovery image wait 30 seconds"
cp /bootflash/$1 /recovery
sync
sleep 30
sync
rm -rf /bootflash/*
cp /recovery/$1 /bootflash
sync
sleep 30
sync
echo "Setting up boot variables"
touch /mnt/cfg/0/boot/grub/menu.lst.local
touch /mnt/cfg/1/boot/grub/menu.lst.local
echo "boot $1" > /mnt/cfg/0/boot/grub/menu.lst.local
echo "boot $1" > /mnt/cfg/1/boot/grub/menu.lst.local
touch /mnt/cfg/0/boot/grub/menu.lst.recovery
touch /mnt/cfg/1/boot/grub/menu.lst.recovery
echo "boot $1" > /mnt/cfg/0/boot/grub/menu.lst.recovery
echo "boot $1" > /mnt/cfg/1/boot/grub/menu.lst.recovery
else
bg_action /tmp/prepare-mfg $1
fi
|