#!/usr/bin/python
############################################################
import sys
import platform
import argparse
import onl.grub

if platform.machine() != 'x86_64':
   sys.stderr.write("This command can only be used on GRUB-based X86_64 architectures.")
   sys.exit(1)

ap = argparse.ArgumentParser("onl-onie-boot-mode")

ap.add_argument("mode", choices=onl.grub.ONIE_BOOT_MODES)
ap.add_argument("--onie-only", action='store_true', help="Do not set ONIE boot menu option.")

ops = ap.parse_args()

onl.grub.onie_boot_mode_set(ops.mode)

if not ops.onie_only:
   onl.grub.boot_onie()
   print "The system will boot into ONIE %s mode at the next restart." % ops.mode
else:
   print "Mode %s will be selected the next time the system boots into ONIE." % ops.mode









