From d6d89cc3cb27b8fa7e530c2012189e3345afd2b8 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Thu, 17 Nov 2016 19:29:31 +0000 Subject: [PATCH] - onie boot tool access - boot selection --- .../src/python/onl/grub/__init__.py | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 packages/base/all/vendor-config-onl/src/python/onl/grub/__init__.py diff --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 new file mode 100644 index 00000000..2ef7373c --- /dev/null +++ b/packages/base/all/vendor-config-onl/src/python/onl/grub/__init__.py @@ -0,0 +1,35 @@ +from onl.mounts import OnlOnieBootContext, OnlMountContextReadWrite +import subprocess + +ONIE_BOOT_MODES = [ 'install', + 'rescue', + 'uninstall', + 'update', + 'embed', + 'diag', + 'none' + ] + +def onie_boot_mode_set(mode): + if mode not in ONIE_BOOT_MODES: + raise ValueError("%s is not a valid onie boot mode." % mode) + + with OnlOnieBootContext() as ob: + subprocess.check_call("%s/onie/tools/bin/onie-boot-mode -o %s" % (ob.directory, mode), shell=True) + +def onie_fwpkg(arguments): + with OnlOnieBootContext() as ob: + subprocess.check_call("%s/onie/tools/bin/onie-fwpkg %s" % (ob.directory, arguments), shell=True) + +def boot_entry_set(index): + with OnlMountContextReadWrite("ONL-BOOT", logger=None) as ob: + subprocess.check_call("/usr/sbin/grub-set-default --boot-directory=%s %d" % (ob.directory, index), shell=True) + +def boot_onie(): + return boot_entry_set(1) + + + + + +