blob: 1d69e287a1ecec9bfd3c6dfff1bcc080abde0f10 [file] [log] [blame]
Thiyagarajan Subramanie84935d2020-04-23 17:45:44 +05301diff --git a/builds/any/rootfs/jessie/common/all-base-packages.yml b/builds/any/rootfs/jessie/common/all-base-packages.yml
2index bbeab6b4..ca5a45cd 100644
3--- a/builds/any/rootfs/jessie/common/all-base-packages.yml
4+++ b/builds/any/rootfs/jessie/common/all-base-packages.yml
5@@ -81,3 +81,7 @@
6 - sysstat
7 - ipmitool
8 - lm-sensors
9+- python3.4
10+- python3-yaml
11+- cron
12+- logrotate
Humera Kouser9c2bd9f2020-09-25 02:41:29 -040013diff --git a/builds/any/rootfs/jessie/common/overlay/etc/mtab.yml b/builds/any/rootfs/jessie/common/overlay/etc/mtab.yml
14index e04f366..81ef69a 100644
15--- a/builds/any/rootfs/jessie/common/overlay/etc/mtab.yml
16+++ b/builds/any/rootfs/jessie/common/overlay/etc/mtab.yml
17@@ -1,21 +1,30 @@
18 mounts:
19 ONL-IMAGES:
20- mount: ro
21+ mount: rw
22 dir: /mnt/onl/images
23 fsck: true
24
25- ONL-DATA:
26+ ONL-ACTIVE-DATA:
27+ mount: rw
28+ dir: /mnt/onl/active_data
29+
30+ ONL-STANDBY-DATA:
31 mount: rw
32- dir: /mnt/onl/data
33+ dir: /mnt/onl/standby_data
34
35 ONL-CONFIG:
36- mount: ro
37+ mount: rw
38 dir: /mnt/onl/config
39 fsck: true
40
41- ONL-BOOT:
42- mount: ro
43- dir: /mnt/onl/boot
44+ ONL-ACTIVE-BOOT:
45+ mount: rw
46+ dir: /mnt/onl/active_boot
47+ fsck: false
48+
49+ ONL-STANDBY-BOOT:
50+ mount: rw
51+ dir: /mnt/onl/standby_boot
52 fsck: false
53
54 # ESP (EFI system partition)
55diff --git a/builds/any/rootfs/wheezy/common/overlay/etc/mtab.yml b/builds/any/rootfs/wheezy/common/overlay/etc/mtab.yml
56index 598e4c6..744baf3 100644
57--- a/builds/any/rootfs/wheezy/common/overlay/etc/mtab.yml
58+++ b/builds/any/rootfs/wheezy/common/overlay/etc/mtab.yml
59@@ -1,19 +1,28 @@
60 mounts:
61 ONL-IMAGES:
62- mount: ro
63+ mount: rw
64 dir: /mnt/onl/images
65 fsck: true
66
67- ONL-DATA:
68+ ONL-ACTIVE-DATA:
69+ mount: rw
70+ dir: /mnt/onl/active_data
71+
72+ ONL-STANDBY-DATA:
73 mount: rw
74- dir: /mnt/onl/data
75+ dir: /mnt/onl/standby_data
76
77 ONL-CONFIG:
78- mount: ro
79+ mount: rw
80 dir: /mnt/onl/config
81 fsck: true
82
83- ONL-BOOT:
84- mount: ro
85- dir: /mnt/onl/boot
86+ ONL-ACTIVE-BOOT:
87+ mount: rw
88+ dir: /mnt/onl/active_boot
89+ fsck: false
90+
91+ ONL-STANDBY-BOOT:
92+ mount: rw
93+ dir: /mnt/onl/standby_boot
94 fsck: false
95diff --git a/packages/base/all/boot.d/src/53.install-debs b/packages/base/all/boot.d/src/53.install-debs
96index e31d382..cf72eb3 100755
97--- a/packages/base/all/boot.d/src/53.install-debs
98+++ b/packages/base/all/boot.d/src/53.install-debs
99@@ -1,6 +1,15 @@
100 #!/bin/sh
101 ############################################################
102-PACKAGE_DIR=/mnt/onl/data/install-debs
103+ROOTFS_PATH=
104+CMD_LINE_FILE="/proc/cmdline"
105+if [ -f ${CMD_LINE_FILE} ]; then
106+ if grep -q "data-active" ${CMD_LINE_FILE}; then
107+ ROOTFS_PATH="active_data"
108+ else
109+ ROOTFS_PATH="standby_data"
110+ fi
111+fi
112+PACKAGE_DIR=/mnt/onl/${ROOTFS_PATH}/install-debs
113 PACKAGE_LIST="$PACKAGE_DIR/list"
114
115 if [ -e "$PACKAGE_LIST" ]; then
Thiyagarajan Subramanie84935d2020-04-23 17:45:44 +0530116diff --git a/packages/base/all/initrds/loader-initrd-files/src/bin/swiprep b/packages/base/all/initrds/loader-initrd-files/src/bin/swiprep
117index d5a72f8e..0b0583e1 100755
118--- a/packages/base/all/initrds/loader-initrd-files/src/bin/swiprep
119+++ b/packages/base/all/initrds/loader-initrd-files/src/bin/swiprep
Humera Kouser9c2bd9f2020-09-25 02:41:29 -0400120@@ -173,7 +173,49 @@ if test "$mode_install"; then
Thiyagarajan Subramanie84935d2020-04-23 17:45:44 +0530121 echo "*** invalid squashfs contents" 1>&2
122 exit 1
123 fi
124+ cp "$swipath" "$workdir"/
125+ cd "$workdir"
126+ unzip "$swipath"
127+ target=$(find . -name bal_packages)
128+ for f in "$target"/*
129+ do
130+ main_file_name=$(basename $f)
131+ full_path_name=$(echo $f | cut -c 3-)
132+ cp $full_path_name "$workdir"/$main_file_name
133+ done
134+ echo "Moving validation script to /root/"
135+ mv "$workdir"/validate_onl_installation.sh "$destdir"/root/
136+ mv "$workdir"/fetch_olt_sw_hw_details.py "$destdir"/root/
137+ mv "$workdir"/openolt* "$destdir"/
138+ echo "INFO: Copying init scripts to init.d"
139+ cp "$workdir"/start_inband_oltservices.sh "$destdir"/etc/init.d/
Girish Gowdra6e745522020-07-15 15:52:13 -0700140+ cp "$workdir"/inband.config "$destdir"/
Humera Kouser9c2bd9f2020-09-25 02:41:29 -0400141+ cp "$workdir"/change_labels.sh "$destdir"/etc/init.d/
Thiyagarajan Subramanie84935d2020-04-23 17:45:44 +0530142+ cd -
143 fi
144+cat > "$destdir"/etc/rc.local <<- EOF
145+#!/bin/sh -e
146+#
147+# rc.local
148+#
149+# This script is executed at the end of each multiuser runlevel.
150+# Make sure that the script will "exit 0" on success or any other
151+# value on error.
152+#
153+# In order to enable or disable this script just change the execution
154+# bits.
155+#
156+# By default this script does nothing.
157+
158+chmod 0777 /etc/init.d/start_inband_oltservices.sh
159+chmod 0777 /root/validate_onl_installation.sh
Humera Kouser9c2bd9f2020-09-25 02:41:29 -0400160+chmod 0777 /etc/init.d/change_labels.sh
Girish Gowdra6e745522020-07-15 15:52:13 -0700161+nohup sh /etc/init.d/start_inband_oltservices.sh >> /var/log/startup.log &
Humera Kouser9c2bd9f2020-09-25 02:41:29 -0400162+sh /etc/init.d/change_labels.sh >> /var/log/olt_upgrage_changelabels.log
Thiyagarajan Subramanie84935d2020-04-23 17:45:44 +0530163+exit 0
164+
165+EOF
166+
167 if test "$mode_overlay"; then
168 # keep the squashfs file around
169 mv $workdir/rootfs.sqsh /tmp/.rootfs
Humera Kouser9c2bd9f2020-09-25 02:41:29 -0400170diff --git a/packages/base/all/initrds/loader-initrd-files/src/bin/sysinit b/packages/base/all/initrds/loader-initrd-files/src/bin/sysinit
171index 6529c75..cc9892d 100755
172--- a/packages/base/all/initrds/loader-initrd-files/src/bin/sysinit
173+++ b/packages/base/all/initrds/loader-initrd-files/src/bin/sysinit
174@@ -90,13 +90,14 @@ if [ ! -f /etc/onl/abort ]; then
175 cat /etc/issue
176 fi
177
178- if [ -f /mnt/onl/boot/boot-config ]; then
179+ if [ -f /mnt/onl/active_boot/boot-config ]; then
180 # Use local boot-config.
181- cp /mnt/onl/boot/boot-config /etc/onl/boot-config
182+ cp /mnt/onl/active_boot/boot-config /etc/onl/boot-config
183 elif [ -f /etc/onl/boot-config-default ]; then
184 # Use default boot-config.
185 cp /etc/onl/boot-config-default /etc/onl/boot-config
186- cp /etc/onl/boot-config-default /mnt/onl/boot/boot-config
187+ cp /etc/onl/boot-config-default /mnt/onl/active_boot/boot-config
188+
189 fi
190 fi
191
192diff --git a/packages/base/all/initrds/loader-initrd-files/src/bootmodes/installed b/packages/base/all/initrds/loader-initrd-files/src/bootmodes/installed
193index dc0e887..b068acb 100755
194--- a/packages/base/all/initrds/loader-initrd-files/src/bootmodes/installed
195+++ b/packages/base/all/initrds/loader-initrd-files/src/bootmodes/installed
196@@ -8,17 +8,44 @@
197 . /lib/msgs
198 . /etc/onl/BOOTPARAMS
199
200-# make sure /mnt/onl/data exists
201-if [ ! -d /mnt/onl/data ]; then
202- msg_error "Missing /mnt/onl/data, disk boot cannot continue"
203+ONL_ROOT="/mnt/onl"
204+IMAGES_PATH="${ONL_ROOT}/images"
205+ACTIVE_DATA="${ONL_ROOT}/active_data"
206+STANDBY_DATA="${ONL_ROOT}/standby_data"
207+UPGRADE_IMAGE_PATH="${IMAGES_PATH}/upgrade"
208+FILE="${ONL_ROOT}/config/upgrade_config"
209+
210+# Default root file system path
211+ROOTFS_PATH=${ACTIVE_DATA}
212+DATA_NAME="active_data"
213+# Default switch image file
214+SWI_FILE=$(ls ${IMAGES_PATH}/*.swi)
215+
216+# Get the image based on the boot
217+grep -q "data-active" /proc/cmdline
218+if [ $? -ne 0 ]; then
219+ ROOTFS_PATH=${STANDBY_DATA}
220+ DATA_NAME="standby_data"
221+ # for temporary reboot on standby mode
222+ if [ -d ${UPGRADE_IMAGE_PATH} ]; then
223+ SWI_FILE=$(ls ${UPGRADE_IMAGE_PATH}/*.swi)
224+ else
225+ echo "ERROR: No Swi found for upgrade"
226+ exit 1
227+ fi
228+fi
229+
230+# make sure /mnt/onl/active_data exists
231+if [ ! -d ${ROOTFS_PATH} ]; then
232+ msg_error "Missing ${ROOTFS_PATH}, disk boot cannot continue"
233 exit 200
234 fi
235
236 # make sure it's mounted as per mtab.yml
237 d1=$(stat -f -c '%b' /mnt/onl)
238-d2=$(stat -f -c '%b' /mnt/onl/data)
239+d2=$(stat -f -c '%d' ${ROOTFS_PATH})
240 if [ "$d1" -eq "$d2" ]; then
241- msg_error "Unmounted /mnt/onl/data, disk boot cannot continue"
242+ msg_error "Unmounted ${ROOTFS_PATH}, disk boot cannot continue"
243 exit 200
244 fi
245
246@@ -37,8 +64,8 @@ case "$SWI" in
247 ""|dir:*|nfs://*/)
248 msg_info "*** missing SWI file, will attempt to boot existing image"
249
250- if [ ! -s /mnt/onl/data/etc/onl/SWI ]; then
251- msg_error "Un-populated /mnt/onl/data, cannot continue"
252+ if [ ! -s ${ROOTFS_PATH}/etc/onl/SWI ]; then
253+ msg_error "Un-populated ${ROOTFS_PATH}, cannot continue"
254 exit 200
255 fi
256
257@@ -50,11 +77,11 @@ case "$SWI" in
258 TMPDIR=$swiget_workdir swipath=$(swiget $SWI)
259
260 # do some sort of test to see if it's populated
261- if [ ! -s /mnt/onl/data/etc/onl/SWI ]; then
262- msg_info "Un-populated /mnt/onl/data, will (re-)image"
263+ if [ ! -s ${ROOTFS_PATH}/etc/onl/SWI ]; then
264+ msg_info "Un-populated ${ROOTFS_PATH}, will (re-)image"
265 do_unpack=1
266 else
267- msg_info "Found valid (current) image at /mnt/onl/data"
268+ msg_info "Found valid (current) image at ${ROOTFS_PATH}"
269 fi
270 ;;
271 esac
272@@ -69,12 +96,13 @@ case "$SWI" in
273 esac
274
275 sed -i -e '/^SWI=/d' /etc/onl/BOOTPARAMS
276-echo "SWI=dir:data:/" >> /etc/onl/BOOTPARAMS
277+echo "SWI=dir:$DATA_NAME:/" >> /etc/onl/BOOTPARAMS
278
279 if [ "$do_unpack" ]; then
280- swiprep --install "$swipath" --swiref "$swistamp" /mnt/onl/data
281+ swipath=$SWI_FILE
282+ swiprep --install "$swipath" --swiref "$swistamp" "$ROOTFS_PATH"
283 fi
284-swiprep --record "$swipath" --swiref "$swistamp" /mnt/onl/data
285+swiprep --record "$swipath" --swiref "$swistamp" "$ROOTFS_PATH"
286
287 trap - 0 1
288 do_cleanup
289diff --git a/packages/base/all/initrds/loader-initrd-files/src/etc/mtab.yml b/packages/base/all/initrds/loader-initrd-files/src/etc/mtab.yml
290index 051105c..c5f4c35 100644
291--- a/packages/base/all/initrds/loader-initrd-files/src/etc/mtab.yml
292+++ b/packages/base/all/initrds/loader-initrd-files/src/etc/mtab.yml
293@@ -4,19 +4,29 @@ mounts:
294 dir: /mnt/onl/images
295 fsck: true
296
297- ONL-DATA:
298+ ONL-ACTIVE-DATA:
299 mount: rw
300- dir: /mnt/onl/data
301+ dir: /mnt/onl/active_data
302 fsck: true
303
304 ONL-CONFIG:
305- mount: ro
306+ mount: rw
307 dir: /mnt/onl/config
308 fsck: true
309
310- ONL-BOOT:
311+ ONL-ACTIVE-BOOT:
312+ mount: rw
313+ dir: /mnt/onl/active_boot
314+ fsck: true
315+
316+ ONL-STANDBY-BOOT:
317+ mount: rw
318+ dir: /mnt/onl/standby_boot
319+ fsck: true
320+
321+ ONL-STANDBY-DATA:
322 mount: rw
323- dir: /mnt/onl/boot
324+ dir: /mnt/onl/standby_data
325 fsck: true
326
327 # ESP (EFI system partition)
328diff --git a/packages/base/all/vendor-config-onl/src/bin/onlfit b/packages/base/all/vendor-config-onl/src/bin/onlfit
329index 2c4b21e..01de3a0 100755
330--- a/packages/base/all/vendor-config-onl/src/bin/onlfit
331+++ b/packages/base/all/vendor-config-onl/src/bin/onlfit
332@@ -21,7 +21,7 @@ dir=`mktemp -d`
333 rc=
334
335 if (cd $dir && wget $1); then
336- onlfs rw boot mv $dir/* /mnt/onl/boot/${PLATFORM}.itb
337+ onlfs rw boot mv $dir/* /mnt/onl/active_boot/${PLATFORM}.itb
338 rc=0
339 else
340 echo "Download failed."
341diff --git a/packages/base/all/vendor-config-onl/src/bin/onlkernel b/packages/base/all/vendor-config-onl/src/bin/onlkernel
342index e77a6cc..a61046a 100755
343--- a/packages/base/all/vendor-config-onl/src/bin/onlkernel
344+++ b/packages/base/all/vendor-config-onl/src/bin/onlkernel
345@@ -19,7 +19,7 @@ dir=`mktemp -d`
346 rc=
347
348 if (cd $dir && wget $1); then
349- onlfs rw boot mv $dir/* /mnt/onl/boot
350+ onlfs rw boot mv $dir/* /mnt/onl/active_boot
351 rc=0
352 else
353 echo "Download failed."
354diff --git a/packages/base/all/vendor-config-onl/src/boot.d/70.dhclient.conf b/packages/base/all/vendor-config-onl/src/boot.d/70.dhclient.conf
355index 052f28f..4af1bf2 100755
356--- a/packages/base/all/vendor-config-onl/src/boot.d/70.dhclient.conf
357+++ b/packages/base/all/vendor-config-onl/src/boot.d/70.dhclient.conf
358@@ -7,12 +7,10 @@
359 MA1_MAC=${MA1_MAC:-$(cat /sys/class/net/ma1/address)}
360 DHCLIENT_CONF=${DHCLIENT_CONF:-/etc/dhcp/dhclient.conf}
361
362-echo "interface \"ma1\" {" >> $DHCLIENT_CONF
363-echo " send dhcp-client-identifier 01:$MA1_MAC;" >> $DHCLIENT_CONF
364-echo "}" >> $DHCLIENT_CONF
365-
366-
367-
368-
369-
370+grep -q "interface \"ma1\" {" $DHCLIENT_CONF
371+if [ $? -ne 0 ];then
372+ echo "interface \"ma1\" {" >> $DHCLIENT_CONF
373+ echo " send dhcp-client-identifier 01:$MA1_MAC;" >> $DHCLIENT_CONF
374+ echo "}" >> $DHCLIENT_CONF
375+fi
376
377diff --git a/packages/base/all/vendor-config-onl/src/etc/onl/sysconfig/00-defaults.yml b/packages/base/all/vendor-config-onl/src/etc/onl/sysconfig/00-defaults.yml
378index 432c6a9..098e014 100644
379--- a/packages/base/all/vendor-config-onl/src/etc/onl/sysconfig/00-defaults.yml
380+++ b/packages/base/all/vendor-config-onl/src/etc/onl/sysconfig/00-defaults.yml
381@@ -7,6 +7,9 @@
382 ############################################################
383 installer:
384 menu_name: "\"Open Network Linux\""
385+ menu_name_active: "\"ONL Active\""
386+ menu_name_standby: "\"ONL Standby\""
387+
388 os_name: Open Network Linux
389 grub:
390 - $PLATFORM.cpio.gz
391diff --git a/packages/base/all/vendor-config-onl/src/lib/platform-config-defaults-uboot.yml b/packages/base/all/vendor-config-onl/src/lib/platform-config-defaults-uboot.yml
392index 57e61fb..31d3de0 100644
393--- a/packages/base/all/vendor-config-onl/src/lib/platform-config-defaults-uboot.yml
394+++ b/packages/base/all/vendor-config-onl/src/lib/platform-config-defaults-uboot.yml
395@@ -171,7 +171,7 @@ default:
396 # data --> rest of disk
397 # default format (as shown) is ext4
398 installer:
399- - ONL-BOOT:
400+ - ONL-ACTIVE-BOOT:
401 =: 128MiB
402 # NOTE that u-boot wants the boot partition ext2, not ext4
403 format: ext2
404@@ -181,9 +181,15 @@ default:
405 =: 128MiB
406 format: ext4
407 - ONL-IMAGES:
408- =: 1GiB
409+ =: 3GiB
410 format: ext4
411- - ONL-DATA:
412+ - ONL-ACTIVE-DATA:
413+ =: 3GiB
414+ format: ext4
415+ - ONL-STANDBY-BOOT:
416+ =: 128MiB
417+ format: ext4
418+ - ONL-STANDBY-DATA:
419 =: 100%
420 format: ext4
421
422diff --git a/packages/base/all/vendor-config-onl/src/lib/platform-config-defaults-x86-64.yml b/packages/base/all/vendor-config-onl/src/lib/platform-config-defaults-x86-64.yml
423index 544bc2f..900cbef 100644
424--- a/packages/base/all/vendor-config-onl/src/lib/platform-config-defaults-x86-64.yml
425+++ b/packages/base/all/vendor-config-onl/src/lib/platform-config-defaults-x86-64.yml
426@@ -75,6 +75,9 @@ default:
427 device: ONIE-BOOT
428 # install to the device that contains the ONIE-BOOT partition
429 # (query using parted and/or blkid)
430+ install_type:
431+ type: install
432+ device: None
433
434 # Default partitioning scheme
435 # boot, config --> 128MiB
436@@ -82,16 +85,22 @@ default:
437 # data --> rest of disk
438 # default format (as shown) is ext4
439 installer:
440- - ONL-BOOT:
441+ - ONL-ACTIVE-BOOT:
442 =: 128MiB
443 format: ext4
444 - ONL-CONFIG:
445 =: 128MiB
446 format: ext4
447 - ONL-IMAGES:
448- =: 1GiB
449+ =: 3GiB
450 format: ext4
451- - ONL-DATA:
452+ - ONL-ACTIVE-DATA:
453+ =: 3GiB
454+ format: ext4
455+ - ONL-STANDBY-BOOT:
456+ =: 128MiB
457+ format: ext4
458+ - ONL-STANDBY-DATA:
459 =: 100%
460 format: ext4
461
462diff --git a/packages/base/all/vendor-config-onl/src/python/onl/bootconfig/__init__.py b/packages/base/all/vendor-config-onl/src/python/onl/bootconfig/__init__.py
463index e85c9ca..2c047be 100755
464--- a/packages/base/all/vendor-config-onl/src/python/onl/bootconfig/__init__.py
465+++ b/packages/base/all/vendor-config-onl/src/python/onl/bootconfig/__init__.py
466@@ -5,7 +5,7 @@ import sys
467 import netaddr
468
469 class OnlBootConfig(object):
470- BOOT_CONFIG_DEFAULT='/mnt/onl/boot/boot-config'
471+ BOOT_CONFIG_DEFAULT='/mnt/onl/active_boot/boot-config'
472
473 def __init__(self):
474 self.keys = {}
475@@ -26,7 +26,7 @@ class OnlBootConfig(object):
476 self._readf(self.BOOT_CONFIG_DEFAULT)
477 else:
478 from onl.mounts import OnlMountContextReadOnly
479- with OnlMountContextReadOnly("ONL-BOOT", logger=None):
480+ with OnlMountContextReadOnly("ONL-ACTIVE-BOOT", logger=None):
481 self._readf(self.BOOT_CONFIG_DEFAULT)
482
483 def set(self, k, v):
484@@ -53,7 +53,8 @@ class OnlBootConfig(object):
485 return True
486 else:
487 from onl.mounts import OnlMountContextReadWrite
488- with OnlMountContextReadWrite("ONL-BOOT", logger=None):
489+ with OnlMountContextReadWrite("ONL-ACTIVE-BOOT", logger=None):
490+
491 if not os.path.exists(self.BOOT_CONFIG_DEFAULT) or force_overwrite:
492 self._writef(self.BOOT_CONFIG_DEFAULT)
493 return True
494diff --git a/packages/base/all/vendor-config-onl/src/python/onl/grub/__init__.py b/packages/base/all/vendor-config-onl/src/python/onl/grub/__init__.py
495index b23b948..7bbca82 100644
496--- a/packages/base/all/vendor-config-onl/src/python/onl/grub/__init__.py
497+++ b/packages/base/all/vendor-config-onl/src/python/onl/grub/__init__.py
498@@ -34,7 +34,7 @@ def onie_fwpkg(arguments):
499 subprocess.check_call("%s/onie/tools/bin/onie-fwpkg %s" % (ob.directory, arguments), shell=True)
500
501 def boot_entry_set(index):
502- with OnlMountContextReadWrite("ONL-BOOT", logger=None) as ob:
503+ with OnlMountContextReadWrite("ONL-ACTIVE-BOOT", logger=None) as ob:
504 subprocess.check_call("/usr/sbin/grub-set-default --boot-directory=%s %d" % (ob.directory, index), shell=True)
505
506 def boot_onie():
507diff --git a/packages/base/all/vendor-config-onl/src/python/onl/install/BaseInstall.py b/packages/base/all/vendor-config-onl/src/python/onl/install/BaseInstall.py
508index 7416c20..0c72c9d 100755
509--- a/packages/base/all/vendor-config-onl/src/python/onl/install/BaseInstall.py
510+++ b/packages/base/all/vendor-config-onl/src/python/onl/install/BaseInstall.py
511@@ -364,30 +364,30 @@ class Base:
512 return 0
513
514 def installBootConfig(self):
515+ devices = ["ONL-ACTIVE-BOOT", "ONL-STANDBY-BOOT"]
516
517- try:
518- dev = self.blkidParts['ONL-BOOT']
519- except IndexError as ex:
520- self.log.warn("cannot find ONL-BOOT partition (maybe raw?) : %s", str(ex))
521- return 1
522-
523- self.log.info("Installing boot-config to %s", dev.device)
524+ for device in devices:
525+ try:
526+ dev = self.blkidParts[device]
527+ except IndexError as ex:
528+ self.log.warn("cannot find ONL-BOOT partition (maybe raw?) : %s", str(ex))
529+ return 1
530
531- basename = 'boot-config'
532- with MountContext(dev.device, log=self.log) as ctx:
533- dst = os.path.join(ctx.dir, basename)
534+ basename = 'boot-config'
535+ with MountContext(dev.device, log=self.log) as ctx:
536+ dst = os.path.join(ctx.dir, basename)
537
538- if not self.installerCopy(basename, dst, True):
539- return
540+ if not self.installerCopy(basename, dst, True):
541+ return
542
543- with open(dst) as fd:
544- buf = fd.read()
545+ with open(dst) as fd:
546+ buf = fd.read()
547
548- ecf = buf.encode('base64', 'strict').strip()
549- if self.im.grub and self.im.grubEnv is not None:
550- setattr(self.im.grubEnv, 'boot_config_default', ecf)
551- if self.im.uboot and self.im.ubootEnv is not None:
552- setattr(self.im.ubootEnv, 'boot-config-default', ecf)
553+ ecf = buf.encode('base64', 'strict').strip()
554+ if self.im.grub and self.im.grubEnv is not None:
555+ setattr(self.im.grubEnv, 'boot_config_default', ecf)
556+ if self.im.uboot and self.im.ubootEnv is not None:
557+ setattr(self.im.ubootEnv, 'boot-config-default', ecf)
558
559 return 0
560
561@@ -503,14 +503,14 @@ if [ "${saved_entry}" ] ; then
562 fi
563
564 menuentry %(boot_menu_entry)s {
565- search --no-floppy --label --set=root ONL-BOOT
566+ search --no-floppy --label --set=root %(boot_partition)s
567 # Always return to this entry by default.
568 set saved_entry="0"
569 save_env saved_entry
570 echo 'Loading %(boot_loading_name)s ...'
571 insmod gzio
572 insmod part_msdos
573- linux /%(kernel)s %(args)s onl_platform=%(platform)s
574+ linux /%(kernel)s %(args)s onl_platform=%(platform)s %(boot_type)s
575 initrd /%(platform)s.cpio.gz
576 }
577
578@@ -693,26 +693,26 @@ class GrubInstaller(SubprocessMixin, Base):
579 initrd = i
580 break
581
582- dev = self.blkidParts['ONL-BOOT']
583+ devices = ["ONL-ACTIVE-BOOT", "ONL-STANDBY-BOOT"]
584+ for device in devices:
585+ dev = self.blkidParts[device]
586
587- self.log.info("Installing kernel to %s", dev.device)
588+ self.log.info("Installing kernel to %s", dev.device)
589
590- with MountContext(dev.device, log=self.log) as ctx:
591- def _cp(b, dstname=None):
592- if dstname is None:
593- dstname = b
594- dst = os.path.join(ctx.dir, dstname)
595- self.installerCopy(b, dst, optional=True)
596- [_cp(e) for e in kernels]
597- _cp(initrd, "%s.cpio.gz" % self.im.installerConf.installer_platform)
598+ with MountContext(dev.device, log=self.log) as ctx:
599+ def _cp(b, dstname=None):
600+ if dstname is None:
601+ dstname = b
602+ dst = os.path.join(ctx.dir, dstname)
603+ self.installerCopy(b, dst, optional=True)
604+ [_cp(e) for e in kernels]
605+ _cp(initrd, "%s.cpio.gz" % self.im.installerConf.installer_platform)
606
607 return 0
608
609 def installGrubCfg(self):
610-
611- dev = self.blkidParts['ONL-BOOT']
612-
613- self.log.info("Installing grub.cfg to %s", dev.device)
614+ device = "ONL-ACTIVE-BOOT"
615+ dev = self.blkidParts[device]
616
617 ctx = {}
618
619@@ -723,6 +723,21 @@ class GrubInstaller(SubprocessMixin, Base):
620 ctx['serial'] = self.im.platformConf['grub']['serial']
621
622 ctx['boot_menu_entry'] = sysconfig.installer.menu_name
623+ cmd = "mkdir /tmp/Test"
624+ os.system(cmd)
625+ cmd = "mount /dev/sda5 /tmp/Test"
626+ os.system(cmd)
627+ with open("upgrade_config", "w") as f:
628+ f.write("root_path=data-active\n")
629+ f.write("boot_path=ONL-ACTIVE-BOOT\n")
630+
631+ cmd = "mv upgrade_config /tmp/Test/upgrade_config"
632+ os.system(cmd)
633+ cmd = "umount /tmp/Test"
634+ os.system(cmd)
635+ ctx['boot_partition'] = "ONL-ACTIVE-BOOT"
636+ ctx['boot_type'] = "data-active"
637+
638 ctx['boot_loading_name'] = sysconfig.installer.os_name
639
640 if self.isUEFI:
641@@ -740,13 +755,12 @@ class GrubInstaller(SubprocessMixin, Base):
642 if not os.path.exists(d):
643 self.makedirs(d)
644 dst = os.path.join(ctx.dir, 'grub/grub.cfg')
645- with open(dst, "w") as fd:
646+ with open(dst, "a") as fd:
647 fd.write(cf)
648
649 return 0
650
651 def installGrub(self):
652- self.log.info("Installing GRUB to %s", self.partedDevice.path)
653 self.im.grubEnv.install(self.partedDevice.path)
654 return 0
655
656@@ -773,11 +787,6 @@ class GrubInstaller(SubprocessMixin, Base):
657 else:
658 self.im.grubEnv.__dict__['espPart'] = None
659
660- self.log.info("Installing to %s starting at partition %d",
661- self.device, self.minpart)
662-
663- self.log.info("disk is %s", self.partedDevice.path)
664-
665 self.log.info("found %s partitions (bsz %s, lbsz %s)",
666 self.partedDisk.type,
667 self.partedDevice.sectorSize,
668@@ -803,7 +812,8 @@ class GrubInstaller(SubprocessMixin, Base):
669
670 # once we assign the ONL-BOOT partition,
671 # we can re-target the grub environment
672- dev = self.blkidParts['ONL-BOOT']
673+
674+ dev = self.blkidParts['ONL-ACTIVE-BOOT']
675 self.im.grubEnv.__dict__['bootPart'] = dev.device
676 self.im.grubEnv.__dict__['bootDir'] = None
677
678@@ -1169,7 +1179,7 @@ class UbootInstaller(SubprocessMixin, UBIfsCreater):
679 self.installerDd(loaderBasename, self.rawLoaderDevice)
680 return 0
681
682- dev = self.blkidParts['ONL-BOOT']
683+ dev = self.blkidParts['ONL-ACTIVE-BOOT']
684 self.log.info("Installing ONL loader %s --> %s:%s...",
685 loaderBasename, dev.device, loaderBasename)
686 with MountContext(dev.device, log=self.log) as ctx:
687diff --git a/packages/base/all/vendor-config-onl/src/python/onl/install/ShellApp.py b/packages/base/all/vendor-config-onl/src/python/onl/install/ShellApp.py
688index 4b363e7..fe268fe 100644
689--- a/packages/base/all/vendor-config-onl/src/python/onl/install/ShellApp.py
690+++ b/packages/base/all/vendor-config-onl/src/python/onl/install/ShellApp.py
691@@ -331,37 +331,38 @@ class Loader(AppBase):
692 PROG = "loader-shell"
693
694 def runGrub(self):
695+ devices = ["ONL-ACTIVE-BOOT", "ONL-STANDBY-BOOT"]
696+ for boot_device in devices:
697+ try:
698+ dev = self.blkid[boot_device].device
699+ except KeyError:
700+ pass
701+ if dev is None:
702+ self.log.error("cannot find GRUB partition %s", dev)
703+ return 1
704+ initrd = self.pc['grub']['initrd']
705+ if type(initrd) == dict: initrd = initrd['=']
706
707- try:
708- dev = self.blkid['ONL-BOOT'].device
709- except KeyError:
710- pass
711- if dev is None:
712- self.log.error("cannot find GRUB partition %s", dev)
713- return 1
714-
715- initrd = self.pc['grub']['initrd']
716- if type(initrd) == dict: initrd = initrd['=']
717+ parts = [p for p in self.pm.mounts if p.device == dev]
718+ if parts:
719+ grubDir = parts[0]
720+ self.log.debug("found loader device %s mounted at %s",
721+ dev, grubDir)
722+ p = os.path.join(grubDir, initrd)
723+ if not os.path.exists(p):
724+ self.log.error("cannot find initrd %s", p)
725+ return 1
726+ self.log.debug("found loader initrd at %s", p)
727+ return self._runInitrdShell(p)
728
729- parts = [p for p in self.pm.mounts if p.device == dev]
730- if parts:
731- grubDir = parts[0]
732- self.log.debug("found loader device %s mounted at %s",
733- dev, grubDir)
734- p = os.path.join(grubDir, initrd)
735- if not os.path.exists(p):
736- self.log.error("cannot find initrd %s", p)
737- return 1
738- self.log.debug("found loader initrd at %s", p)
739- return self._runInitrdShell(p)
740+ with MountContext(dev, log=self.log) as ctx:
741+ p = os.path.join(ctx.dir, initrd)
742+ if not os.path.exists(p):
743+ self.log.error("cannot find initrd %s:%s", dev, p)
744+ return 1
745+ self.log.debug("found loader initrd at %s:%s", dev, p)
746+ return self._runInitrdShell(p)
747
748- with MountContext(dev, log=self.log) as ctx:
749- p = os.path.join(ctx.dir, initrd)
750- if not os.path.exists(p):
751- self.log.error("cannot find initrd %s:%s", dev, p)
752- return 1
753- self.log.debug("found loader initrd at %s:%s", dev, p)
754- return self._runInitrdShell(p)
755
756 def runUboot(self):
757
758@@ -373,7 +374,7 @@ class Loader(AppBase):
759 bootPartno = None
760 for idx, part in enumerate(self.pc['installer']):
761 label, pdata = list(part.items())[0]
762- if label == 'ONL-BOOT':
763+ if label == 'ONL-ACTIVE-BOOT':
764 bootPart = pdata
765 bootPartno = idx + 1
766 break
767@@ -385,7 +386,7 @@ class Loader(AppBase):
768 if fmt == 'raw':
769 bootDevice = dev + str(bootPartno)
770 else:
771- bootDevice = self.blkid['ONL-BOOT'].device
772+ bootDevice = self.blkid['ONL-ACTIVE-BOOT'].device
773
774 # run from a raw partition
775 if fmt == 'raw':
776diff --git a/packages/base/all/vendor-config-onl/src/python/onl/upgrade/loader.py b/packages/base/all/vendor-config-onl/src/python/onl/upgrade/loader.py
777index bf3bbe5..d282f3f 100755
778--- a/packages/base/all/vendor-config-onl/src/python/onl/upgrade/loader.py
779+++ b/packages/base/all/vendor-config-onl/src/python/onl/upgrade/loader.py
780@@ -77,7 +77,8 @@ class LoaderUpgrade_Fit(LoaderUpgradeBase):
781 if fit_image is None:
782 self.abort("The FIT upgrade image is missing. Upgrade cannot continue.")
783
784- with OnlMountContextReadWrite("ONL-BOOT", self.logger) as d:
785+ with OnlMountContextReadWrite("ONL-ACTIVE-BOOT", self.logger) as d:
786+
787 self.copyfile(fit_image, os.path.join(d.directory, "%s.itb" % (self.platform.platform())))
788
789 onlPlatform = onl.platform.current.OnlPlatform()
790@@ -135,7 +136,7 @@ class LoaderUpgrade_x86_64(LoaderUpgradeBase, InstallUtils.SubprocessMixin):
791 X86_64_UPGRADE_DIR=sysconfig.upgrade.loader.package.dir
792 X86_64_UPGRADE_KERNEL_PATTERNS = [ "kernel-*" ]
793
794- with OnlMountContextReadWrite("ONL-BOOT", self.logger) as d:
795+ with OnlMountContextReadWrite("ONL-ACTIVE-BOOT", self.logger) as d:
796 for f in os.listdir(X86_64_UPGRADE_DIR):
797 for pattern in X86_64_UPGRADE_KERNEL_PATTERNS:
798 if fnmatch.fnmatch(f, pattern):
799diff --git a/packages/base/all/vendor-config-onl/src/sbin/uninstall b/packages/base/all/vendor-config-onl/src/sbin/uninstall
800index 79d0d77..93c7fd9 100755
801--- a/packages/base/all/vendor-config-onl/src/sbin/uninstall
802+++ b/packages/base/all/vendor-config-onl/src/sbin/uninstall
803@@ -12,7 +12,7 @@ uninstall_x86_64()
804
805 # Force ONIE boot selection
806 onlfs mount boot --rw
807- echo "default=1" >> /mnt/onl/boot/grub/grub.cfg
808+ echo "default=1" >> /mnt/onl/active_boot/grub/grub.cfg
809
810 else
811 if [ "$1" = "factory" ]; then
Thiyagarajan Subramanie84935d2020-04-23 17:45:44 +0530812diff --git a/tools/switool.py b/tools/switool.py
Humera Kouser9c2bd9f2020-09-25 02:41:29 -0400813index 26eb2fb..6c783c3 100755
Thiyagarajan Subramanie84935d2020-04-23 17:45:44 +0530814--- a/tools/switool.py
815+++ b/tools/switool.py
816@@ -79,6 +79,26 @@ if ops.create or ops.overwrite:
817 swi = OnlSwitchImage(ops.swi, 'w')
818 swi.add_rootfs(ops.rootfs)
819 swi.add_manifest(ops.manifest)
820+
821+ try:
822+ bal_files = []
823+ onl_path = os.environ.get("ONL")
824+ bal_package_path=onl_path+"/bal_packages"
825+ cwd = os.getcwd()
826+ if os.path.isdir(bal_package_path):
827+ os.chdir(bal_package_path)
828+ for root, dirs, files in os.walk(bal_package_path):
829+ for file_name in files:
830+ file_real_path = os.path.realpath(file_name)
831+ bal_files.append(file_real_path)
832+
833+ os.chdir(cwd)
834+ for f_name in bal_files:
835+ print("INFO: File Name - ", f_name)
836+ swi.add(f_name)
837+ except KeyError:
838+ print("Not exist environment value for %s" % "key_maybe_not_exist")
839+
840 for f in ops.add_files:
841 swi.add(f, arcname=f)
Humera Kouser9c2bd9f2020-09-25 02:41:29 -0400842