From b9ddd22e829a83a8e0395c9553c5facb6bfb07b0 Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Thu, 20 Oct 2016 11:59:26 -0700 Subject: [PATCH 01/43] Added UMOUNT tag to suspend cleanup --- .../src/python/onl/install/ShellApp.py | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --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 index c0ff2fa2..19cfaf6f 100644 --- 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 @@ -112,11 +112,16 @@ class Onie(AppBase): PROG = "onie-shell" + UNMOUNT = True + # default, unmount directories once the initrd is extracted + def run(self): self.pm = ProcMountsParser() self.blkid = BlkidParser(log=self.log.getChild("blkid")) self.mtd = ProcMtdParser(log=self.log.getChild("mtd")) + self.dctx = None + self.onieDir = None def _g(d): pat = os.path.join(d, "onie/initrd.img*") @@ -134,22 +139,28 @@ class Onie(AppBase): parts = [p for p in self.pm.mounts if p.device == dev] if parts: - onieDir = parts[0] - self.log.debug("found ONIE boot mounted at %s", onieDir) - initrd = _g(onieDir) + self.log.debug("found ONIE boot mounted at %s", parts[0].dir) + initrd = _g(parts[0].dir) if initrd is None: - self.log.warn("cannot find ONIE initrd on %s", onieDir) + self.log.warn("cannot find ONIE initrd on %s", parts[0].dir) else: + self.onieDir = parts[0].dir self.log.debug("found ONIE initrd at %s", initrd) - return _runInitrdShell(initrd) + return self._runInitrdShell(initrd) - with MountContext(dev, log=self.log) as ctx: - initrd = _g(ctx.dir) + # else, try to mount the directory containing the initrd + with MountContext(dev, log=self.log) as self.dctx: + initrd = _g(self.dctx.dir) if initrd is None: self.log.warn("cannot find ONIE initrd on %s", dev) else: self.log.debug("found ONIE initrd at %s", initrd) - return self._runInitrdShell(initrd) + try: + return self._runInitrdShell(initrd) + finally: + if not self.UMOUNT: + self.onieDir = self.dctx.hostDir + self.dctx.detach() self.log.warn("cannot find an ONIE initrd") return 1 @@ -163,6 +174,7 @@ class Onie(AppBase): self.log.debug("cannot find ONIE initrd on %s (%s)", part.device, part.dir) else: + self.onieDir = part.dir self.log.debug("found ONIE initrd at %s", initrd) return self._runInitrdShell(initrd) From 759b002e4ddf03345cd69a8d1e2f4082d96812c0 Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Thu, 20 Oct 2016 11:59:45 -0700 Subject: [PATCH 02/43] Added attach/detach support --- .../src/python/onl/install/InstallUtils.py | 33 ++++++++++++++++--- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/packages/base/all/vendor-config-onl/src/python/onl/install/InstallUtils.py b/packages/base/all/vendor-config-onl/src/python/onl/install/InstallUtils.py index 830e042e..386f318a 100644 --- a/packages/base/all/vendor-config-onl/src/python/onl/install/InstallUtils.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/install/InstallUtils.py @@ -219,6 +219,9 @@ class MountContext(SubprocessMixin): if not self.device and not self.label: raise ValueError("no device or label specified") + self._detachMounted = False + self._detachHostDir = None + def __enter__(self): dev = self.device if dev is None: @@ -245,7 +248,7 @@ class MountContext(SubprocessMixin): self.mounted = True return self - def __exit__(self, type, value, tb): + def shutdown(self): mounted = False if self.mounted: @@ -263,8 +266,18 @@ class MountContext(SubprocessMixin): if self.hostDir is not None: self.rmdir(self.hostDir) + def __exit__(self, type, value, tb): + self.shutdown() return False + def detach(self): + self.mounted, self._detachMounted = False, self.mounted + self.hostDir, self._detachHostdir = None, self.hostDir + + def attach(self): + self.mounted = self._detachMounted + self.hostDir = self._detachHostdir + class BlkidEntry: def __init__(self, device, **kwargs): @@ -665,6 +678,8 @@ class InitrdContext(SubprocessMixin): self.ilog.setLevel(logging.INFO) self.log = self.hlog + self._detachInitrd = None + def _unpack(self): self.dir = self.mkdtemp(prefix="chroot-", suffix=".d") @@ -783,7 +798,7 @@ class InitrdContext(SubprocessMixin): return self - def __exit__(self, type, value, tb): + def shutdown(self): p = ProcMountsParser() dirs = [e.dir for e in p.mounts if e.dir.startswith(self.dir)] @@ -803,13 +818,21 @@ class InitrdContext(SubprocessMixin): else: self.log.debug("saving chroot in %s", self.dir) + def __exit__(self, type, value, tb): + self.shutdown() return False + def detach(self): + self.initrd, self._detachInitrd = None, self.initrd + + def attach(self): + self.initrd = self._detachInitrd + @classmethod - def mkChroot(self, initrd, log=None): - with InitrdContext(initrd=initrd, log=log) as ctx: + def mkChroot(cls, initrd, log=None): + with cls(initrd=initrd, log=log) as ctx: initrdDir = ctx.dir - ctx.initrd = None + ctx.detach() # save the unpacked directory, do not clean it up # (it's inside this chroot anyway) return initrdDir From d129388145f77045314b238e38ecffd6ba36ba9d Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Thu, 20 Oct 2016 12:00:48 -0700 Subject: [PATCH 03/43] Refactor to use OnieHelper --- .../src/python/onl/install/App.py | 76 ++++++++++++++----- 1 file changed, 59 insertions(+), 17 deletions(-) diff --git a/packages/base/all/vendor-config-onl/src/python/onl/install/App.py b/packages/base/all/vendor-config-onl/src/python/onl/install/App.py index fec1128e..5ab00ed7 100644 --- a/packages/base/all/vendor-config-onl/src/python/onl/install/App.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/install/App.py @@ -17,9 +17,32 @@ import time from InstallUtils import InitrdContext from InstallUtils import SubprocessMixin from InstallUtils import ProcMountsParser +from ShellApp import Onie import ConfUtils, BaseInstall -class App(SubprocessMixin): +class OnieHelper(Onie): + """Unpack the initrd, but keep it around.""" + + UMOUNT = False + # leave self.onieDir mounted + + ictx = None + + def _runInitrdShell(self, initrd): + with InitrdContext(initrd, log=self.log) as self.ictx: + self.initrdDir = self.ictx.dir + self.ictx.detach() + + def shutdown(self): + + self.ictx.attach() + self.ictx.shutdown() + + if self.dctx is not None: + self.dctx.attach() + self.dctx.shutdown() + +class App(SubprocessMixin, object): def __init__(self, url=None, debug=False, force=False, @@ -43,6 +66,8 @@ class App(SubprocessMixin): self.nextUpdate = None + self.onieHelper = None + def run(self): if self.url is not None: @@ -123,27 +148,27 @@ class App(SubprocessMixin): self.log.info("please reboot this system now.") return 0 - def runLocal(self): + def runLocalOrChroot(self): - self.log.info("getting installer configuration") - if os.path.exists(ConfUtils.MachineConf.PATH): - self.machineConf = ConfUtils.MachineConf() - else: - self.log.warn("missing /etc/machine.conf from ONIE runtime") - self.machineConf = ConfUtils.MachineConf(path='/dev/null') - self.installerConf = ConfUtils.InstallerConf() + if self.machineConf is None: + self.log.error("missing machine.conf") + return 1 + if self.installerConf is None: + self.log.error("missing installer.conf") + return 1 ##self.log.info("using native GRUB") ##self.grubEnv = ConfUtils.GrubEnv(log=self.log.getChild("grub")) - pat = "/mnt/onie-boot/onie/initrd.img*" - l = glob.glob(pat) - if l: - initrd = l[0] - self.log.info("using native ONIE initrd+chroot GRUB (%s)", initrd) - initrdDir = InitrdContext.mkChroot(initrd, log=self.log) - self.grubEnv = ConfUtils.ChrootGrubEnv(initrdDir, - bootDir="/mnt/onie-boot", + self.onieHelper = OnieHelper(log=self.log) + code = self.onieHelper.run() + if code: + self.log.warn("cannot find ONIE initrd") + + if self.onieHelper.onieDir is not None: + self.log.info("using native ONIE initrd+chroot GRUB (%s)", self.onieHelper.onieDir) + self.grubEnv = ConfUtils.ChrootGrubEnv(self.onieHelper.initrdDir, + bootDir=self.onieHelper.onieDir, path="/grub/grubenv", log=self.log.getChild("grub")) # direct access using ONIE initrd as a chroot @@ -216,6 +241,19 @@ class App(SubprocessMixin): self.log.info("Install finished.") return 0 + def runLocal(self): + + self.log.info("getting installer configuration") + if os.path.exists(ConfUtils.MachineConf.PATH): + self.machineConf = ConfUtils.MachineConf() + else: + self.log.warn("missing /etc/machine.conf from ONIE runtime") + self.machineConf = ConfUtils.MachineConf(path='/dev/null') + + self.installerConf = ConfUtils.InstallerConf() + + return self.runLocalOrChroot() + def findPlatform(self): plat = arch = None @@ -302,6 +340,10 @@ class App(SubprocessMixin): if installer is not None: installer.shutdown() + h, self.onieHelper = self.onieHelper, None + if h is not None: + h.shutdown() + def post_mortem(self): self.log.info("re-attaching to tty") fdno = os.open("/dev/console", os.O_RDWR) From 08e6bddfbbc4c0674fa82041a7d541fc4227aef3 Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Thu, 20 Oct 2016 12:03:35 -0700 Subject: [PATCH 04/43] WIP parted API updates -- DO NO MERGE --- .../src/python/onl/install/BaseInstall.py | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --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 index eb25aa9f..cf3f299e 100644 --- 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 @@ -21,6 +21,12 @@ from InstallUtils import ProcMountsParser import onl.YamlUtils from onl.sysconfig import sysconfig +try: + PartedException = parted._ped.PartedException +except AttributeError: + import _ped + PartedException = _ped.PartedException + class Base: class installmeta: @@ -382,7 +388,7 @@ class Base: for m in pm.mounts: if m.device.startswith(self.device): if not self.force: - self.log.error("mount %s on %s will be erased by install", + self.log.error("mount %s on %s will be erased by install (try --force)", m.dir, m.device) return 1 else: @@ -668,9 +674,6 @@ class UbootInstaller(SubprocessMixin, Base): self.device = self.im.getDevice() - code = self.assertUnmounted() - if code: return code - self.rawLoaderDevice = None # set to a partition device for raw loader install, # default to None for FS-based install @@ -686,9 +689,12 @@ class UbootInstaller(SubprocessMixin, Base): return 0 self.log.warn("disk %s has wrong label %s", self.device, self.partedDisk.type) - except parted._ped.PartedException as ex: + except PartedException as ex: self.log.error("cannot get partition table from %s: %s", self.device, str(ex)) + except AttributeError as ex: + self.log.error("XXX cannot get partition table from %s: %s", + self.device, str(ex)) self.log.info("creating msdos label on %s") self.partedDisk = parted.freshDisk(self.partedDevice, 'msdos') @@ -727,6 +733,7 @@ class UbootInstaller(SubprocessMixin, Base): break if not loaderBasename: + raise ValueError("platform loader file missing!") self.log.error("The platform loader file is missing.") return 1 @@ -783,6 +790,9 @@ class UbootInstaller(SubprocessMixin, Base): self.log.error("not a block device: %s", self.device) return 1 + code = self.assertUnmounted() + if code: return code + code = self.maybeCreateLabel() if code: return code From c799c398634e83cb7dd4f8e604b006dc558c6e2e Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Mon, 10 Oct 2016 17:42:38 +0000 Subject: [PATCH 05/43] Latest --- packages/platforms-closed | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/platforms-closed b/packages/platforms-closed index 1fe8a60b..60d7d7fd 160000 --- a/packages/platforms-closed +++ b/packages/platforms-closed @@ -1 +1 @@ -Subproject commit 1fe8a60b83155758a44a62b3e6c89bac2bde7769 +Subproject commit 60d7d7fd9abd05ed5c9969ac48ebf40838c93116 From e3030a6a1b83e8d0820715589442eed66236eeee Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Mon, 10 Oct 2016 15:08:19 -0700 Subject: [PATCH 06/43] Latest --- packages/platforms-closed | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/platforms-closed b/packages/platforms-closed index 60d7d7fd..feff1c37 160000 --- a/packages/platforms-closed +++ b/packages/platforms-closed @@ -1 +1 @@ -Subproject commit 60d7d7fd9abd05ed5c9969ac48ebf40838c93116 +Subproject commit feff1c37eb206ac0fc3b8bcb5ab3514b693ed2df From 43c30cf18741eec4de88f2c5eeeb7edd2682a449 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Tue, 11 Oct 2016 20:30:35 +0000 Subject: [PATCH 07/43] The onl-pki script has moved. --- .../all/initrds/loader-initrd-files/src/bin/sysinit | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/packages/base/all/initrds/loader-initrd-files/src/bin/sysinit b/packages/base/all/initrds/loader-initrd-files/src/bin/sysinit index 81d327e0..983b4799 100755 --- a/packages/base/all/initrds/loader-initrd-files/src/bin/sysinit +++ b/packages/base/all/initrds/loader-initrd-files/src/bin/sysinit @@ -91,20 +91,15 @@ if [ ! -f /etc/onl/abort ]; then # Use default boot-config. cp /etc/onl/boot-config-default /etc/onl/boot-config fi - - # - # Initialize the /mnt/flash/boot area. - # - #mkdir -p /mnt/data/boot - #rm -rf /mnt/flash/boot/* fi # # Initialize PKI # -if [ -f /sbin/onl-pki ]; then - /sbin/onl-pki --init +ONL_PKI=/usr/bin/onl-pki +if [ -f "$ONL_PKI" ]; then + "$ONL_PKI" --init fi From d3e977ac0eee7cf231b3753b50a6840088213858 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Wed, 12 Oct 2016 18:41:45 +0000 Subject: [PATCH 08/43] Latest --- sm/bigcode | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sm/bigcode b/sm/bigcode index fb78f3db..19fb14d8 160000 --- a/sm/bigcode +++ b/sm/bigcode @@ -1 +1 @@ -Subproject commit fb78f3dbac61413aec9b88f9dce14369ebaf68cf +Subproject commit 19fb14d8a5424284d2b082b65f4f5a269a587fd5 From 86cedd5babfa28af67ec677b1ea485acc4739ba0 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Thu, 13 Oct 2016 18:03:31 +0000 Subject: [PATCH 09/43] - Improve retry and timeout performance for the isch driver - adm1021 device detection option --- .../drivers-hwmon-adm1021-detect.patch | 29 +++++++++++++++ .../drivers-i2c-busses-i2c-isch-timeout.patch | 36 +++++++++++++++++++ .../kernels/3.2.65-1+deb7u2/patches/series | 2 ++ 3 files changed, 67 insertions(+) create mode 100644 packages/base/any/kernels/3.2.65-1+deb7u2/patches/drivers-hwmon-adm1021-detect.patch create mode 100644 packages/base/any/kernels/3.2.65-1+deb7u2/patches/drivers-i2c-busses-i2c-isch-timeout.patch diff --git a/packages/base/any/kernels/3.2.65-1+deb7u2/patches/drivers-hwmon-adm1021-detect.patch b/packages/base/any/kernels/3.2.65-1+deb7u2/patches/drivers-hwmon-adm1021-detect.patch new file mode 100644 index 00000000..079fb085 --- /dev/null +++ b/packages/base/any/kernels/3.2.65-1+deb7u2/patches/drivers-hwmon-adm1021-detect.patch @@ -0,0 +1,29 @@ +--- a/drivers/hwmon/adm1021.c 2014-12-14 08:24:02.000000000 -0800 ++++ b/drivers/hwmon/adm1021.c 2016-10-13 10:48:10.045055678 -0700 +@@ -105,6 +105,7 @@ static struct adm1021_data *adm1021_upda + /* (amalysh) read only mode, otherwise any limit's writing confuse BIOS */ + static int read_only; + ++static int detect = 1; + + static const struct i2c_device_id adm1021_id[] = { + { "adm1021", adm1021 }, +@@ -295,6 +296,9 @@ static int adm1021_detect(struct i2c_cli + "smbus byte data not supported!\n"); + return -ENODEV; + } ++ if(detect == 0) { ++ return -ENODEV; ++ } + + status = i2c_smbus_read_byte_data(client, ADM1021_REG_STATUS); + conv_rate = i2c_smbus_read_byte_data(client, +@@ -510,6 +514,8 @@ MODULE_LICENSE("GPL"); + + module_param(read_only, bool, 0); + MODULE_PARM_DESC(read_only, "Don't set any values, read only mode"); ++module_param(detect, bool, 1); ++MODULE_PARM_DESC(detect, "Enable or disable device detection."); + + module_init(sensors_adm1021_init) + module_exit(sensors_adm1021_exit) diff --git a/packages/base/any/kernels/3.2.65-1+deb7u2/patches/drivers-i2c-busses-i2c-isch-timeout.patch b/packages/base/any/kernels/3.2.65-1+deb7u2/patches/drivers-i2c-busses-i2c-isch-timeout.patch new file mode 100644 index 00000000..013b3725 --- /dev/null +++ b/packages/base/any/kernels/3.2.65-1+deb7u2/patches/drivers-i2c-busses-i2c-isch-timeout.patch @@ -0,0 +1,36 @@ +--- a/drivers/i2c/busses/i2c-isch.c 2014-12-14 08:24:02.000000000 -0800 ++++ b/drivers/i2c/busses/i2c-isch.c 2016-10-13 08:02:44.564840300 -0700 +@@ -47,7 +47,7 @@ + #define SMBBLKDAT (0x20 + sch_smba) + + /* Other settings */ +-#define MAX_TIMEOUT 500 ++#define MAX_RETRIES 5000 + + /* I2C constants */ + #define SCH_QUICK 0x00 +@@ -68,7 +68,7 @@ static int sch_transaction(void) + { + int temp; + int result = 0; +- int timeout = 0; ++ int retries = 0; + + dev_dbg(&sch_adapter.dev, "Transaction (pre): CNT=%02x, CMD=%02x, " + "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb(SMBHSTCNT), +@@ -100,12 +100,12 @@ static int sch_transaction(void) + outb(inb(SMBHSTCNT) | 0x10, SMBHSTCNT); + + do { +- msleep(1); ++ usleep_range(100, 200); + temp = inb(SMBHSTSTS) & 0x0f; +- } while ((temp & 0x08) && (timeout++ < MAX_TIMEOUT)); ++ } while ((temp & 0x08) && (retries++ < MAX_RETRIES)); + + /* If the SMBus is still busy, we give up */ +- if (timeout > MAX_TIMEOUT) { ++ if (retries > MAX_RETRIES) { + dev_err(&sch_adapter.dev, "SMBus Timeout!\n"); + result = -ETIMEDOUT; + } diff --git a/packages/base/any/kernels/3.2.65-1+deb7u2/patches/series b/packages/base/any/kernels/3.2.65-1+deb7u2/patches/series index 929c0e53..f93799e2 100644 --- a/packages/base/any/kernels/3.2.65-1+deb7u2/patches/series +++ b/packages/base/any/kernels/3.2.65-1+deb7u2/patches/series @@ -251,3 +251,5 @@ platform-accton-as7716_32x-device-drivers.patch driver-broadcom-tigon3.patch mgmt-port-init-config.patch arch-intel-reboot-cf9-cold.patch +drivers-hwmon-adm1021-detect.patch +drivers-i2c-busses-i2c-isch-timeout.patch From bc4d2e6f97b8908dbd627eb4386a190add6323e5 Mon Sep 17 00:00:00 2001 From: Zi Zhou Date: Thu, 13 Oct 2016 17:19:31 -0700 Subject: [PATCH 10/43] Do not show CRC under System Information for "show version" --- .../base/all/vendor-config-onl/src/python/onl/platform/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py b/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py index 19f6be9d..f9e0e20e 100644 --- a/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py @@ -45,7 +45,7 @@ class OnlInfoObject(object): @staticmethod def string(d, indent=DEFAULT_INDENT): - return "\n".join( sorted("%s%s: %s" % (indent,k,v) for k,v in d.iteritems() if not k.startswith('_') and d[k] is not None) ) + return "\n".join( sorted("%s%s: %s" % (indent,k,v) for k,v in d.iteritems() if not k.startswith('_') and d[k] is not None and k != 'CRC')) ############################################################ From ac03653c5f94618a11a397fdc6203d75ac53678a Mon Sep 17 00:00:00 2001 From: Steven Noble Date: Thu, 13 Oct 2016 20:44:31 -0700 Subject: [PATCH 11/43] Kernel configuration options and updated at24 patch for kernel 3.16 --- .../configs/x86_64-all/x86_64-all.config | 29 ++++++++++++- ...-at24-fix-odd-length-two-byte-access.patch | 43 +++++++------------ 2 files changed, 43 insertions(+), 29 deletions(-) diff --git a/packages/base/any/kernels/3.16+deb8/configs/x86_64-all/x86_64-all.config b/packages/base/any/kernels/3.16+deb8/configs/x86_64-all/x86_64-all.config index 7a66710e..8546a1f2 100644 --- a/packages/base/any/kernels/3.16+deb8/configs/x86_64-all/x86_64-all.config +++ b/packages/base/any/kernels/3.16+deb8/configs/x86_64-all/x86_64-all.config @@ -818,6 +818,7 @@ CONFIG_NETFILTER_XT_TARGET_DSCP=y CONFIG_NETFILTER_XT_TARGET_HL=y CONFIG_NETFILTER_XT_TARGET_HMARK=y CONFIG_NETFILTER_XT_TARGET_IDLETIMER=y +# CONFIG_NETFILTER_XT_TARGET_LED is not set CONFIG_NETFILTER_XT_TARGET_LOG=y CONFIG_NETFILTER_XT_TARGET_MARK=y CONFIG_NETFILTER_XT_TARGET_NETMAP=y @@ -2116,7 +2117,18 @@ CONFIG_SENSORS_LM90=y # CONFIG_SENSORS_NCT6683 is not set # CONFIG_SENSORS_NCT6775 is not set # CONFIG_SENSORS_PCF8591 is not set -# CONFIG_PMBUS is not set +CONFIG_PMBUS=y +CONFIG_SENSORS_PMBUS=y +# CONFIG_SENSORS_ADM1275 is not set +# CONFIG_SENSORS_LM25066 is not set +# CONFIG_SENSORS_LTC2978 is not set +# CONFIG_SENSORS_MAX16064 is not set +# CONFIG_SENSORS_MAX34440 is not set +CONFIG_SENSORS_DNI_DPS460=y +# CONFIG_SENSORS_MAX8688 is not set +# CONFIG_SENSORS_UCD9000 is not set +CONFIG_SENSORS_UCD9200=y +# CONFIG_SENSORS_ZL6100 is not set # CONFIG_SENSORS_SHT15 is not set # CONFIG_SENSORS_SHT21 is not set # CONFIG_SENSORS_SHTC1 is not set @@ -2648,7 +2660,20 @@ CONFIG_LEDS_CLASS=y # # LED Triggers # -# CONFIG_LEDS_TRIGGERS is not set +CONFIG_LEDS_TRIGGERS=y +CONFIG_LEDS_TRIGGER_TIMER=y +# CONFIG_LEDS_TRIGGER_ONESHOT is not set +# CONFIG_LEDS_TRIGGER_HEARTBEAT is not set +# CONFIG_LEDS_TRIGGER_BACKLIGHT is not set +# CONFIG_LEDS_TRIGGER_CPU is not set +CONFIG_LEDS_TRIGGER_GPIO=y +# CONFIG_LEDS_TRIGGER_DEFAULT_ON is not set + +# +# iptables trigger is under Netfilter config (LED target) +# +# CONFIG_LEDS_TRIGGER_TRANSIENT is not set +# CONFIG_LEDS_TRIGGER_CAMERA is not set # CONFIG_ACCESSIBILITY is not set # CONFIG_INFINIBAND is not set # CONFIG_EDAC is not set diff --git a/packages/base/any/kernels/3.16+deb8/patches/driver-at24-fix-odd-length-two-byte-access.patch b/packages/base/any/kernels/3.16+deb8/patches/driver-at24-fix-odd-length-two-byte-access.patch index 709220f3..6060b15e 100644 --- a/packages/base/any/kernels/3.16+deb8/patches/driver-at24-fix-odd-length-two-byte-access.patch +++ b/packages/base/any/kernels/3.16+deb8/patches/driver-at24-fix-odd-length-two-byte-access.patch @@ -1,29 +1,18 @@ -driver at24 fix odd length two byte access - -From: Cumulus Networks - -For I2C_SMBUS_WORD_DATA read accesses check if the access length is -one or two bytes. For transactions that have an odd length eventualy -we read 1 byte at the end to complete the request. - -The previous code always used a count of 2, which works fine if the -requested total length is even. If the requested length was odd, -however, the code would cause a kernel OOPS. - -The while (count) loop would go forever as count went from 1 to -1, -never becoming zero. Also the return buffer would overrun. - -This patch allows for reading an odd number of bytes in -I2C_SMBUS_WORD_DATA mode. ---- - drivers/misc/eeprom/at24.c | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c -index d87f77f..9e9256a 100644 ---- a/drivers/misc/eeprom/at24.c -+++ b/drivers/misc/eeprom/at24.c -@@ -192,7 +192,8 @@ static ssize_t at24_eeprom_read(struct at24_data *at24, char *buf, +--- a/drivers/misc/eeprom/at24.c 2016-10-06 12:45:49.290365545 +0000 ++++ b/drivers/misc/eeprom/at24.c 2016-10-06 12:47:08.630368526 +0000 +@@ -84,9 +84,9 @@ + * + * This value is forced to be a power of two so that writes align on pages. + */ +-static unsigned io_limit = 128; ++static unsigned io_limit = 32; + module_param(io_limit, uint, 0); +-MODULE_PARM_DESC(io_limit, "Maximum bytes per I/O (default 128)"); ++MODULE_PARM_DESC(io_limit, "Maximum bytes per I/O (default 32)"); + + /* + * Specs often allow 5 msec for a page write, sometimes 20 msec; +@@ -192,7 +192,8 @@ count = I2C_SMBUS_BLOCK_MAX; break; case I2C_SMBUS_WORD_DATA: @@ -33,7 +22,7 @@ index d87f77f..9e9256a 100644 break; case I2C_SMBUS_BYTE_DATA: count = 1; -@@ -237,7 +238,8 @@ static ssize_t at24_eeprom_read(struct at24_data *at24, char *buf, +@@ -237,7 +238,8 @@ status = i2c_smbus_read_word_data(client, offset); if (status >= 0) { buf[0] = status & 0xff; From 05ef1f19b4392c2bd551c37c7959bfe11a9e6cc9 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Fri, 14 Oct 2016 18:07:35 +0000 Subject: [PATCH 12/43] Latest --- packages/platforms-closed | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/platforms-closed b/packages/platforms-closed index feff1c37..fe6a4b28 160000 --- a/packages/platforms-closed +++ b/packages/platforms-closed @@ -1 +1 @@ -Subproject commit feff1c37eb206ac0fc3b8bcb5ab3514b693ed2df +Subproject commit fe6a4b286335b1a286e41c562cff4a95a5497c2c From 7c3d3a2c3bb6516d04c7f46a9bded26415d8cd05 Mon Sep 17 00:00:00 2001 From: Sridhar Pitchai Date: Fri, 14 Oct 2016 16:36:45 -0700 Subject: [PATCH 13/43] Platform x86-64-agema-agc7648 without ONLP (#113) --- packages/platforms/agema/Makefile | 1 + .../platforms/agema/vendor-config/Makefile | 1 + .../platforms/agema/vendor-config/PKG.yml | 1 + .../src/python/agema/__init__.py | 7 ++++ packages/platforms/agema/x86-64/Makefile | 1 + .../x86-64/x86-64-agema-agc7648/Makefile | 1 + .../x86-64/x86-64-agema-agc7648/onlp/Makefile | 1 + .../x86-64/x86-64-agema-agc7648/onlp/PKG.yml | 15 ++++++++ .../platform-config/Makefile | 1 + .../platform-config/r0/Makefile | 1 + .../platform-config/r0/PKG.yml | 1 + .../r0/src/lib/x86-64-agc7648-r0.yml | 35 +++++++++++++++++++ .../src/python/x86_64_agc7648_r0/__init__.py | 8 +++++ 13 files changed, 74 insertions(+) create mode 100644 packages/platforms/agema/Makefile create mode 100644 packages/platforms/agema/vendor-config/Makefile create mode 100644 packages/platforms/agema/vendor-config/PKG.yml create mode 100644 packages/platforms/agema/vendor-config/src/python/agema/__init__.py create mode 100644 packages/platforms/agema/x86-64/Makefile create mode 100644 packages/platforms/agema/x86-64/x86-64-agema-agc7648/Makefile create mode 100644 packages/platforms/agema/x86-64/x86-64-agema-agc7648/onlp/Makefile create mode 100644 packages/platforms/agema/x86-64/x86-64-agema-agc7648/onlp/PKG.yml create mode 100644 packages/platforms/agema/x86-64/x86-64-agema-agc7648/platform-config/Makefile create mode 100644 packages/platforms/agema/x86-64/x86-64-agema-agc7648/platform-config/r0/Makefile create mode 100644 packages/platforms/agema/x86-64/x86-64-agema-agc7648/platform-config/r0/PKG.yml create mode 100644 packages/platforms/agema/x86-64/x86-64-agema-agc7648/platform-config/r0/src/lib/x86-64-agc7648-r0.yml create mode 100644 packages/platforms/agema/x86-64/x86-64-agema-agc7648/platform-config/r0/src/python/x86_64_agc7648_r0/__init__.py diff --git a/packages/platforms/agema/Makefile b/packages/platforms/agema/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/agema/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/agema/vendor-config/Makefile b/packages/platforms/agema/vendor-config/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/agema/vendor-config/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/agema/vendor-config/PKG.yml b/packages/platforms/agema/vendor-config/PKG.yml new file mode 100644 index 00000000..9cc81777 --- /dev/null +++ b/packages/platforms/agema/vendor-config/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-config-vendor.yml VENDOR=agema Vendor=Agema diff --git a/packages/platforms/agema/vendor-config/src/python/agema/__init__.py b/packages/platforms/agema/vendor-config/src/python/agema/__init__.py new file mode 100644 index 00000000..5e56e4a9 --- /dev/null +++ b/packages/platforms/agema/vendor-config/src/python/agema/__init__.py @@ -0,0 +1,7 @@ +#!/usr/bin/python + +from onl.platform.base import * + +class OnlPlatformAgema(OnlPlatformBase): + MANUFACTURER='Agema' + PRIVATE_ENTERPRISE_NUMBER=65530 diff --git a/packages/platforms/agema/x86-64/Makefile b/packages/platforms/agema/x86-64/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/agema/x86-64/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/agema/x86-64/x86-64-agema-agc7648/Makefile b/packages/platforms/agema/x86-64/x86-64-agema-agc7648/Makefile new file mode 100644 index 00000000..dc1e7b86 --- /dev/null +++ b/packages/platforms/agema/x86-64/x86-64-agema-agc7648/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk diff --git a/packages/platforms/agema/x86-64/x86-64-agema-agc7648/onlp/Makefile b/packages/platforms/agema/x86-64/x86-64-agema-agc7648/onlp/Makefile new file mode 100644 index 00000000..dc1e7b86 --- /dev/null +++ b/packages/platforms/agema/x86-64/x86-64-agema-agc7648/onlp/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk diff --git a/packages/platforms/agema/x86-64/x86-64-agema-agc7648/onlp/PKG.yml b/packages/platforms/agema/x86-64/x86-64-agema-agc7648/onlp/PKG.yml new file mode 100644 index 00000000..46f47033 --- /dev/null +++ b/packages/platforms/agema/x86-64/x86-64-agema-agc7648/onlp/PKG.yml @@ -0,0 +1,15 @@ +variables: + platform: x86-64-agc7648-r0 + install: /lib/platform-config/${platform}/onl + +common: + version: 1.0.0 + arch: amd64 + copyright: Copyright 2013, 2014, 2015 Big Switch Networks + maintainer: support@bigswitch.com + comment: dummy package for ONLP on Wedge +packages: + - name: onlp-${platform} + summary: ONLP Package for the ${platform} platform. + + changelog: initial version diff --git a/packages/platforms/agema/x86-64/x86-64-agema-agc7648/platform-config/Makefile b/packages/platforms/agema/x86-64/x86-64-agema-agc7648/platform-config/Makefile new file mode 100644 index 00000000..dc1e7b86 --- /dev/null +++ b/packages/platforms/agema/x86-64/x86-64-agema-agc7648/platform-config/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk diff --git a/packages/platforms/agema/x86-64/x86-64-agema-agc7648/platform-config/r0/Makefile b/packages/platforms/agema/x86-64/x86-64-agema-agc7648/platform-config/r0/Makefile new file mode 100644 index 00000000..dc1e7b86 --- /dev/null +++ b/packages/platforms/agema/x86-64/x86-64-agema-agc7648/platform-config/r0/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk diff --git a/packages/platforms/agema/x86-64/x86-64-agema-agc7648/platform-config/r0/PKG.yml b/packages/platforms/agema/x86-64/x86-64-agema-agc7648/platform-config/r0/PKG.yml new file mode 100644 index 00000000..e1d73496 --- /dev/null +++ b/packages/platforms/agema/x86-64/x86-64-agema-agc7648/platform-config/r0/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=agema PLATFORM=x86-64-agc7648-r0 diff --git a/packages/platforms/agema/x86-64/x86-64-agema-agc7648/platform-config/r0/src/lib/x86-64-agc7648-r0.yml b/packages/platforms/agema/x86-64/x86-64-agema-agc7648/platform-config/r0/src/lib/x86-64-agc7648-r0.yml new file mode 100644 index 00000000..79300f3f --- /dev/null +++ b/packages/platforms/agema/x86-64/x86-64-agema-agc7648/platform-config/r0/src/lib/x86-64-agc7648-r0.yml @@ -0,0 +1,35 @@ +--- + +###################################################################### +# +# platform-config for x86_64-agc7648-r0 +# +# +###################################################################### + +x86-64-agc7648-r0: + + grub: + + serial: >- + --port=0x3f8 + --speed=115200 + --word=8 + --parity=0 + --stop=1 + + kernel: + <<: *kernel-3-18 + + args: >- + nopat + console=ttyS0,57600n8 + rd_NO_MD + rd_NO_LUKS + intel_iommu=off + + ##network + ## interfaces: + ## ma1: + ## name: ~ + ## syspath: pci0000:00/0000:00:14.0 diff --git a/packages/platforms/agema/x86-64/x86-64-agema-agc7648/platform-config/r0/src/python/x86_64_agc7648_r0/__init__.py b/packages/platforms/agema/x86-64/x86-64-agema-agc7648/platform-config/r0/src/python/x86_64_agc7648_r0/__init__.py new file mode 100644 index 00000000..15e7d82b --- /dev/null +++ b/packages/platforms/agema/x86-64/x86-64-agema-agc7648/platform-config/r0/src/python/x86_64_agc7648_r0/__init__.py @@ -0,0 +1,8 @@ +from onl.platform.base import * +from onl.platform.accton import * + +class OnlPlatform_x86_64_agc7648_r0(OnlPlatformAgema, + OnlPlatformPortConfig_48x10_6x40): + MODEL="agc7648" + PLATFORM="x86-64-agc7648-r0" + SYS_OBJECT_ID=".7648.1" From 09a4d38fa8b2a0bc12c68bdd73ec2e1f9b99e48f Mon Sep 17 00:00:00 2001 From: Charlie Lewis Date: Fri, 14 Oct 2016 16:37:51 -0700 Subject: [PATCH 14/43] improve formatting of markdown for readibility (#108) --- docs/Building.md | 49 +++++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/docs/Building.md b/docs/Building.md index e66ab7ad..693f83b5 100644 --- a/docs/Building.md +++ b/docs/Building.md @@ -41,17 +41,17 @@ If you would like to build by hand you can do the following: #> git clone https://github.com/opencomputeproject/OpenNetworkLinux #> cd OpenNetworkLinux - #> docker/tools/onlbuilder (-8) # enter the docker workspace + #> docker/tools/onlbuilder (-8) # enter the docker workspace #> apt-cacher-ng - #> source setup.env # pull in necessary environment variables + #> source setup.env # pull in necessary environment variables #> make amd64 ppc # make onl for $platform (currently amd64 or powerpc) The resulting ONIE installers are in -$ONL/RELEASE/$SUITE/$ARCH/ONL-2.*INSTALLER, i.e. -RELEASE/jessie/amd64/ONL-2.0.0_ONL-OS_2015-12-12.0252-ffce159_AMD64_INSTALLER +`$ONL/RELEASE/$SUITE/$ARCH/ONL-2.*INSTALLER`, i.e. +`RELEASE/jessie/amd64/ONL-2.0.0_ONL-OS_2015-12-12.0252-ffce159_AMD64_INSTALLER` and the SWI files (if you want them) are in -$ONL/RELEASE/$SUITE/$ARCH/ONL*.swi. i.e. -RELEASE/jessie/amd64/ONL-2.0.0_ONL-OS_2015-12-12.0252-ffce159_AMD64.swi +`$ONL/RELEASE/$SUITE/$ARCH/ONL*.swi`. i.e. +`RELEASE/jessie/amd64/ONL-2.0.0_ONL-OS_2015-12-12.0252-ffce159_AMD64.swi` @@ -69,13 +69,13 @@ Common docker related issues: - Beware that `apt-get install docker` installs a dock application not docker :-) You want the lxc-docker package instead. - Some versions of docker are unhappy if you use a local DNS caching resolver: - e.g., you have 127.0.0.1 in your /etc/resolv.conf - - if you have this, specify DNS="--dns 8.8.8.8" when you enter the docker environment + - if you have this, specify `DNS="--dns 8.8.8.8"` when you enter the docker environment - e.g., `make DNS="--dns 8.8.8.8" docker` Consider enabling builds for non-privileged users with: - `sudo usermod -aG docker $USER` -- If you run as non-root without this, you will get errors like "..: dial unix /var/run/docker.sock: permission denied" +- If you run as non-root without this, you will get errors like `..: dial unix /var/run/docker.sock: permission denied` - Building as root is fine as well (it immediately jumps into a root build shell), so this optional #Additional Build Details @@ -134,43 +134,47 @@ Example setup on new Debian 8.2 installation Install sudo and add yourself to the sudoers: As root: - +``` apt-get install sudo - vi /etc/sudoers.d/username +``` Add the line: - +``` username ALL=(ALL:ALL) ALL +``` Add the docker key: - +``` sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D gpg: key 2C52609D: public key "Docker Release Tool (releasedocker) " imported gpg: Total number processed: 1 gpg: imported: 1 (RSA: 1) +``` Install necessary items, make, binfmt-support and apt-transport-https (for docker): - +``` sudo apt-get install apt-transport-https make binfmt-support +``` Add the docker repository to your system: - +``` sudo vi /etc/apt/sources.list.d/docker.list - +``` Add the following line to the file: - +``` deb https://apt.dockerproject.org/repo debian-jessie main +``` Install Docker: - +``` sudo apt-get update - sudo apt-get install docker-engine +``` Test Docker: - +``` sudo docker run hello-world Unable to find image 'hello-world:latest' locally @@ -182,21 +186,24 @@ Status: Downloaded newer image for hello-world:latest Hello from Docker. This message shows that your installation appears to be working correctly. +``` Add yourself to the docker group: - +``` sudo gpasswd -a snoble docker Adding user snoble to group docker +``` logout and log back in for the group to take effect: Clone the OpenNetworkLinux repository: - +``` git clone https://github.com/opencomputeproject/OpenNetworkLinux.git Cloning into 'OpenNetworkLinux'... Checking connectivity... done. +``` Build OpenNetworkLinux: From fad2b5cd8260895005573183150e1cc9b2ebbc72 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Tue, 18 Oct 2016 11:30:47 -0700 Subject: [PATCH 15/43] Latest --- packages/platforms-closed | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/platforms-closed b/packages/platforms-closed index fe6a4b28..5ae11894 160000 --- a/packages/platforms-closed +++ b/packages/platforms-closed @@ -1 +1 @@ -Subproject commit fe6a4b286335b1a286e41c562cff4a95a5497c2c +Subproject commit 5ae11894fd5667434ad8ce5e7ae4b17eaf06567b From c87583271817f1b867709a1ec788a186f32cf23e Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Wed, 19 Oct 2016 14:54:11 +0000 Subject: [PATCH 16/43] Generalize to all exceptions. --- .../vendor-config-onl/src/python/onl/install/BaseInstall.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --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 index cf3f299e..27286acc 100644 --- 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 @@ -692,9 +692,9 @@ class UbootInstaller(SubprocessMixin, Base): except PartedException as ex: self.log.error("cannot get partition table from %s: %s", self.device, str(ex)) - except AttributeError as ex: - self.log.error("XXX cannot get partition table from %s: %s", - self.device, str(ex)) + except Error as ex: + self.log.exception("cannot get partition table from %s" + self.device) self.log.info("creating msdos label on %s") self.partedDisk = parted.freshDisk(self.partedDevice, 'msdos') From 31738e8855f58552c884914df6719ae843a1f3e1 Mon Sep 17 00:00:00 2001 From: Steven Noble Date: Wed, 19 Oct 2016 10:14:43 -0700 Subject: [PATCH 17/43] Updates docs for Wedge to include Wedge 100 (#115) --- docs/Building.md | 8 ++++---- docs/GettingStartedWedge.md | 31 ++++++++++++++++++++++--------- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/docs/Building.md b/docs/Building.md index 693f83b5..f4c02f7a 100644 --- a/docs/Building.md +++ b/docs/Building.md @@ -105,8 +105,8 @@ Adding/Removing packages from a SWI: The list of packages for a given SWI are in - $ONL/packages/base/any/rootfs/common/$ARCH-packages.yml # for $ARCH specific packages - $ONL/packages/base/any/rootfs/common/common-packages.yml # for $ARCH-independent packages + $ONL/packages/base/any/rootfs/$suite/common/$ARCH-packages.yml # for $ARCH specific packages + $ONL/packages/base/any/rootfs/$suite/common/common-packages.yml # for $ARCH-independent packages Build a software image (SWI) for all powerpc platforms: ------------------------------------------------------------ @@ -190,9 +190,9 @@ This message shows that your installation appears to be working correctly. Add yourself to the docker group: ``` -sudo gpasswd -a snoble docker +sudo gpasswd -a user1 docker -Adding user snoble to group docker +Adding user user1 to group docker ``` logout and log back in for the group to take effect: diff --git a/docs/GettingStartedWedge.md b/docs/GettingStartedWedge.md index 42fe39c9..2bfcd926 100644 --- a/docs/GettingStartedWedge.md +++ b/docs/GettingStartedWedge.md @@ -9,17 +9,20 @@ Once installed, ONL has a default account ("root") with a default password the root password before the system comes up. You will need to enable the network interface before you can run the FBOSS agent. -FBOSS is installed and set to run the configuration created for a OCP ONL +On the Wedge 40 FBOSS is installed and set to run the configuration created for a OCP ONL on Wedge Demo. This configuration sets up the first physical QSFP port of the wedge as 4 10G ports (via a break out cable) and configures vlans and ip addresses on them. +On the Wedge 100 FBOSS is installed and set to run a generic configuration that breaks all +ports into 25G (each 100G port is broken into 4 ports for a total of 128 ports) + ONIE Manual Install ------------------------------------------------ If your Accton Wedge does not have ONIE installed, you will need to install it before you can proceed. -1) Download the ONIE rescue image from http://opennetlinux.org/binaries/accton-wedge/onie-recovery-x86_64-accton_wedge_16x-r0.iso +1) Download the ONIE rescue image for the Wedge 40 from http://opennetlinux.org/binaries/accton-wedge/onie-recovery-x86_64-accton_wedge_16x-r0.iso for the Wedge 100 it is http://opennetlinux.org/binaries/accton-wedge/onie-recovery-x86-64-facebook-wedge100-r0.iso 2) Burn the image onto a USB (a USB with a minimum size of 256M is necessary) @@ -40,8 +43,8 @@ configuration menu linux installation, you will need to either reboot (if possible) or hit ctrl-x, exiting to the BMC and issue the "wedge_power reset" command to power-cycle the microserver, run sol.sh again and hit F2 when the BIOS status screen appears -10) One you are in the BIOS configuration, move to the boot screen and change -the boot mode from UEFI to Legacy +10) For the Wedge 40 Once you are in the BIOS configuration, move to the boot screen and change +the boot mode from UEFI to Legacy. For the Wedge 100 you will choose the non UEFI version of your USB disk. 11) In the boot device list, make sure that the USB is set to #1 @@ -56,13 +59,15 @@ reboot 16) *IMPORTANT* Remove the USB from the system before proceeding to the ONL install +17) On the Wedge 100 go back into the BIOS and set device P0 to be the main boot drive. + ONL Manual Install ------------------------------------------------ 1) Attach a serial terminal to the wedge 2) Boot switch and choose "ONIE: Rescue" to go to ONIE''s interactive mode -3) From the ONIE# prompt run "install_url http://opennetlinux.org/binaries/latest-wedge-2.0.installer" +3) From the ONIE# prompt run "install_url http://opennetlinux.org/binaries/latest-DEB8-AMD64-installed.installer" 4) Wait for the install to finish and the system to reboot @@ -72,18 +77,23 @@ password "onl" 6) Configure the ma1 interface either via dhcp (dhclient ma1) or manually 7) Install fboss using the commands - + + For the Wedge 40 #> apt-get update #> apt-get install fboss + Or for the Wedge 100 + #> apt-get install fboss-w100 + 8) From the command prompt you can start fboss by using the command "service fboss_wedge_agent start" -9) The first time you start the fboss_wedge_agent service it will download -the OpenNSL library from the Broadcom github account. +9) On the Wedge 40 The first time you start the fboss_wedge_agent service it will download +the OpenNSL library from the Broadcom github account. On the Wedge 100, it OpenNSL is included +as a package. 10) Once the library is installed, fboss_wedge_agent will start, using the -default configuration located at /etc/fboss/ocp-demo.json +default configuration located at /etc/fboss/ocp-demo.json for the Wedge 40 or /etc/fboss/sample_config.json for the Wedge 100 11) You can confirm that the fboss_wedge_agent is running by issuing the command "service fboss_wedge_agent status" @@ -94,6 +104,9 @@ command "service fboss_wedge_agent status" Modifying The fboss_wedge_agent configuration ------------------------------------------------ + +The rest of this document is based on the Wedge 40 but the Wedge 100 is similar. + In the /etc/init.d/fboss_wedge_agent script, you will locate a section where the configuration file "FBOSS_DAEMON_OPTIONS" is set: From db0790fac81674b5807b6c505ab37549285a8bbe Mon Sep 17 00:00:00 2001 From: Sridhar Pitchai Date: Wed, 19 Oct 2016 10:15:03 -0700 Subject: [PATCH 18/43] Platform x86-64-alphanetworks-snx60a0-486f-r0 (#114) Fixing the console port --- .../r0/src/lib/x86-64-alphanetworks-snx60a0-486f-r0.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/platforms/alphanetworks/x86-64-alphanetworks-snx60a0-486f/platform-config/r0/src/lib/x86-64-alphanetworks-snx60a0-486f-r0.yml b/packages/platforms/alphanetworks/x86-64-alphanetworks-snx60a0-486f/platform-config/r0/src/lib/x86-64-alphanetworks-snx60a0-486f-r0.yml index d55b1cc0..abd98158 100644 --- a/packages/platforms/alphanetworks/x86-64-alphanetworks-snx60a0-486f/platform-config/r0/src/lib/x86-64-alphanetworks-snx60a0-486f-r0.yml +++ b/packages/platforms/alphanetworks/x86-64-alphanetworks-snx60a0-486f/platform-config/r0/src/lib/x86-64-alphanetworks-snx60a0-486f-r0.yml @@ -10,7 +10,7 @@ x86-64-alphanetworks-snx60a0-486f-r0: grub: serial: >- - --port=0x3f8 + --port=0x2f8 --speed=115200 --word=8 --parity=no @@ -21,5 +21,4 @@ x86-64-alphanetworks-snx60a0-486f-r0: args: >- nopat - console=ttyS0,115200n8 - + console=ttyS1,115200n8 From 079765bf8593d2f0ce91aee90b5e71b4635156ce Mon Sep 17 00:00:00 2001 From: Steven Noble Date: Wed, 19 Oct 2016 21:51:01 -0700 Subject: [PATCH 19/43] Updates the Wedge 40 and 100 systems to use the 3.16 kernel (#117) --- .../platform-config/r0/src/lib/x86-64-accton-wedge-16x-r0.yml | 2 +- .../platform-config/r0/src/lib/x86-64-facebook-wedge100-r0.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge-16x/platform-config/r0/src/lib/x86-64-accton-wedge-16x-r0.yml b/packages/platforms/accton/x86-64/x86-64-accton-wedge-16x/platform-config/r0/src/lib/x86-64-accton-wedge-16x-r0.yml index 133874d1..17765a92 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-wedge-16x/platform-config/r0/src/lib/x86-64-accton-wedge-16x-r0.yml +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge-16x/platform-config/r0/src/lib/x86-64-accton-wedge-16x-r0.yml @@ -18,7 +18,7 @@ x86-64-accton-wedge-16x-r0: --stop=1 kernel: - <<: *kernel-3-18 + <<: *kernel-3-16 args: >- nopat diff --git a/packages/platforms/accton/x86-64/x86-64-facebook-wedge100/platform-config/r0/src/lib/x86-64-facebook-wedge100-r0.yml b/packages/platforms/accton/x86-64/x86-64-facebook-wedge100/platform-config/r0/src/lib/x86-64-facebook-wedge100-r0.yml index fdcbd263..c80d99e7 100644 --- a/packages/platforms/accton/x86-64/x86-64-facebook-wedge100/platform-config/r0/src/lib/x86-64-facebook-wedge100-r0.yml +++ b/packages/platforms/accton/x86-64/x86-64-facebook-wedge100/platform-config/r0/src/lib/x86-64-facebook-wedge100-r0.yml @@ -18,7 +18,7 @@ x86-64-facebook-wedge100-r0: --stop=1 kernel: - <<: *kernel-3-18 + <<: *kernel-3-16 args: >- nopat From 1c12aa5189615854d6b318b2d4943cb9e57c7d95 Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Mon, 24 Oct 2016 13:11:02 -0700 Subject: [PATCH 20/43] Added serialization function --- .../src/python/onl/install/ConfUtils.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/base/all/vendor-config-onl/src/python/onl/install/ConfUtils.py b/packages/base/all/vendor-config-onl/src/python/onl/install/ConfUtils.py index b81fd347..4f2a831c 100644 --- a/packages/base/all/vendor-config-onl/src/python/onl/install/ConfUtils.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/install/ConfUtils.py @@ -7,6 +7,7 @@ import os import logging import subprocess from InstallUtils import SubprocessMixin, ChrootSubprocessMixin, MountContext +from cStringIO import StringIO class ConfBase: @@ -45,6 +46,14 @@ class ConfBase: def __setattr__(self, attr, val): self.__dict__['_data'][attr] = val + def dumps(self): + """Generate a serialized representation.""" + buf = StringIO() + data = self.__dict__.get('_data', {}) + for key, val in data.iteritems(): + buf.write("%s=\"%s\"\n" % (key, val,)) + return buf.getvalue() + class ConfFileBase(ConfBase): PATH = None From ead42bc86044d92b8261fda8719a5bff28d0db2f Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Mon, 24 Oct 2016 13:11:21 -0700 Subject: [PATCH 21/43] Added upgrade-shell --- .../vendor-config-onl/src/bin/upgrade-shell | 7 +++ .../src/python/onl/install/ShellApp.py | 48 ++++++++++++++++++- 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100755 packages/base/all/vendor-config-onl/src/bin/upgrade-shell diff --git a/packages/base/all/vendor-config-onl/src/bin/upgrade-shell b/packages/base/all/vendor-config-onl/src/bin/upgrade-shell new file mode 100755 index 00000000..7e488d28 --- /dev/null +++ b/packages/base/all/vendor-config-onl/src/bin/upgrade-shell @@ -0,0 +1,7 @@ +#!/usr/bin/python + +"""Run the upgrade image +""" + +import onl.install.ShellApp +onl.install.ShellApp.Upgrader.main() diff --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 index 19cfaf6f..79c40e59 100644 --- 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 @@ -16,8 +16,9 @@ from InstallUtils import BlkidParser import Fit import onl.platform.current +from onl.sysconfig import sysconfig -class AppBase(SubprocessMixin): +class AppBase(SubprocessMixin, object): @property def PROG(self): @@ -109,6 +110,7 @@ class AppBase(SubprocessMixin): sys.exit(code) class Onie(AppBase): + """Application shell that uses the ONIE runtime.""" PROG = "onie-shell" @@ -193,6 +195,7 @@ class Onie(AppBase): return 1 class Loader(AppBase): + """Application shell that uses the (installed) loader runtime.""" PROG = "loader-shell" @@ -309,6 +312,49 @@ class Loader(AppBase): self.log.error("invalid platform-config") return 1 +class Upgrader(AppBase): + """Application shell that uses on-disk upgrade loader runtime.""" + + PROG = "upgrade-shell" + + def runGrub(self): + + d = sysconfig.upgrade.loader.package.dir + for b in sysconfig.upgrade.loader.package.grub: + p = os.path.join(d, b) + if os.path.exists(p): + self.log.debug("found upgrade initrd at %s", p) + return self._runInitrdShell(p) + + self.log.error("cannot find upgrade initrd") + return 1 + + def runUboot(self): + + d = sysconfig.upgrade.loader.package.dir + for b in sysconfig.upgrade.loader.package.fit: + p = os.path.join(d, b) + if os.path.exists(p): + self.log.debug("found upgrade FIT image %s", p) + return self._runFitShell(p) + + self.log.error("cannot find FIT image") + return 1 + + def run(self): + + self.platform = onl.platform.current.OnlPlatform() + self.pc = self.platform.platform_config + + if 'grub' in self.pc: + return self.runGrub() + + if 'flat_image_tree' in self.pc: + return self.runUboot() + + self.log.error("invalid platform-config") + return 1 + main = Onie.main if __name__ == "__main__": From 8d9bedd92e82659837705e099ca45d2e7251ab85 Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Mon, 24 Oct 2016 13:11:42 -0700 Subject: [PATCH 22/43] Added cp-R, added support for devtmpfs --- .../src/python/onl/install/InstallUtils.py | 78 ++++++++++++++----- 1 file changed, 58 insertions(+), 20 deletions(-) diff --git a/packages/base/all/vendor-config-onl/src/python/onl/install/InstallUtils.py b/packages/base/all/vendor-config-onl/src/python/onl/install/InstallUtils.py index 386f318a..9ce429fc 100644 --- a/packages/base/all/vendor-config-onl/src/python/onl/install/InstallUtils.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/install/InstallUtils.py @@ -177,6 +177,27 @@ class SubprocessMixin: # don't believe it self.check_call(cmd, vmode=self.V1) + def cpR(self, srcRoot, dstRoot): + srcRoot = os.path.abspath(srcRoot) + dstRoot = os.path.abspath(dstRoot) + dstRoot = os.path.join(dstRoot, os.path.split(srcRoot)[1]) + for r, dl, fl in os.walk(srcRoot): + + for de in dl: + src = os.path.join(r, de) + subdir = src[len(srcRoot)+1:] + dst = os.path.join(dstRoot, subdir) + if not os.path.exists(dst): + self.log.debug("+ /bin/mkdir -p %s", dst) + os.mkdirs(dst) + + for fe in fl: + src = os.path.join(r, de) + subdir = src[len(srcRoot)+1:] + dst = os.path.join(dstRoot, subdir) + self.log.debug("+ /bin/cp -a %s %s", src, dst) + shutil.copy2(src, dst) + class TempdirContext(SubprocessMixin): def __init__(self, prefix=None, suffix=None, chroot=None, log=None): @@ -678,6 +699,7 @@ class InitrdContext(SubprocessMixin): self.ilog.setLevel(logging.INFO) self.log = self.hlog + self._hasDevTmpfs = False self._detachInitrd = None def _unpack(self): @@ -739,27 +761,28 @@ class InitrdContext(SubprocessMixin): else: self.unlink(dst) - for e in os.listdir("/dev"): - src = os.path.join("/dev", e) - dst = os.path.join(dev2, e) - if os.path.islink(src): - self.symlink(os.readlink(src), dst) - elif os.path.isdir(src): - self.mkdir(dst) - elif os.path.isfile(src): - self.copy2(src, dst) - else: - st = os.stat(src) - if stat.S_ISBLK(st.st_mode): - maj, min = os.major(st.st_rdev), os.minor(st.st_rdev) - self.log.debug("+ mknod %s b %d %d", dst, maj, min) - os.mknod(dst, st.st_mode, st.st_rdev) - elif stat.S_ISCHR(st.st_mode): - maj, min = os.major(st.st_rdev), os.minor(st.st_rdev) - self.log.debug("+ mknod %s c %d %d", dst, maj, min) - os.mknod(dst, st.st_mode, st.st_rdev) + if not self._hasDevTmpfs: + for e in os.listdir("/dev"): + src = os.path.join("/dev", e) + dst = os.path.join(dev2, e) + if os.path.islink(src): + self.symlink(os.readlink(src), dst) + elif os.path.isdir(src): + self.mkdir(dst) + elif os.path.isfile(src): + self.copy2(src, dst) else: - self.log.debug("skipping device %s", src) + st = os.stat(src) + if stat.S_ISBLK(st.st_mode): + maj, min = os.major(st.st_rdev), os.minor(st.st_rdev) + self.log.debug("+ mknod %s b %d %d", dst, maj, min) + os.mknod(dst, st.st_mode, st.st_rdev) + elif stat.S_ISCHR(st.st_mode): + maj, min = os.major(st.st_rdev), os.minor(st.st_rdev) + self.log.debug("+ mknod %s c %d %d", dst, maj, min) + os.mknod(dst, st.st_mode, st.st_rdev) + else: + self.log.debug("skipping device %s", src) dst = os.path.join(self.dir, "dev/pts") if not os.path.exists(dst): @@ -772,6 +795,11 @@ class InitrdContext(SubprocessMixin): def __enter__(self): + with open("/proc/filesystems") as fd: + buf = fd.read() + if "devtmpfs" in buf: + self._hasDevTmpfs = True + if self.initrd is not None: self.log.debug("extracting initrd %s", self.initrd) @@ -792,6 +820,16 @@ class InitrdContext(SubprocessMixin): cmd = ('mount', '-t', 'sysfs', 'sysfs', dst,) self.check_call(cmd, vmode=self.V1) + # maybe mount devtmpfs + if self._hasDevTmpfs: + dst = os.path.join(self.dir, "dev") + cmd = ('mount', '-t', 'devtmpfs', 'devtmpfs', dst,) + self.check_call(cmd, vmode=self.V1) + + dst = os.path.join(self.dir, "dev/pts") + if not os.path.exists(dst): + self.mkdir(dst) + dst = os.path.join(self.dir, "dev/pts") cmd = ('mount', '-t', 'devpts', 'devpts', dst,) self.check_call(cmd, vmode=self.V1) From 5e0ea4516e5a21ea220ec8818fa8d4c35753d77e Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Mon, 24 Oct 2016 13:11:54 -0700 Subject: [PATCH 23/43] Update comment --- packages/base/all/vendor-config-onl/src/bin/loader-shell | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/base/all/vendor-config-onl/src/bin/loader-shell b/packages/base/all/vendor-config-onl/src/bin/loader-shell index e006aef4..9e758889 100755 --- a/packages/base/all/vendor-config-onl/src/bin/loader-shell +++ b/packages/base/all/vendor-config-onl/src/bin/loader-shell @@ -1,6 +1,6 @@ #!/usr/bin/python -"""Run native ONIE tools +"""Run native (on-disk) loader tools """ import onl.install.ShellApp From b6ce6eb566431b90a9acd80a0b9bbb8c4c78fb99 Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Mon, 24 Oct 2016 13:12:03 -0700 Subject: [PATCH 24/43] Added devtmpfs workaround --- .../vendor-config-onl/src/lib/install/lib.sh | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/packages/base/all/vendor-config-onl/src/lib/install/lib.sh b/packages/base/all/vendor-config-onl/src/lib/install/lib.sh index 388ab892..74dd273f 100644 --- a/packages/base/all/vendor-config-onl/src/lib/install/lib.sh +++ b/packages/base/all/vendor-config-onl/src/lib/install/lib.sh @@ -62,17 +62,26 @@ installer_mkchroot() { local rootdir rootdir=$1 + local hasDevTmpfs + if grep -q devtmpfs /proc/filesystems; then + hasDevTmpfs=1 + fi + # special handling for /dev, which usually already has nested mounts installer_say "Setting up /dev" rm -fr "${rootdir}/dev"/* - for dev in /dev/*; do - if test -d "$dev"; then - mkdir "${rootdir}${dev}" - else - cp -a "$dev" "${rootdir}${dev}" - fi - done - mkdir -p "${rootdir}/dev/pts" + if test "$hasDevTmpfs"; then + : + else + for dev in /dev/*; do + if test -d "$dev"; then + mkdir "${rootdir}${dev}" + else + cp -a "$dev" "${rootdir}${dev}" + fi + done + mkdir -p "${rootdir}/dev/pts" + fi installer_say "Setting up /run" rm -fr "${rootdir}/run"/* @@ -99,6 +108,10 @@ installer_mkchroot() { installer_say "Setting up mounts" mount -t proc proc "${rootdir}/proc" mount -t sysfs sysfs "${rootdir}/sys" + if test "$hasDevTmpfs"; then + mount -t devtmpfs devtmpfs "${rootdir}/dev" + mkdir -p ${rootdir}/dev/pts + fi mount -t devpts devpts "${rootdir}/dev/pts" if test ${TMPDIR+set}; then From c10374ddc6c5077472bddfa3658294f3c509791c Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Mon, 24 Oct 2016 16:51:52 -0700 Subject: [PATCH 25/43] Fixed cpR implementation --- .../src/python/onl/install/InstallUtils.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/base/all/vendor-config-onl/src/python/onl/install/InstallUtils.py b/packages/base/all/vendor-config-onl/src/python/onl/install/InstallUtils.py index 9ce429fc..3f1ead96 100644 --- a/packages/base/all/vendor-config-onl/src/python/onl/install/InstallUtils.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/install/InstallUtils.py @@ -188,15 +188,13 @@ class SubprocessMixin: subdir = src[len(srcRoot)+1:] dst = os.path.join(dstRoot, subdir) if not os.path.exists(dst): - self.log.debug("+ /bin/mkdir -p %s", dst) - os.mkdirs(dst) + self.makedirs(dst) for fe in fl: - src = os.path.join(r, de) + src = os.path.join(r, fe) subdir = src[len(srcRoot)+1:] dst = os.path.join(dstRoot, subdir) - self.log.debug("+ /bin/cp -a %s %s", src, dst) - shutil.copy2(src, dst) + self.copy2(src, dst) class TempdirContext(SubprocessMixin): From f8f297512159cfd9276e26b1fb60a0ede86897e2 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Tue, 25 Oct 2016 18:07:26 +0000 Subject: [PATCH 26/43] New SYSTEM_COMPATIBILITY_VERSION (SCV) key This key is designed to indicate the overall system compatibility between different installations. For example, the system configuration in ONL2.0 is different from ONL 1.0 (partition scheme, loader/version management, etc) and attempting to boot a 1.0 switch image on a 2.0 system will not work properly. This key exists to facilitate operational compatibility and upgrade steps. When a switch image is booted against a loader with an SCV different than it expects then a full re-install will need to be performed in order to upgrade the system before that image can run. If the SCV is different then an in-place loader-upgrade cannot be performed either. The upgrade process will be updated to include an SCV check and perform a re-install. The loader upgrade sequence will be predicated on SCV equality. If the SCV is not equal after all upgrade operations then switch has the option of rebooting instead of continuing the init process. This will be configured through the sysconfig interface. --- tools/onlvi.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/onlvi.py b/tools/onlvi.py index d71be362..6bee3bbe 100644 --- a/tools/onlvi.py +++ b/tools/onlvi.py @@ -52,3 +52,6 @@ class OnlVersionImplementation(object): def V_FNAME_RELEASE_ID(self, data): return "%s-%s" % (self.V_VERSION_ID(data), self.V_FNAME_BUILD_ID(data)) + + def V_SYSTEM_COMPATIBILITY_VERSION(self, data): + return "2" From 06ad896fd4f9b11233f8b31ffdfee85c0805f435 Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Tue, 25 Oct 2016 14:36:22 -0700 Subject: [PATCH 27/43] Added system upgrade key --- .../all/vendor-config-onl/src/etc/onl/sysconfig/00-defaults.yml | 2 ++ 1 file changed, 2 insertions(+) diff --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 index 6527b70d..10278f7e 100644 --- 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 @@ -19,6 +19,8 @@ installer: upgrade: onie: auto: advisory + system: + auto: advisory loader: auto: advisory versions: /etc/onl/loader/versions.json From 6f9d993696d281a477cbff1750d08a191fcc6526 Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Tue, 25 Oct 2016 14:37:16 -0700 Subject: [PATCH 28/43] the --extract option is unimplemented --- tools/onlpm.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/onlpm.py b/tools/onlpm.py index e41e639d..58e991eb 100755 --- a/tools/onlpm.py +++ b/tools/onlpm.py @@ -1043,7 +1043,6 @@ if __name__ == '__main__': ap.add_argument("--repo-package-dir", default=os.environ.get('ONLPM_OPTION_REPO_PACKAGE_DIR', 'packages')) ap.add_argument("--packagedirs", nargs='+', metavar='PACKAGEDIR') ap.add_argument("--subdir", default=os.getcwd()) - ap.add_argument("--extract", metavar='PACKAGE') ap.add_argument("--extract-dir", nargs=2, metavar=('PACKAGE', 'DIR'), action='append') ap.add_argument("--force", action='store_true') ap.add_argument("--list", action='store_true'); From df146fd1226087c29e0cd3fe1ff36ebd84255995 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Wed, 19 Oct 2016 21:34:54 +0000 Subject: [PATCH 29/43] Onie and Loader infrastructure improvements - Loader and ONIE moved to importable classes for tool usage - OnieUpgradeBase updated. --- .../src/python/onl/upgrade/loader.py | 121 ++++++++++++++++++ .../src/python/onl/upgrade/onie.py | 59 +++++++++ .../src/python/onl/upgrade/ubase.py | 47 +++---- 3 files changed, 204 insertions(+), 23 deletions(-) create mode 100755 packages/base/all/vendor-config-onl/src/python/onl/upgrade/loader.py create mode 100755 packages/base/all/vendor-config-onl/src/python/onl/upgrade/onie.py diff --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 new file mode 100755 index 00000000..10df045e --- /dev/null +++ b/packages/base/all/vendor-config-onl/src/python/onl/upgrade/loader.py @@ -0,0 +1,121 @@ +#!/usr/bin/python +############################################################ +# +# ONL Loader Upgrade +# +############################################################ +import os +import sys +import fnmatch + +from onl.upgrade import ubase +from onl.sysconfig import sysconfig +from onl.mounts import OnlMountManager, OnlMountContextReadOnly, OnlMountContextReadWrite + +class LoaderUpgradeBase(ubase.BaseUpgrade): + name="loader" + Name="Loader" + title="Loader Upgrade Check" + atype="A Loader" + + current_version_key="Current Loader Version" + next_version_key="Next Loader Version" + + def auto_upgrade_default(self): + return sysconfig.upgrade.loader.auto + + def init_versions(self): + + # + # Current Loader version file. + # If this file doesn't exist then in-place upgrade is not supported. + # + ETC_LOADER_VERSIONS_JSON = sysconfig.upgrade.loader.versions + + # Upgrade Loader Version file. + NEXT_LOADER_VERSIONS_JSON = os.path.join(sysconfig.upgrade.loader.package.dir, "manifest.json") + + + self.current_version = self.load_json(ETC_LOADER_VERSIONS_JSON, + "RELEASE_ID", + None) + + self.next_version = self.load_json(NEXT_LOADER_VERSIONS_JSON, + "version", {}).get('RELEASE_ID', None) + + def summarize(self): + self.logger.info("Current Loader Version: %s" % self.current_version) + self.logger.info(" Next Loader Version: %s" % self.next_version) + self.logger.info("") + + + def upgrade_notes(self): + return """ + * A single reboot will be required to complete this upgrade. +""" + + +class LoaderUpgrade_Fit(LoaderUpgradeBase): + + def do_upgrade(self, forced=False): + + fit_image = None + for f in sysconfig.upgrade.loader.package.fit: + fp = os.path.join(sysconfig.upgrade.loader.package.dir, f) + if os.path.exists(fp): + fit_image = fp; + break + + if fit_image is None: + self.abort("The FIT upgrade image is missing. Upgrade cannot continue.") + + with OnlMountContextReadWrite("ONL-BOOT", self.logger) as d: + self.copyfile(fit_image, os.path.join(d.directory, "%s.itb" % (self.platform.platform()))) + + self.reboot() + + +class LoaderUpgrade_x86_64(LoaderUpgradeBase): + + def do_upgrade(self, forced=False): + + X86_64_UPGRADE_DIR=sysconfig.upgrade.loader.package.dir + X86_64_UPGRADE_KERNEL_PATTERNS = [ "kernel-*" ] + + with OnlMountContextReadWrite("ONL-BOOT", self.logger) as d: + for f in os.listdir(X86_64_UPGRADE_DIR): + for pattern in X86_64_UPGRADE_KERNEL_PATTERNS: + if fnmatch.fnmatch(f, pattern): + self.copyfile(os.path.join(X86_64_UPGRADE_DIR, f), os.path.join(d.directory, f)) + + initrd = None + for c in sysconfig.upgrade.loader.package.grub: + initrd = os.path.join(X86_64_UPGRADE_DIR, c) + if os.path.exists(initrd): + break + else: + initrd = None + + if initrd: + self.copyfile(initrd, os.path.join(d.directory, "%s.cpio.gz" % self.platform.platform())) + else: + self.abort("Initrd is missing. Upgrade cannot continue.") + + # Disabled until it can be resolved with the new installer. + #src = "/lib/platform-config/current/onl/boot/grub.cfg" + #dst = os.path.join(d.directory, "grub/grub.cfg") + #if os.path.exists(src): + # self.copyfile(src, dst) + + self.reboot() + + +import platform +arch = platform.machine() +LoaderUpgrade = None + +if arch in [ 'ppc', 'armv7l', 'aarch64', 'arm64' ]: + LoaderUpgrade = LoaderUpgrade_Fit +elif arch == 'x86_64': + LoaderUpgrade = LoaderUpgrade_x86_64 + diff --git a/packages/base/all/vendor-config-onl/src/python/onl/upgrade/onie.py b/packages/base/all/vendor-config-onl/src/python/onl/upgrade/onie.py new file mode 100755 index 00000000..a4f6beb2 --- /dev/null +++ b/packages/base/all/vendor-config-onl/src/python/onl/upgrade/onie.py @@ -0,0 +1,59 @@ +#!/usr/bin/python -u + +import os +import sys + +from onl.upgrade import ubase +from onl.sysconfig import sysconfig +from onl.mounts import OnlMountManager, OnlMountContextReadOnly, OnlMountContextReadWrite + +class OnieUpgrade(ubase.BaseOnieUpgrade): + + name="onie" + Name="ONIE" + title="ONIE Upgrade Check" + atype="An ONIE" + + current_version_key="Current ONIE Version" + next_version_key="Next ONIE Version" + + def init_versions(self): + + # Get the current platform ONIE version + self.current_version = self.platform.onie_version() + self.next_version = None + self.updater = None + + self.manifest = self.load_json(os.path.join(sysconfig.upgrade.onie.package.dir, "manifest.json")) + + if self.manifest is None: + self.finish("No ONIE updater available for the current platform.") + + if 'onie-version' not in self.manifest: + self.finish("No ONIE version in the upgrade manifest.") + else: + self.next_version = self.manifest['onie-version'] + + if 'onie-updater' not in self.manifest: + self.finish("No ONIE updater in the upgrade manifest.") + + + def summarize(self): + self.logger.info("Current ONIE Version: %s" % self.current_version) + self.logger.info(" Next ONIE Version: %s" % self.manifest.get('onie-version')) + self.logger.info(" Updater: %s" % self.manifest.get('onie-updater')) + self.logger.info("") + + def upgrade_notes(self): + return """ + * The system will reboot into ONIE to complete the update, and then reboot to return to Switch Light +""" + + def do_upgrade(self, forced=False): + self.install_onie_updater(sysconfig.upgrade.onie.package.dir, + self.manifest['onie-updater']) + self.initiate_onie_update() + + def do_no_upgrade(self): + self.clean_onie_updater() + diff --git a/packages/base/all/vendor-config-onl/src/python/onl/upgrade/ubase.py b/packages/base/all/vendor-config-onl/src/python/onl/upgrade/ubase.py index 68f3828f..af2b677d 100644 --- a/packages/base/all/vendor-config-onl/src/python/onl/upgrade/ubase.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/upgrade/ubase.py @@ -15,7 +15,9 @@ import string import argparse import yaml from time import sleep + from onl.platform.current import OnlPlatform +from onl.mounts import OnlMountManager, OnlMountContextReadOnly, OnlMountContextReadWrite class BaseUpgrade(object): @@ -365,19 +367,19 @@ If you choose not to perform this upgrade booting cannot continue.""" % self.aty class BaseOnieUpgrade(BaseUpgrade): - ONIE_UPDATER_PATH = "/mnt/flash2/onie-updater" + ONIE_UPDATER_CONTEXT = "ONL-IMAGES" + ONIE_UPDATER_PATH = "/mnt/onl/images" def install_onie_updater(self, src_dir, updater): - if type(updater) is list: - # Copy all files in the list to /mnt/flash2 + with OnlMountContextReadWrite(self.ONIE_UPDATER_CONTEXT, logger=None): + if type(updater) is not list: + updater = [ updater ] + + # Copy all files in the list to ONIE_UPDATER_PATH for f in updater: src = os.path.join(src_dir, f) - dst = os.path.join("/mnt/flash2", f) + dst = os.path.join(self.ONIE_UPDATER_PATH, f) self.copyfile(src, dst) - else: - # Copy single updater to /mnt/flash2/onie-updater - src = os.path.join(src_dir, updater) - self.copyfile(src, self.ONIE_UPDATER_PATH) def initiate_onie_update(self): @@ -394,27 +396,26 @@ class BaseOnieUpgrade(BaseUpgrade): self.abort("Could not set ONIE Boot Mode to Update. Upgrade cannot continue.") self.umount(OB) - SL = "/mnt/sl-boot" - self.mount(SL, label="SL-BOOT") - with open("/mnt/sl-boot/grub/grub.cfg", "a") as f: - f.write("set default=ONIE\n") - self.umount(SL) + with OnlMountContextReadWrite("ONL-BOOT", logger=None): + with open("/mnt/onl/boot/grub/grub.cfg", "a") as f: + f.write("set default=ONIE\n") self.reboot() else: self.abort("Architecture %s unhandled." % self.arch) def clean_onie_updater(self): - if os.path.exists(self.ONIE_UPDATER_PATH): - self.logger.info("Removing previous onie-updater.") - os.remove(self.ONIE_UPDATER_PATH) + with OnlMountContextReadWrite(self.ONIE_UPDATER_CONTEXT, logger=None): + updater = os.path.join(self.ONIE_UPDATER_PATH, "onie-updater") + if os.path.exists(updater): + self.logger.info("Removing previous onie-updater.") + os.remove(updater) - -def upgrade_status(): - data = {} - if os.path.exists(BaseUpgrade.UPGRADE_STATUS_JSON): - with open(BaseUpgrade.UPGRADE_STATUS_JSON) as f: - data = json.load(f) - return data +# def upgrade_status(): +# data = {} +# if os.path.exists(BaseUpgrade.UPGRADE_STATUS_JSON): +# with open(BaseUpgrade.UPGRADE_STATUS_JSON) as f: +# data = json.load(f) +# return data From 03bb6b718d43fe8444373ff6ea2568ddd5bbebce Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Wed, 19 Oct 2016 21:36:00 +0000 Subject: [PATCH 30/43] Add default ONIE upgrade package settings. --- .../src/boot.d/60.upgrade-onie | 3 + .../src/boot.d/61.upgrade-onie | 55 -------- .../src/boot.d/62.upgrade-loader | 129 +----------------- .../src/etc/onl/sysconfig/00-defaults.yml | 4 + 4 files changed, 9 insertions(+), 182 deletions(-) create mode 100755 packages/base/all/vendor-config-onl/src/boot.d/60.upgrade-onie delete mode 100755 packages/base/all/vendor-config-onl/src/boot.d/61.upgrade-onie diff --git a/packages/base/all/vendor-config-onl/src/boot.d/60.upgrade-onie b/packages/base/all/vendor-config-onl/src/boot.d/60.upgrade-onie new file mode 100755 index 00000000..a6daef06 --- /dev/null +++ b/packages/base/all/vendor-config-onl/src/boot.d/60.upgrade-onie @@ -0,0 +1,3 @@ +#!/usr/bin/python +from onl.upgrade.onie import OnieUpgrade +OnieUpgrade().main() diff --git a/packages/base/all/vendor-config-onl/src/boot.d/61.upgrade-onie b/packages/base/all/vendor-config-onl/src/boot.d/61.upgrade-onie deleted file mode 100755 index 5f0e8883..00000000 --- a/packages/base/all/vendor-config-onl/src/boot.d/61.upgrade-onie +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/python -u -from onl.upgrade import ubase - -class ONIE_Upgrade(ubase.BaseOnieUpgrade): - name="onie" - Name="ONIE" - title="ONIE Upgrade Check" - atype="An ONIE" - - current_version_key="Current ONIE Version" - next_version_key="Next ONIE Version" - - def init_versions(self): - - # Get the current platform ONIE version - self.current_version = self.platform.onie_version() - self.next_version = None - self.updater = None - - (udir, um, data) = self.platform.upgrade_manifest("onie") - self.udir = udir - self.data = data - - if data: - self.next_version = data.get('onie-version', None) - - if data: - self.updater = data.get('onie-updater', None) - - if self.updater is None: - self.finish("No ONIE updater available for the current platform.") - - def summarize(self): - self.logger.info("Current ONIE Version: %s" % self.current_version) - self.logger.info(" Next ONIE Version: %s" % self.next_version) - self.logger.info(" Force-Update: %s" % self.data['force-update']) - self.logger.info(" Updater: %s" % self.updater) - self.logger.info("") - - def upgrade_notes(self): - return """ - * The system will reboot into ONIE to complete the update, and then reboot to return to Switch Light -""" - - def do_upgrade(self, forced=False): - self.install_onie_updater(self.udir, self.updater) - self.initiate_onie_update() - - def do_no_upgrade(self): - self.clean_onie_updater() - - -if __name__ == '__main__': - ONIE_Upgrade().main() - diff --git a/packages/base/all/vendor-config-onl/src/boot.d/62.upgrade-loader b/packages/base/all/vendor-config-onl/src/boot.d/62.upgrade-loader index afe514df..02aa6d92 100755 --- a/packages/base/all/vendor-config-onl/src/boot.d/62.upgrade-loader +++ b/packages/base/all/vendor-config-onl/src/boot.d/62.upgrade-loader @@ -1,128 +1,3 @@ #!/usr/bin/python -############################################################ -# -# ONL Loader Upgrade -# -############################################################ -import os -import sys -import fnmatch -from onl.upgrade import ubase -from onl.sysconfig import sysconfig -from onl.mounts import OnlMountManager, OnlMountContextReadOnly, OnlMountContextReadWrite - -class Loader_Upgrade(ubase.BaseUpgrade): - name="loader" - Name="Loader" - title="Loader Upgrade Check" - atype="A Loader" - - current_version_key="Current Loader Version" - next_version_key="Next Loader Version" - - def auto_upgrade_default(self): - return sysconfig.upgrade.loader.auto - - def init_versions(self): - - # - # Current Loader version file. - # If this file doesn't exist then in-place upgrade is not supported. - # - ETC_LOADER_VERSIONS_JSON = sysconfig.upgrade.loader.versions - - # Upgrade Loader Version file. - NEXT_LOADER_VERSIONS_JSON = os.path.join(sysconfig.upgrade.loader.package.dir, "manifest.json") - - - self.current_version = self.load_json(ETC_LOADER_VERSIONS_JSON, - "RELEASE_ID", - None) - - self.next_version = self.load_json(NEXT_LOADER_VERSIONS_JSON, - "version", {}).get('RELEASE_ID', None) - - def summarize(self): - self.logger.info("Current Loader Version: %s" % self.current_version) - self.logger.info(" Next Loader Version: %s" % self.next_version) - self.logger.info("") - - - def upgrade_notes(self): - return """ - * A single reboot will be required to complete this upgrade. -""" - - -class Loader_Upgrade_FIT(Loader_Upgrade): - - def do_upgrade(self, forced=False): - - fit_image = None - for f in sysconfig.upgrade.loader.package.fit: - fp = os.path.join(sysconfig.upgrade.loader.package.dir, f) - if os.path.exists(fp): - fit_image = fp; - break - - if fit_image is None: - self.abort("The FIT upgrade image is missing. Upgrade cannot continue.") - - with OnlMountContextReadWrite("ONL-BOOT", self.logger) as d: - self.copyfile(fit_image, os.path.join(d.directory, "%s.itb" % (self.platform.platform()))) - - self.reboot() - - -class Loader_Upgrade_x86_64(Loader_Upgrade): - - def do_upgrade(self, forced=False): - - X86_64_UPGRADE_DIR=sysconfig.upgrade.loader.package.dir - X86_64_UPGRADE_KERNEL_PATTERNS = [ "kernel-*" ] - - with OnlMountContextReadWrite("ONL-BOOT", self.logger) as d: - for f in os.listdir(X86_64_UPGRADE_DIR): - for pattern in X86_64_UPGRADE_KERNEL_PATTERNS: - if fnmatch.fnmatch(f, pattern): - self.copyfile(os.path.join(X86_64_UPGRADE_DIR, f), os.path.join(d.directory, f)) - - initrd = None - for c in sysconfig.upgrade.loader.package.grub: - initrd = os.path.join(X86_64_UPGRADE_DIR, c) - if os.path.exists(initrd): - break - else: - initrd = None - - if initrd: - self.copyfile(initrd, os.path.join(d.directory, "%s.cpio.gz" % self.platform.platform())) - else: - self.abort("Initrd is missing. Upgrade cannot continue.") - - # Disabled until it can be resolved with the new installer. - #src = "/lib/platform-config/current/onl/boot/grub.cfg" - #dst = os.path.join(d.directory, "grub/grub.cfg") - #if os.path.exists(src): - # self.copyfile(src, dst) - - self.reboot() - - - - -if __name__ == '__main__': - import platform - - arch = platform.machine() - klass = None - - if arch in [ 'ppc', 'armv7l', 'aarch64', 'arm64' ]: - klass = Loader_Upgrade_FIT - elif arch == 'x86_64': - klass = Loader_Upgrade_x86_64 - else: - sys.stderr.write("Loader Upgrade: The current architecture (%s) is not supported for upgrade.\n" % arch) - - if klass: - klass().main() +from onl.upgrade.loader import LoaderUpgrade +LoaderUpgrade().main() diff --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 index 10278f7e..de61b257 100644 --- 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 @@ -19,8 +19,12 @@ installer: upgrade: onie: auto: advisory + package: + dir: /lib/platform-config/current/onl/upgrade/onie + system: auto: advisory + loader: auto: advisory versions: /etc/onl/loader/versions.json From b7879951f0cb4076e274298ff1071419061983da Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Thu, 20 Oct 2016 21:15:05 +0000 Subject: [PATCH 31/43] Commit the sysctl settings prior to first mount. --- packages/base/all/boot.d/src/50.initmounts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/base/all/boot.d/src/50.initmounts b/packages/base/all/boot.d/src/50.initmounts index 71f7410f..48717381 100755 --- a/packages/base/all/boot.d/src/50.initmounts +++ b/packages/base/all/boot.d/src/50.initmounts @@ -1,6 +1,10 @@ #!/bin/sh . /lib/lsb/init-functions + +# Apply the existing sysctl settings prior to first mount. +sysctl --quiet --system + log_action_begin_msg "Mounting filesystems..." onl-mounts -q mount all log_action_end_msg 0 From 4a5732241cf5248d575db10cf551d56c15129a47 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Thu, 20 Oct 2016 14:16:01 -0700 Subject: [PATCH 32/43] Add platform and firmware keys. --- .../vendor-config-onl/src/python/onl/platform/base.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py b/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py index f9e0e20e..23163d29 100644 --- a/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py @@ -90,6 +90,10 @@ class OnieInfo(object): } +class PlatformInfo(object): + CPLD_VERSIONS='CPLD Versions' + + ############################################################ # # ONL Platform Base @@ -107,7 +111,7 @@ class OnlPlatformBase(object): def __init__(self): self.add_info_json("onie_info", "%s/onie-info.json" % self.basedir_onl(), OnieInfo, required=False) - self.add_info_json("platform_info", "%s/platform-info.json" % self.basedir_onl(), + self.add_info_json("platform_info", "%s/platform-info.json" % self.basedir_onl(), PlatformInfo, required=False) # Find the base platform config @@ -217,6 +221,9 @@ class OnlPlatformBase(object): def onie_version(self): return self.onie_info.ONIE_VERSION + def firmware_version(self): + return self.platform_info.CPLD_VERSIONS + def upgrade_manifest(self, type_, override_dir=None): if override_dir: m = os.path.join(override_dir, "manifest.json") From b077ed028bcb8b3c08447484a3870e2863be3b21 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Thu, 20 Oct 2016 21:18:24 +0000 Subject: [PATCH 33/43] Enable ONIE and Firmware Upgrade Package Support --- .../src/boot.d/61.upgrade-firmware | 3 ++ .../src/etc/onl/sysconfig/00-defaults.yml | 6 +++ .../src/python/onl/upgrade/firmware.py | 52 +++++++++++++++++++ .../src/python/onl/upgrade/onie.py | 33 +++--------- .../src/python/onl/upgrade/ubase.py | 22 +++++--- 5 files changed, 84 insertions(+), 32 deletions(-) create mode 100755 packages/base/all/vendor-config-onl/src/boot.d/61.upgrade-firmware create mode 100755 packages/base/all/vendor-config-onl/src/python/onl/upgrade/firmware.py diff --git a/packages/base/all/vendor-config-onl/src/boot.d/61.upgrade-firmware b/packages/base/all/vendor-config-onl/src/boot.d/61.upgrade-firmware new file mode 100755 index 00000000..aa23c80c --- /dev/null +++ b/packages/base/all/vendor-config-onl/src/boot.d/61.upgrade-firmware @@ -0,0 +1,3 @@ +#!/usr/bin/python +from onl.upgrade.firmware import FirmwareUpgrade +FirmwareUpgrade().main() diff --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 index de61b257..a9519949 100644 --- 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 @@ -25,6 +25,11 @@ upgrade: system: auto: advisory + firmware: + auto: advisory + package: + dir: /lib/platform-config/current/onl/upgrade/firmware + loader: auto: advisory versions: /etc/onl/loader/versions.json @@ -39,6 +44,7 @@ upgrade: swi: auto: disabled + pki: key: name: key.pem diff --git a/packages/base/all/vendor-config-onl/src/python/onl/upgrade/firmware.py b/packages/base/all/vendor-config-onl/src/python/onl/upgrade/firmware.py new file mode 100755 index 00000000..e9a08088 --- /dev/null +++ b/packages/base/all/vendor-config-onl/src/python/onl/upgrade/firmware.py @@ -0,0 +1,52 @@ +#!/usr/bin/python -u + +import os +import sys + +from onl.upgrade import ubase +from onl.sysconfig import sysconfig + +class FirmwareUpgrade(ubase.BaseOnieUpgrade): + + name="firmware" + Name="Firmware" + title="Firmware Upgrade Check" + atype="A firmware" + + current_version_key="Current Firmware Version" + next_version_key="Next Firmware Version" + + def init_versions(self): + + # Get the current platform firmware version + self.current_version = self.platform.firmware_version() + self.next_version = None + self.updater = None + self.load_manifest(os.path.join(sysconfig.upgrade.firmware.package.dir, "manifest.json")) + + def do_upgrade(self, forced=False): + self.install_onie_updater(sysconfig.upgrade.firmware.package.dir, + self.manifest['updater']) + self.initiate_onie_update() + + + def upgrade_notes(self): + notes = """ + * Two reboots will be required to complete this upgrade. + + * Do not turn the power off on this device until the upgrade is complete. + Disrupting power during the firmware upgrade may result in an unrecoverable system.""" + + duration = self.manifest.get("duration", None) + if duration: + notes = notes + """ + + * THIS UPGRADE WILL REQUIRE APPROXIMATELY %s MINUTES. + The system will reboot when completed.""" % duration + + return notes + + + def do_no_upgrade(self): + self.clean_onie_updater() + diff --git a/packages/base/all/vendor-config-onl/src/python/onl/upgrade/onie.py b/packages/base/all/vendor-config-onl/src/python/onl/upgrade/onie.py index a4f6beb2..fab08c0d 100755 --- a/packages/base/all/vendor-config-onl/src/python/onl/upgrade/onie.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/upgrade/onie.py @@ -5,7 +5,6 @@ import sys from onl.upgrade import ubase from onl.sysconfig import sysconfig -from onl.mounts import OnlMountManager, OnlMountContextReadOnly, OnlMountContextReadWrite class OnieUpgrade(ubase.BaseOnieUpgrade): @@ -23,37 +22,19 @@ class OnieUpgrade(ubase.BaseOnieUpgrade): self.current_version = self.platform.onie_version() self.next_version = None self.updater = None + self.load_manifest(os.path.join(sysconfig.upgrade.onie.package.dir, "manifest.json")) - self.manifest = self.load_json(os.path.join(sysconfig.upgrade.onie.package.dir, "manifest.json")) + def do_upgrade(self, forced=False): + self.install_onie_updater(sysconfig.upgrade.onie.package.dir, + self.manifest['updater']) + self.initiate_onie_update() - if self.manifest is None: - self.finish("No ONIE updater available for the current platform.") - - if 'onie-version' not in self.manifest: - self.finish("No ONIE version in the upgrade manifest.") - else: - self.next_version = self.manifest['onie-version'] - - if 'onie-updater' not in self.manifest: - self.finish("No ONIE updater in the upgrade manifest.") - - - def summarize(self): - self.logger.info("Current ONIE Version: %s" % self.current_version) - self.logger.info(" Next ONIE Version: %s" % self.manifest.get('onie-version')) - self.logger.info(" Updater: %s" % self.manifest.get('onie-updater')) - self.logger.info("") + def do_no_upgrade(self): + self.clean_onie_updater() def upgrade_notes(self): return """ * The system will reboot into ONIE to complete the update, and then reboot to return to Switch Light """ - def do_upgrade(self, forced=False): - self.install_onie_updater(sysconfig.upgrade.onie.package.dir, - self.manifest['onie-updater']) - self.initiate_onie_update() - - def do_no_upgrade(self): - self.clean_onie_updater() diff --git a/packages/base/all/vendor-config-onl/src/python/onl/upgrade/ubase.py b/packages/base/all/vendor-config-onl/src/python/onl/upgrade/ubase.py index af2b677d..2b5f6c22 100644 --- a/packages/base/all/vendor-config-onl/src/python/onl/upgrade/ubase.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/upgrade/ubase.py @@ -411,11 +411,21 @@ class BaseOnieUpgrade(BaseUpgrade): self.logger.info("Removing previous onie-updater.") os.remove(updater) + def load_manifest(self, path): + self.manifest = self.load_json(path) -# def upgrade_status(): -# data = {} -# if os.path.exists(BaseUpgrade.UPGRADE_STATUS_JSON): -# with open(BaseUpgrade.UPGRADE_STATUS_JSON) as f: -# data = json.load(f) -# return data + if self.manifest is None: + self.finish("No %s updater available for the current platform." % self.Name) + if 'version' not in self.manifest: + self.finish("No %s version in the upgrade manifest." % self.Name) + else: + self.next_version = self.manifest['version'] + + if 'updater' not in self.manifest: + self.finish("No %s updater in the upgrade manifest." % self.Name) + + def summarize(self): + self.logger.info("Current %s Version: %s" % (self.Name, self.current_version)) + self.logger.info(" Next %s Version: %s" % (self.Name, self.manifest.get('version'))) + self.logger.info("") From 306842e7cc6bffb9b8e5a97ab718696317b989d3 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Fri, 21 Oct 2016 06:56:09 -0700 Subject: [PATCH 34/43] Latest --- packages/platforms-closed | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/platforms-closed b/packages/platforms-closed index 5ae11894..14f30a9e 160000 --- a/packages/platforms-closed +++ b/packages/platforms-closed @@ -1 +1 @@ -Subproject commit 5ae11894fd5667434ad8ce5e7ae4b17eaf06567b +Subproject commit 14f30a9e614fb075ae591838f9859eb1e3f188be From 222ffd25047d12699d01e68c1008b787cec5b273 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Fri, 21 Oct 2016 16:02:32 +0000 Subject: [PATCH 35/43] Fix uninstallation. --- packages/base/all/vendor-config-onl/PKG.yml | 2 +- .../all/vendor-config-onl/src/sbin/uninstall | 59 +++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100755 packages/base/all/vendor-config-onl/src/sbin/uninstall diff --git a/packages/base/all/vendor-config-onl/PKG.yml b/packages/base/all/vendor-config-onl/PKG.yml index 3dc90ee8..0c0727bb 100644 --- a/packages/base/all/vendor-config-onl/PKG.yml +++ b/packages/base/all/vendor-config-onl/PKG.yml @@ -17,6 +17,6 @@ packages: - src/boot.d : /etc/boot.d - src/bin : /usr/bin - src/lib : /lib/vendor-config/onl - + - src/sbin : /sbin changelog: Changes diff --git a/packages/base/all/vendor-config-onl/src/sbin/uninstall b/packages/base/all/vendor-config-onl/src/sbin/uninstall new file mode 100755 index 00000000..8fe4742e --- /dev/null +++ b/packages/base/all/vendor-config-onl/src/sbin/uninstall @@ -0,0 +1,59 @@ +#!/bin/sh +set -e + +uninstall_x86_64() +{ + # + # Set ONIE boot selection to uninstall + # + mkdir -p /mnt/onie-boot + mount -L ONIE-BOOT /mnt/onie-boot > /dev/null 2>&1 + + if [ "$1" = "factory" ]; then + /mnt/onie-boot/onie/tools/bin/onie-boot-mode -o uninstall + else + /mnt/onie-boot/onie/tools/bin/onie-boot-mode -o install + fi + + umount /mnt/onie-boot + + # + # Select ONIE as the boot default + # + onl-mounts mount boot --rw + echo "set default=ONIE" >> /mnt/onl/boot/grub/grub.cfg + onl-mounts mount boot +} + +uninstall_uboot() +{ + if [ "$1" = "factory" ]; then + fw_setenv onie_boot_reason uninstall + else + fw_setenv nos_bootcmd echo + fi +} + +uninstall() +{ + case `uname -m` in + x86_64) + uninstall_x86_64 $1 + ;; + ppc|armv7l) + uninstall_uboot $1 + ;; + *) + echo "Uninstall for the current architecture is not implemented. This is a bug." + exit 1 + ;; + esac +} + +############################################################ + +uninstall $1 +echo "The NOS will be removed at the next reboot." +exit 0 + + From 1d52f43a0b4ee0fab6fc5bb401822babd2cd5839 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Fri, 21 Oct 2016 18:12:33 +0000 Subject: [PATCH 36/43] Upgrade separation and cleanup. --- .../src/boot.d/60.upgrade-onie | 4 +-- .../src/boot.d/61.upgrade-firmware | 5 ++- .../src/boot.d/62.upgrade-loader | 4 +-- .../src/python/onl/upgrade/loader.py | 3 ++ .../src/python/onl/upgrade/onie.py | 1 - .../src/python/onl/upgrade/ubase.py | 35 ++++++++++++------- .../src/sbin/onl-upgrade-firmware | 3 ++ .../src/sbin/onl-upgrade-loader | 3 ++ .../src/sbin/onl-upgrade-onie | 3 ++ 9 files changed, 39 insertions(+), 22 deletions(-) create mode 100755 packages/base/all/vendor-config-onl/src/sbin/onl-upgrade-firmware create mode 100755 packages/base/all/vendor-config-onl/src/sbin/onl-upgrade-loader create mode 100755 packages/base/all/vendor-config-onl/src/sbin/onl-upgrade-onie diff --git a/packages/base/all/vendor-config-onl/src/boot.d/60.upgrade-onie b/packages/base/all/vendor-config-onl/src/boot.d/60.upgrade-onie index a6daef06..540e24d3 100755 --- a/packages/base/all/vendor-config-onl/src/boot.d/60.upgrade-onie +++ b/packages/base/all/vendor-config-onl/src/boot.d/60.upgrade-onie @@ -1,3 +1 @@ -#!/usr/bin/python -from onl.upgrade.onie import OnieUpgrade -OnieUpgrade().main() +/sbin/onl-upgrade-onie diff --git a/packages/base/all/vendor-config-onl/src/boot.d/61.upgrade-firmware b/packages/base/all/vendor-config-onl/src/boot.d/61.upgrade-firmware index aa23c80c..41880e16 100755 --- a/packages/base/all/vendor-config-onl/src/boot.d/61.upgrade-firmware +++ b/packages/base/all/vendor-config-onl/src/boot.d/61.upgrade-firmware @@ -1,3 +1,2 @@ -#!/usr/bin/python -from onl.upgrade.firmware import FirmwareUpgrade -FirmwareUpgrade().main() +/sbin/onl-upgrade-firmware + diff --git a/packages/base/all/vendor-config-onl/src/boot.d/62.upgrade-loader b/packages/base/all/vendor-config-onl/src/boot.d/62.upgrade-loader index 02aa6d92..f802031a 100755 --- a/packages/base/all/vendor-config-onl/src/boot.d/62.upgrade-loader +++ b/packages/base/all/vendor-config-onl/src/boot.d/62.upgrade-loader @@ -1,3 +1 @@ -#!/usr/bin/python -from onl.upgrade.loader import LoaderUpgrade -LoaderUpgrade().main() +/sbin/onl-upgrade-loader diff --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 index 10df045e..6637c9a7 100755 --- 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 @@ -43,6 +43,9 @@ class LoaderUpgradeBase(ubase.BaseUpgrade): self.next_version = self.load_json(NEXT_LOADER_VERSIONS_JSON, "version", {}).get('RELEASE_ID', None) + def prepare_upgrade(self): + pass + def summarize(self): self.logger.info("Current Loader Version: %s" % self.current_version) self.logger.info(" Next Loader Version: %s" % self.next_version) diff --git a/packages/base/all/vendor-config-onl/src/python/onl/upgrade/onie.py b/packages/base/all/vendor-config-onl/src/python/onl/upgrade/onie.py index fab08c0d..4cf81016 100755 --- a/packages/base/all/vendor-config-onl/src/python/onl/upgrade/onie.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/upgrade/onie.py @@ -17,7 +17,6 @@ class OnieUpgrade(ubase.BaseOnieUpgrade): next_version_key="Next ONIE Version" def init_versions(self): - # Get the current platform ONIE version self.current_version = self.platform.onie_version() self.next_version = None diff --git a/packages/base/all/vendor-config-onl/src/python/onl/upgrade/ubase.py b/packages/base/all/vendor-config-onl/src/python/onl/upgrade/ubase.py index 2b5f6c22..86562b61 100644 --- a/packages/base/all/vendor-config-onl/src/python/onl/upgrade/ubase.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/upgrade/ubase.py @@ -41,6 +41,10 @@ class BaseUpgrade(object): self.platform = OnlPlatform() self.init() + self.current_version = None + self.next_version = None + self.init_versions() + def init(self): pass @@ -161,11 +165,16 @@ class BaseUpgrade(object): UPGRADE_STATUS_JSON = "/lib/platform-config/current/onl/upgrade.json" - def update_upgrade_status(self, key, value): + @staticmethod + def upgrade_status_get(): data = {} - if os.path.exists(self.UPGRADE_STATUS_JSON): - with open(self.UPGRADE_STATUS_JSON) as f: + if os.path.exists(BaseUpgrade.UPGRADE_STATUS_JSON): + with open(BaseUpgrade.UPGRADE_STATUS_JSON) as f: data = json.load(f) + return data + + def update_upgrade_status(self, key, value): + data = self.upgrade_status_get() data[key] = value with open(self.UPGRADE_STATUS_JSON, "w") as f: json.dump(data, f) @@ -177,6 +186,8 @@ class BaseUpgrade(object): def init_versions(self): raise Exception("init_versions() must be provided by the deriving class.") + def prepare_upgrade(self): + raise Exception("prepare_versions() must be provided by the deriving class.") # # Perform actual upgrade. Provided by derived class. @@ -192,9 +203,7 @@ class BaseUpgrade(object): def init_upgrade(self): - self.current_version = None - self.next_version = None - self.init_versions() + self.prepare_upgrade() self.update_upgrade_status(self.current_version_key, self.current_version) self.update_upgrade_status(self.next_version_key, self.next_version) @@ -411,20 +420,22 @@ class BaseOnieUpgrade(BaseUpgrade): self.logger.info("Removing previous onie-updater.") os.remove(updater) - def load_manifest(self, path): - self.manifest = self.load_json(path) - + def prepare_upgrade(self): if self.manifest is None: self.finish("No %s updater available for the current platform." % self.Name) - if 'version' not in self.manifest: + if self.next_version is None: self.finish("No %s version in the upgrade manifest." % self.Name) - else: - self.next_version = self.manifest['version'] if 'updater' not in self.manifest: self.finish("No %s updater in the upgrade manifest." % self.Name) + def load_manifest(self, path, required=True): + self.manifest = self.load_json(path) + self.next_version = None + if self.manifest: + self.next_version = self.manifest.get('version', None) + def summarize(self): self.logger.info("Current %s Version: %s" % (self.Name, self.current_version)) self.logger.info(" Next %s Version: %s" % (self.Name, self.manifest.get('version'))) diff --git a/packages/base/all/vendor-config-onl/src/sbin/onl-upgrade-firmware b/packages/base/all/vendor-config-onl/src/sbin/onl-upgrade-firmware new file mode 100755 index 00000000..aa23c80c --- /dev/null +++ b/packages/base/all/vendor-config-onl/src/sbin/onl-upgrade-firmware @@ -0,0 +1,3 @@ +#!/usr/bin/python +from onl.upgrade.firmware import FirmwareUpgrade +FirmwareUpgrade().main() diff --git a/packages/base/all/vendor-config-onl/src/sbin/onl-upgrade-loader b/packages/base/all/vendor-config-onl/src/sbin/onl-upgrade-loader new file mode 100755 index 00000000..02aa6d92 --- /dev/null +++ b/packages/base/all/vendor-config-onl/src/sbin/onl-upgrade-loader @@ -0,0 +1,3 @@ +#!/usr/bin/python +from onl.upgrade.loader import LoaderUpgrade +LoaderUpgrade().main() diff --git a/packages/base/all/vendor-config-onl/src/sbin/onl-upgrade-onie b/packages/base/all/vendor-config-onl/src/sbin/onl-upgrade-onie new file mode 100755 index 00000000..a6daef06 --- /dev/null +++ b/packages/base/all/vendor-config-onl/src/sbin/onl-upgrade-onie @@ -0,0 +1,3 @@ +#!/usr/bin/python +from onl.upgrade.onie import OnieUpgrade +OnieUpgrade().main() From 820cc3d9737997e09051d746411335bbd6de46de Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Tue, 25 Oct 2016 18:02:00 +0000 Subject: [PATCH 37/43] - DHCP Timeout support in the Loader environment When $NETAUTO=dhcp the transaction will now timeout after $NETRETRIES attempts. If the system has a local install or SWI then booting can continue. For systems which require DHCP to be functional before booting can continue (for example SWIs downloaded via URL rather than locally) then NETRETRIES=infinite should be set in the boot-config. NETRETRIES can be set to any number of attempts, or infinite. The default value is 5 attempts. - Wait for ma1 linkup in the loader A short wait has been introduced to allow ma1 to linkup prior to continuing. --- .../initrds/loader-initrd-files/src/bin/ifup | 56 ++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/packages/base/all/initrds/loader-initrd-files/src/bin/ifup b/packages/base/all/initrds/loader-initrd-files/src/bin/ifup index b9edbe67..eeef3eff 100644 --- a/packages/base/all/initrds/loader-initrd-files/src/bin/ifup +++ b/packages/base/all/initrds/loader-initrd-files/src/bin/ifup @@ -25,6 +25,7 @@ # Configure a network interface from settings in /etc/onl/NET # NETDEV: device name # NETAUTO: autoconfiguration method ("dhcp" or empty) +# NETRETRIES: autoconfiguration timeout # NETIP: IP address (/prefix optional for v4) # NETMASK: netmask (if NETIP has no prefix) # NETGW: default gateway IP address (optional) @@ -43,10 +44,39 @@ if [ "${NETHW}" ]; then ip link set dev ${NETDEV} addr ${NETHW} fi +# Default DHCP timeout is 10 requests in 10 seconds. +NETRETRIES_DEFAULT=10 +NETRETRIES=${NETRETRIES:-$NETRETRIES_DEFAULT} +if [ "$NETRETRIES" = "infinite" ]; then + NETRETRIES= +elif [ $(echo "$NETRETRIES" | tr -d '[:digit:]') ] || [ "$NETRETRIES" -lt 0 ]; then + echo "Warning: the NETRETRIES setting is currently '$NETRETRIES'. This is invalid and the default value of $NETRETRIES_DEFAULT will be used instead." + NETRETRIES=$NETRETRIES_DEFAULT +fi case "${NETAUTO}" in dhcp|auto) echo 1 >/proc/sys/net/ipv6/conf/${NETDEV}/autoconf - udhcpc -i ${NETDEV} + if [ -n "${NETRETRIES}" ]; then + if ! udhcpc --retries $NETRETRIES --now -i ${NETDEV}; then + echo "**********************************************************************" + echo "DHCP failed after $NETRETRIES attempts." + echo "**********************************************************************" + fi + else + while true; do + if udhcpc --retries $NETRETRIES_DEFAULT --now -i ${NETDEV}; then + break + fi + echo + echo "**********************************************************************" + echo "DHCP failed after $NETRETRIES_DEFAULT attempts." + echo "" + echo "No timeout is configured so DHCP requests will continue until successful." + echo " Press Ctrl-C to terminate and configure manually." + echo "" + echo "**********************************************************************" + done + fi ;; up) ifconfig "${NETDEV}" up @@ -87,3 +117,27 @@ for i in $(seq 30); do fi sleep 1 done +wait_link_up() +{ + local intf=$1 + local count=$2 + + local operstate="/sys/class/net/${intf}/operstate" + + echo "Waiting for link on ${intf}..." + local i=0 + [ -r $operstate ] && while [ $i -lt $count ] ; do + intf_operstate="$(cat $operstate)" + if [ "$intf_operstate" = "up" -o "$intf_operstate" = "unknown" ] ; then + echo "${intf}: up" + return 0 + fi + usleep 100000 + i=$(( $i + 1 )) + done + + echo "${intf}: down." + return 1 +} + +wait_link_up $NETDEV 100 From bff5e68d73511ef52ce67f0031d82852443742b5 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Tue, 25 Oct 2016 18:07:26 +0000 Subject: [PATCH 38/43] New SYSTEM_COMPATIBILITY_VERSION (SCV) key This key is designed to indicate the overall system compatibility between different installations. For example, the system configuration in ONL2.0 is different from ONL 1.0 (partition scheme, loader/version management, etc) and attempting to boot a 1.0 switch image on a 2.0 system will not work properly. This key exists to facilitate operational compatibility and upgrade steps. When a switch image is booted against a loader with an SCV different than it expects then a full re-install will need to be performed in order to upgrade the system before that image can run. If the SCV is different then an in-place loader-upgrade cannot be performed either. The upgrade process will be updated to include an SCV check and perform a re-install. The loader upgrade sequence will be predicated on SCV equality. If the SCV is not equal after all upgrade operations then switch has the option of rebooting instead of continuing the init process. This will be configured through the sysconfig interface. From ac3475f215f12b30af3ec7665331b9e45ccb8467 Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Wed, 26 Oct 2016 12:23:28 -0700 Subject: [PATCH 39/43] Added upgrade-system step --- .../src/boot.d/62.upgrade-system | 1 + .../src/python/onl/install/SystemInstall.py | 307 ++++++++++++++++++ .../src/python/onl/upgrade/system.py | 78 +++++ .../src/sbin/onl-install-system | 7 + .../src/sbin/onl-upgrade-system | 3 + 5 files changed, 396 insertions(+) create mode 100755 packages/base/all/vendor-config-onl/src/boot.d/62.upgrade-system create mode 100644 packages/base/all/vendor-config-onl/src/python/onl/install/SystemInstall.py create mode 100644 packages/base/all/vendor-config-onl/src/python/onl/upgrade/system.py create mode 100755 packages/base/all/vendor-config-onl/src/sbin/onl-install-system create mode 100755 packages/base/all/vendor-config-onl/src/sbin/onl-upgrade-system diff --git a/packages/base/all/vendor-config-onl/src/boot.d/62.upgrade-system b/packages/base/all/vendor-config-onl/src/boot.d/62.upgrade-system new file mode 100755 index 00000000..4fb8aadb --- /dev/null +++ b/packages/base/all/vendor-config-onl/src/boot.d/62.upgrade-system @@ -0,0 +1 @@ +/sbin/onl-upgrade-system diff --git a/packages/base/all/vendor-config-onl/src/python/onl/install/SystemInstall.py b/packages/base/all/vendor-config-onl/src/python/onl/install/SystemInstall.py new file mode 100644 index 00000000..d96557ac --- /dev/null +++ b/packages/base/all/vendor-config-onl/src/python/onl/install/SystemInstall.py @@ -0,0 +1,307 @@ +"""App.py + +Application code for swl-install. +""" + +import logging +import os, sys +import json +import tempfile +import zipfile +import shutil +import argparse +import fnmatch +import subprocess + +from onl.install.InstallUtils import InitrdContext, MountContext +from onl.install.InstallUtils import BlkidParser, ProcMountsParser +from onl.install.ConfUtils import MachineConf, InstallerConf +from onl.install.ShellApp import Onie, Upgrader +import onl.install.App +from onl.sysconfig import sysconfig +from onl.platform.current import OnlPlatform + +from onl.install.InstallUtils import SubprocessMixin + +class UpgradeHelper(Upgrader): + + def __init__(self, callback=None, log=None): + super(UpgradeHelper, self).__init__(log=log) + self.callback = callback + + def _runInitrdShell(self, p): + if self.callback is not None: + self.callback(self, p) + +class OnlBootContext(object): + + def __init__(self, log=None): + self.log = log or logging.getLogger(self.__class__.__name__) + self.dctx = None + self.dir = None + + def __enter__(self): + pm = ProcMountsParser() + logger = self.log.getChild("blkid") + blkid = BlkidParser(log=logger) + + try: + dev = blkid['ONL-BOOT'].device + except IndexError: + dev = None + if dev is None: + raise ValueError("cannot find ONL-BOOT") + + parts = [p for p in pm.mounts if p.device == dev] + if parts: + self.log.debug("found ONL-BOOT at %s", parts[0].dir) + self.dir = parts[0].dir + return self + + # else, mount this: + with MountContext(dev, log=self.log) as self.dctx: + self.log.debug("mounted ONL-BOOT %s --> %s", + dev, self.dctx.dir) + self.dir = self.dctx.dir + self.dctx.detach() + + return self + + def __exit__(self, type, value, tb): + dctx, self.dctx = self.dctx, None + if dctx is not None: + dctx.attach() + dctx.shutdown() + return False + +class App(SubprocessMixin): + + def __init__(self, force=False, log=None): + + if log is not None: + self.log = log + else: + self.log = logging.getLogger(self.__class__.__name__) + + self.force = force + + self.onieHelper = None + + def _runInitrd(self, helper, path): + with InitrdContext(initrd=path, log=self.log) as ctx: + + tdir = os.path.join(ctx.dir, "tmp") + abs_idir = tempfile.mkdtemp(dir=tdir, + prefix="installer-", suffix=".d") + chroot_idir = abs_idir[len(ctx.dir):] + + self.onieHelper = onl.install.App.OnieHelper(log=self.log) + code = self.onieHelper.run() + if code: + self.log.error("cannot find/unpack ONIE initrd") + return code + self.log.info("onie directory is %s", self.onieHelper.onieDir) + self.log.info("initrd directory is %s", self.onieHelper.initrdDir) + + src = os.path.join(self.onieHelper.initrdDir, "etc/machine.conf") + dst = os.path.join(ctx.dir, "etc/machine.conf") + self.log.debug("+ /bin/cp %s %s", src, dst) + shutil.copy2(src, dst) + + h, self.onieHelper = self.onieHelper, None + if h is not None: + h.shutdown() + + src = "/etc/fw_env.config" + if os.path.exists(src): + dst = os.path.join(ctx.dir, "etc/fw_env.config") + self.log.debug("+ /bin/cp %s %s", src, dst) + shutil.copy2(src, dst) + + srcRoot = "/etc/onl" + dstRoot = os.path.join(ctx.dir, "etc") + self.cpR(srcRoot, dstRoot) + + # constitute an /etc/onl/installer.conf in place + installerConf = InstallerConf(path="/dev/null") + + with open("/etc/onl/loader/versions.json") as fd: + data = json.load(fd) + installerConf.onl_version = data['VERSION_ID'] + + installerConf.installer_dir = chroot_idir + + abs_postinst = tempfile.mktemp(dir=abs_idir, + prefix="postinst-", suffix=".sh") + chroot_postinst = abs_postinst[len(ctx.dir):] + installerConf.installer_postinst = chroot_postinst + + # make an empty(ish) zip file (local path in installer_dir) for collateral + zipPath = tempfile.mktemp(dir=abs_idir, + prefix="install-", suffix=".zip") + with zipfile.ZipFile(zipPath, "w") as zf: + pass + installerConf.installer_zip = os.path.split(zipPath)[1] + + # finalize the local installer.conf + dst = os.path.join(ctx.dir, "etc/onl/installer.conf") + with open(dst, "w") as fd: + fd.write(installerConf.dumps()) + + # populate installer_dir with the contents of the loader upgrade + # See also Loader_Upgrade_x86_64.do_upgrade + # Here the initrd filename is as per the installer.zip; + # it is renamed on install to the grub directory + sdir = sysconfig.upgrade.loader.package.dir + + # get kernels for grub installs: + pats = ["kernel-*",] + for f in os.listdir(sdir): + for pat in pats: + if fnmatch.fnmatch(f, pat): + src = os.path.join(sdir, f) + dst = os.path.join(abs_idir, f) + self.log.debug("+ /bin/cp %s %s", src, dst) + shutil.copy2(src, dst) + try: + l = sysconfig.upgrade.loader.package.grub + except AttributeError: + l = [] + for f in l: + src = os.path.join(sdir, f) + if os.path.exists(src): + dst = os.path.join(abs_idir, f) + self.log.debug("+ /bin/cp %s %s", src, dst) + shutil.copy2(src, dst) + + # get FIT files from powerpc installs: + try: + l = sysconfig.upgrade.loader.package.fit + except AttributeError: + l = [] + for f in l: + src = os.path.join(sdir, f) + if os.path.exists(src): + dst = os.path.join(abs_idir, f) + self.log.debug("+ /bin/cp %s %s", src, dst) + shutil.copy2(src, dst) + + with OnlBootContext(log=self.log) as octx: + src = os.path.join(octx.dir, "boot-config") + dst = os.path.join(abs_idir, "boot-config") + self.log.debug("+ /bin/cp %s %s", src, dst) + shutil.copy2(src, dst) + + # chroot to the onl-install script + ##cmd = ('chroot', ctx.dir, + ## '/bin/sh', '-i') + if self.log.level < logging.INFO: + cmd = ('chroot', ctx.dir, "/usr/bin/onl-install", "--verbose", "--force",) + else: + cmd = ('chroot', ctx.dir, "/usr/bin/onl-install", "--force",) + try: + self.check_call(cmd) + except subprocess.CalledProcessError, what: + pass + + def run(self): + """XXX roth -- migrate this to onl.install.App.App + + XXX roth -- assume TMPDIR=/tmp. + """ + + pm = ProcMountsParser() + + # resize /tmp to be large enough for the initrd, see tmpfs + # nonsense in installer.sh.in + tflags = None + tdev = os.stat('/tmp').st_dev + pdir = None + for m in pm.mounts: + if m.fsType in ('ramfs', 'tmpfs',): + dev = os.stat(m.dir).st_dev + if dev == tdev: + self.log.info("found tmpfs/ramfs %s (%s)", dev, m.flags) + pdir = m.dir + tflags = m.flags + + # XXX glean this from install.sh.in (installer_tmpfs_kmin) + if pdir is None: + self.check_call(('mount', + '-o', 'size=1048576k', + '-t', 'tmpfs', + 'tmpfs', '/tmp',)) + else: + self.check_call(('mount', + '-o', 'remount,size=1048576k', + pdir,)) + + for m in pm.mounts: + if m.dir.startswith('/mnt/onl'): + if not self.force: + self.log.error("directory %s is still mounted (try --force)", m.dir) + return 1 + self.log.warn("unmounting %s (--force)", m.dir) + self.check_call(('umount', m.dir,)) + + upgrader = UpgradeHelper(callback=self._runInitrd, log=self.log) + try: + code = upgrader.run() + except: + self.log.exception("upgrader failed") + code = 1 + upgrader.shutdown() + return code + + def shutdown(self): + + h, self.onieHelper = self.onieHelper, None + if h is not None: + h.shutdown() + + @classmethod + def main(cls): + + logging.basicConfig() + logger = logging.getLogger("swl-install") + logger.setLevel(logging.DEBUG) + + # send to ONIE log + hnd = logging.FileHandler("/dev/console") + logger.addHandler(hnd) + logger.propagate = False + + onie_verbose = 'onie_verbose' in os.environ + installer_debug = 'installer_debug' in os.environ + + ap = argparse.ArgumentParser() + ap.add_argument('-v', '--verbose', action='store_true', + default=onie_verbose, + help="Enable verbose logging") + ap.add_argument('-D', '--debug', action='store_true', + default=installer_debug, + help="Enable python debugging") + ap.add_argument('-F', '--force', action='store_true', + help="Unmount filesystems before install") + ops = ap.parse_args() + + if ops.verbose: + logger.setLevel(logging.DEBUG) + + app = cls(force=ops.force, + log=logger) + try: + code = app.run() + except: + logger.exception("runner failed") + code = 1 + if ops.debug: + app.post_mortem() + + app.shutdown() + sys.exit(code) + +main = App.main + +if __name__ == "__main__": + main() diff --git a/packages/base/all/vendor-config-onl/src/python/onl/upgrade/system.py b/packages/base/all/vendor-config-onl/src/python/onl/upgrade/system.py new file mode 100644 index 00000000..9bcbf3cd --- /dev/null +++ b/packages/base/all/vendor-config-onl/src/python/onl/upgrade/system.py @@ -0,0 +1,78 @@ +#!/usr/bin/python +############################################################ +# +# ONL System Upgrade +# +############################################################ +import os +import sys +import fnmatch +from onl.upgrade import ubase +from onl.sysconfig import sysconfig +from onl.mounts import OnlMountManager, OnlMountContextReadOnly, OnlMountContextReadWrite + +from onl.install.SystemInstall import App + +class SystemUpgrade(ubase.BaseUpgrade): + name="system" + Name="System" + title="System Compatibility Version Check" + atype="A Compatible System" + + current_version_key="Current System Compatibility Version" + next_version_key="Next System Compatibility Version" + + def auto_upgrade_default(self): + return sysconfig.upgrade.system.auto + + def init_versions(self): + + # + # Current loader version file. + # If this file doesn't exist then in-place upgrade is not supported. + # + ETC_LOADER_VERSIONS_JSON = sysconfig.upgrade.loader.versions + + # Upgrade Loader Version file. + NEXT_LOADER_VERSIONS_JSON = os.path.join(sysconfig.upgrade.loader.package.dir, "manifest.json") + + VKEY = "SYSTEM_COMPATIBILITY_VERSION" + + self.current_version = self.load_json(ETC_LOADER_VERSIONS_JSON, VKEY, None) + + self.next_version = self.load_json(NEXT_LOADER_VERSIONS_JSON, + "version", {}).get(VKEY, None) + + def prepare_upgrade(self): + pass + + def summarize(self): + self.logger.info("Current System Compatibility Version: %s", + self.current_version) + self.logger.info(" Next System Compatibility Version: %s", + self.next_version) + self.logger.info("") + + + def upgrade_notes(self): + return """ + * One or more reboots will be required to complete this upgrade. +""" + + def do_upgrade(self, forced=False): + app = App(force=True, log=self.logger) + try: + code = app.run() + except: + self.logger.exception("upgrade failed") + code = 1 + app.shutdown() + if code: + self.abort("System upgrade failed.") + else: + self.logger.info("Upgrade succeeded, rebooting") + self.reboot() + +if __name__ == '__main__': + klass = SystemUpgrade + klass().main() diff --git a/packages/base/all/vendor-config-onl/src/sbin/onl-install-system b/packages/base/all/vendor-config-onl/src/sbin/onl-install-system new file mode 100755 index 00000000..9ae0fea3 --- /dev/null +++ b/packages/base/all/vendor-config-onl/src/sbin/onl-install-system @@ -0,0 +1,7 @@ +#!/usr/bin/python + +"""Re-install ONL using the ONL installer infrastructure. +""" + +import onl.install.SystemInstall +onl.install.SystemInstall.main() diff --git a/packages/base/all/vendor-config-onl/src/sbin/onl-upgrade-system b/packages/base/all/vendor-config-onl/src/sbin/onl-upgrade-system new file mode 100755 index 00000000..efc4bdc7 --- /dev/null +++ b/packages/base/all/vendor-config-onl/src/sbin/onl-upgrade-system @@ -0,0 +1,3 @@ +#!/usr/bin/python +from onl.upgrade.system import SystemUpgrade +SystemUpgrade().main() From 12b7eb52dfa6bfb41ac840d9773fcaba9636ba54 Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Wed, 26 Oct 2016 12:23:55 -0700 Subject: [PATCH 40/43] Move upgrade scripts to make room --- .../src/boot.d/{62.upgrade-loader => 63.upgrade-loader} | 0 .../src/boot.d/{63.upgrade-swi => 64.upgrade-swi} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename packages/base/all/vendor-config-onl/src/boot.d/{62.upgrade-loader => 63.upgrade-loader} (100%) rename packages/base/all/vendor-config-onl/src/boot.d/{63.upgrade-swi => 64.upgrade-swi} (100%) diff --git a/packages/base/all/vendor-config-onl/src/boot.d/62.upgrade-loader b/packages/base/all/vendor-config-onl/src/boot.d/63.upgrade-loader similarity index 100% rename from packages/base/all/vendor-config-onl/src/boot.d/62.upgrade-loader rename to packages/base/all/vendor-config-onl/src/boot.d/63.upgrade-loader diff --git a/packages/base/all/vendor-config-onl/src/boot.d/63.upgrade-swi b/packages/base/all/vendor-config-onl/src/boot.d/64.upgrade-swi similarity index 100% rename from packages/base/all/vendor-config-onl/src/boot.d/63.upgrade-swi rename to packages/base/all/vendor-config-onl/src/boot.d/64.upgrade-swi From 515a881bb5777e640c45846385aa0b62775b5fe0 Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Wed, 26 Oct 2016 17:33:29 -0700 Subject: [PATCH 41/43] Oops, botched merge --- .../all/vendor-config-onl/src/python/onl/install/BaseInstall.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --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 index dbdb0a5a..fffab336 100644 --- 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 @@ -693,7 +693,7 @@ class UbootInstaller(SubprocessMixin, Base): self.log.error("cannot get partition table from %s: %s", self.device, str(ex)) except Exception: - self.log.exception("cannot get partition table from %s" + self.log.exception("cannot get partition table from %s", self.device) self.log.info("creating msdos label on %s") From 3dd88819212fab8f0ad53099fa4066bafc83ef2a Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Mon, 7 Nov 2016 13:12:42 -0800 Subject: [PATCH 42/43] Updates for review feedback - use built-in mount context for ONL-BOOT - fix logger handle - minor nit for swiget if the SWI is missing --- .../src/python/onl/install/SystemInstall.py | 62 ++++--------------- 1 file changed, 11 insertions(+), 51 deletions(-) diff --git a/packages/base/all/vendor-config-onl/src/python/onl/install/SystemInstall.py b/packages/base/all/vendor-config-onl/src/python/onl/install/SystemInstall.py index d96557ac..b3339550 100644 --- a/packages/base/all/vendor-config-onl/src/python/onl/install/SystemInstall.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/install/SystemInstall.py @@ -1,6 +1,6 @@ """App.py -Application code for swl-install. +Application code for onl-install. """ import logging @@ -13,15 +13,16 @@ import argparse import fnmatch import subprocess -from onl.install.InstallUtils import InitrdContext, MountContext -from onl.install.InstallUtils import BlkidParser, ProcMountsParser +from onl.install.InstallUtils import InitrdContext +from onl.install.InstallUtils import ProcMountsParser from onl.install.ConfUtils import MachineConf, InstallerConf from onl.install.ShellApp import Onie, Upgrader -import onl.install.App -from onl.sysconfig import sysconfig -from onl.platform.current import OnlPlatform - from onl.install.InstallUtils import SubprocessMixin +import onl.install.App + +from onl.sysconfig import sysconfig + +from onl.mounts import OnlMountContextReadWrite class UpgradeHelper(Upgrader): @@ -33,47 +34,6 @@ class UpgradeHelper(Upgrader): if self.callback is not None: self.callback(self, p) -class OnlBootContext(object): - - def __init__(self, log=None): - self.log = log or logging.getLogger(self.__class__.__name__) - self.dctx = None - self.dir = None - - def __enter__(self): - pm = ProcMountsParser() - logger = self.log.getChild("blkid") - blkid = BlkidParser(log=logger) - - try: - dev = blkid['ONL-BOOT'].device - except IndexError: - dev = None - if dev is None: - raise ValueError("cannot find ONL-BOOT") - - parts = [p for p in pm.mounts if p.device == dev] - if parts: - self.log.debug("found ONL-BOOT at %s", parts[0].dir) - self.dir = parts[0].dir - return self - - # else, mount this: - with MountContext(dev, log=self.log) as self.dctx: - self.log.debug("mounted ONL-BOOT %s --> %s", - dev, self.dctx.dir) - self.dir = self.dctx.dir - self.dctx.detach() - - return self - - def __exit__(self, type, value, tb): - dctx, self.dctx = self.dctx, None - if dctx is not None: - dctx.attach() - dctx.shutdown() - return False - class App(SubprocessMixin): def __init__(self, force=False, log=None): @@ -186,8 +146,8 @@ class App(SubprocessMixin): self.log.debug("+ /bin/cp %s %s", src, dst) shutil.copy2(src, dst) - with OnlBootContext(log=self.log) as octx: - src = os.path.join(octx.dir, "boot-config") + with OnlMountContextReadWrite('ONL-BOOT', logger=self.log) as octx: + src = os.path.join(octx.directory, "boot-config") dst = os.path.join(abs_idir, "boot-config") self.log.debug("+ /bin/cp %s %s", src, dst) shutil.copy2(src, dst) @@ -263,7 +223,7 @@ class App(SubprocessMixin): def main(cls): logging.basicConfig() - logger = logging.getLogger("swl-install") + logger = logging.getLogger("onl-install") logger.setLevel(logging.DEBUG) # send to ONIE log From 19d19ef51ca1e68f7393d5aa0fd6915a705456e9 Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Mon, 7 Nov 2016 13:12:54 -0800 Subject: [PATCH 43/43] Fix swiget for if SWI is missing --- packages/base/all/initrds/loader-initrd-files/src/bin/swiget | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/base/all/initrds/loader-initrd-files/src/bin/swiget b/packages/base/all/initrds/loader-initrd-files/src/bin/swiget index 34615678..333674a9 100755 --- a/packages/base/all/initrds/loader-initrd-files/src/bin/swiget +++ b/packages/base/all/initrds/loader-initrd-files/src/bin/swiget @@ -284,7 +284,7 @@ class Runner(onl.install.InstallUtils.SubprocessMixin): l = [x for x in os.listdir(d) if x.endswith('.swi')] l = [os.path.join(d, x) for x in l] l.sort(key=swiSortKey) - return l[-1] + return l[-1] if l else None pm = ProcMountsParser() parts = [x for x in pm.mounts if x.device == dev] @@ -294,6 +294,9 @@ class Runner(onl.install.InstallUtils.SubprocessMixin): self.log.info("found 'latest' swi %s", dst) else: dst = os.path.join(parts[0].dir, src) + if dst is None: + self.log.error("missing SWI") + return None if not os.path.exists(dst): self.log.error("missing SWI: %s", dst) return None