Commit 72d6a8e6 authored by Leigh Stoller's avatar Leigh Stoller

Initial checkin of ONIE clientside.

* Add onie-dongle and onie-dongle-install targets, which builds and
  installs (DESTDIR required) the bits and pieces we need. This install
  is intended to update the initram FS. ONIE operates as the admin MFS
  and the "frisbee" MFS, bootinfoclient used to emulate PXEWAIT
  waitmode.

* Need to be build in the ONIE cross compiler environment, see the
  ftos.env and mlnx.env for the environment variables before config and
  build.

* Basic operation is like the old CDROM; use bootinfoclient and tmcc
  bootwhat to drop into "admin" or "frisbee" mode, or boot the NOS. Use
  tmcc loadinfo and call onie-nos-install. Use a grub environment
  variable to tell grub to either boot the NOS (and then clear the
  variable) or boot into ONIE.
parent cf9096c3
# #
# Copyright (c) 2000-2017 University of Utah and the Flux Group. # Copyright (c) 2000-2018 University of Utah and the Flux Group.
# #
# {{{EMULAB-LICENSE # {{{EMULAB-LICENSE
# #
...@@ -63,6 +63,16 @@ post-install: post-install-subdirs ...@@ -63,6 +63,16 @@ post-install: post-install-subdirs
clean: clean-subdirs clean: clean-subdirs
distclean: distclean-subdirs distclean: distclean-subdirs
onie-dongle:
$(MAKE) -C lib onie-dongle
$(MAKE) -C os onie-dongle
$(MAKE) -C tmcc onie-dongle
onie-dongle-install: onie-dongle
$(MAKE) -C lib onie-dongle-install
$(MAKE) -C os onie-dongle-install
$(MAKE) -C tmcc onie-dongle-install
destdircheck: destdircheck:
@if [ -z "$(DESTDIR)" ]; then \ @if [ -z "$(DESTDIR)" ]; then \
echo "You must define DESTDIR for this target!"; \ echo "You must define DESTDIR for this target!"; \
......
...@@ -4634,6 +4634,7 @@ outfiles="Makeconf GNUmakefile setversion \ ...@@ -4634,6 +4634,7 @@ outfiles="Makeconf GNUmakefile setversion \
tmcc/plab/GNUmakefile tmcc/cygwinseven/GNUmakefile \ tmcc/plab/GNUmakefile tmcc/cygwinseven/GNUmakefile \
tmcc/centos6/GNUmakefile \ tmcc/centos6/GNUmakefile \
tmcc/centos7/GNUmakefile \ tmcc/centos7/GNUmakefile \
tmcc/onie/GNUmakefile \
os/GNUmakefile os/syncd/GNUmakefile \ os/GNUmakefile os/syncd/GNUmakefile \
os/dijkstra/GNUmakefile os/genhostsfile/GNUmakefile \ os/dijkstra/GNUmakefile os/genhostsfile/GNUmakefile \
os/frisbee.redux/GNUmakefile \ os/frisbee.redux/GNUmakefile \
......
...@@ -322,6 +322,7 @@ outfiles="Makeconf GNUmakefile setversion \ ...@@ -322,6 +322,7 @@ outfiles="Makeconf GNUmakefile setversion \
tmcc/plab/GNUmakefile tmcc/cygwinseven/GNUmakefile \ tmcc/plab/GNUmakefile tmcc/cygwinseven/GNUmakefile \
tmcc/centos6/GNUmakefile \ tmcc/centos6/GNUmakefile \
tmcc/centos7/GNUmakefile \ tmcc/centos7/GNUmakefile \
tmcc/onie/GNUmakefile \
os/GNUmakefile os/syncd/GNUmakefile \ os/GNUmakefile os/syncd/GNUmakefile \
os/dijkstra/GNUmakefile os/genhostsfile/GNUmakefile \ os/dijkstra/GNUmakefile os/genhostsfile/GNUmakefile \
os/frisbee.redux/GNUmakefile \ os/frisbee.redux/GNUmakefile \
......
# #
# Copyright (c) 2000-2016 University of Utah and the Flux Group. # Copyright (c) 2000-2018 University of Utah and the Flux Group.
# #
# {{{EMULAB-LICENSE # {{{EMULAB-LICENSE
# #
...@@ -51,6 +51,12 @@ mfs frisbee-mfs newnode-mfs: ...@@ -51,6 +51,12 @@ mfs frisbee-mfs newnode-mfs:
$(MAKE) -C tmcd client $(MAKE) -C tmcd client
mfs-install frisbee-mfs-install newnode-mfs-install: mfs-install frisbee-mfs-install newnode-mfs-install:
onie-dongle:
$(MAKE) -C libtb client
$(MAKE) -C tmcd client
onie-dongle-install: onie-dongle
# How to recursively descend into subdirectories to make general # How to recursively descend into subdirectories to make general
# targets such as `all'. # targets such as `all'.
%.MAKE: %.MAKE:
......
...@@ -150,9 +150,14 @@ mfs-install: ...@@ -150,9 +150,14 @@ mfs-install:
newnode-mfs: mfs newnode-mfs: mfs
newnode-mfs-install: mfs-install newnode-mfs-install: mfs-install
cdboot-install: mfs-install cdboot-install: mfs-install
onie-dongle:
$(MAKE) -C bootinfo onie-dongle
onie-dongle-install:
$(MAKE) -C bootinfo onie-dongle-install
subdir-distclean: subdir-distclean:
@$(MAKE) -C imagezip distclean @$(MAKE) -C imagezip distclean
......
...@@ -52,5 +52,10 @@ client: all ...@@ -52,5 +52,10 @@ client: all
client-install: client client-install: client
$(INSTALL_PROGRAM) bootinfoclient $(DESTDIR)$(CLIENT_BINDIR) $(INSTALL_PROGRAM) bootinfoclient $(DESTDIR)$(CLIENT_BINDIR)
onie-dongle: client
onie-dongle-install:
$(INSTALL) -m 755 -o root -g root -d $(DESTDIR)/etc/testbed
$(INSTALL_PROGRAM) bootinfoclient $(DESTDIR)/etc/testbed
clean: clean:
rm -f *.o bootinfoclient rm -f *.o bootinfoclient
...@@ -204,6 +204,10 @@ frisbee-mfs: client ...@@ -204,6 +204,10 @@ frisbee-mfs: client
frisbee-mfs-install: frisbee-mfs frisbee-mfs-install: frisbee-mfs
@$(MAKE) -C $(MDSUBDIR) frisbee-mfs-install @$(MAKE) -C $(MDSUBDIR) frisbee-mfs-install
onie-dongle: tmcc tmcc-nossl
onie-dongle-install: onie-dongle
@$(MAKE) -C onie onie-dongle-install
newnode-mfs: client newnode-mfs: client
newnode-mfs-install: newnode-mfs newnode-mfs-install: newnode-mfs
......
#
# Copyright (c) 2000-2018 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
# This file is part of the Emulab network testbed software.
#
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
# License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this file. If not, see <http://www.gnu.org/licenses/>.
#
# }}}
#
SRCDIR = @srcdir@
TESTBED_SRCDIR = @top_srcdir@
OBJDIR = @top_builddir@
SUBDIR = $(subst $(TESTBED_SRCDIR)/,,$(SRCDIR))
include $(OBJDIR)/Makeconf
SCRIPTS =
#
# Force dependencies on the scripts so that they will be rerun through
# configure if the .in file is changed.
#
all:
include $(TESTBED_SRCDIR)/GNUmakerules
SYSETCDIR = $(DESTDIR)/etc
SYSBINDIR = $(DESTDIR)/bin
ETCDIR = $(DESTDIR)$(CLIENT_ETCDIR)
BINDIR = $(DESTDIR)$(CLIENT_BINDIR)
VARDIR = $(DESTDIR)$(CLIENT_VARDIR)
RCDIR = $(SYSETCDIR)/init.d
DEFRUNLVLDIR = $(SYSETCDIR)/rc3.d
INSTALL = /usr/bin/install -c
install client-install: bin-install etc-install
onie-dongle-install: install
dir-install:
$(INSTALL) -m 755 -o root -g root -d $(SYSETCDIR)/testbed
$(INSTALL) -m 775 -o root -g root -d $(SYSETCDIR)/init.d
$(INSTALL) -m 775 -o root -g root -d $(SYSETCDIR)/rc3.d
$(INSTALL) -m 775 -o root -g root -d $(SYSBINDIR)
baselinux-%: dir-install
@echo "no baselinux common files"
common-install: dir-install
@echo "no arch common files"
bin-install: dir-install
$(INSTALL) -m 755 ../tmcc-nossl $(SYSETCDIR)/testbed/tmcc
etc-install: dir-install sysetc-install
$(INSTALL) -m 755 $(SRCDIR)/testbed.sh $(RCDIR)/testbed.sh
-ln -sf ../init.d/testbed.sh $(DEFRUNLVLDIR)/S90testbed
$(INSTALL) -m 755 $(SRCDIR)/exec_installer $(SYSBINDIR)/exec_installer
sysetc-install: dir-install
$(INSTALL) -m 755 $(SRCDIR)/rc.testbed $(SYSETCDIR)/testbed/rc.testbed
$(INSTALL) -m 755 $(SRCDIR)/rc.reload $(SYSETCDIR)/testbed/rc.reload
# Onie has a broken broken resolver
echo "boss" > $(SYSETCDIR)/testbed/bossnode
clean:
This diff is collapsed.
CFLAGS="-I/mnt/onie/build/user/x86_64-g4.9.2-lnx3.2.69-uClibc-ng-1.0.22//openssl/openssl-1.0.2l/include/ -L/mnt/onie/build//user/x86_64-g4.9.2-lnx3.2.69-uClibc-ng-1.0.22/dev-sysroot/usr/lib"
export CFLAGS
CC=/mnt/onie/build/x-tools/x86_64-g4.9.2-lnx3.2.69-uClibc-ng-1.0.22/install/x86_64-onie-linux-uclibc/bin/x86_64-cc
export CC
CXX=/mnt/onie/build/x-tools/x86_64-g4.9.2-lnx3.2.69-uClibc-ng-1.0.22/install/x86_64-onie-linux-uclibc/bin/x86_64-c++
export CXX
CPP=/mnt/onie/build/x-tools/x86_64-g4.9.2-lnx3.2.69-uClibc-ng-1.0.22/install/x86_64-onie-linux-uclibc/bin/x86_64-cpp
export CPP
LIBS=-L/mnt/onie/build//user/x86_64-g4.9.2-lnx3.2.69-uClibc-ng-1.0.22/dev-sysroot/usr/lib
export LIBS
CFLAGS="-I/mnt/onie/build/user/x86_64-g6.3.0-lnx4.9.80-uClibc-ng-1.0.22//openssl/openssl-1.0.2l/include/ -L/mnt/onie/build//user/x86_64-g6.3.0-lnx4.9.80-uClibc-ng-1.0.22/dev-sysroot/usr/lib"
export CFLAGS
CC=/mnt/onie/build/x-tools/x86_64-g6.3.0-lnx4.9.80-uClibc-ng-1.0.22/install/x86_64-onie-linux-uclibc/bin/x86_64-cc
export CC
CXX=/mnt/onie/build/x-tools/x86_64-g6.3.0-lnx4.9.80-uClibc-ng-1.0.22/install/x86_64-onie-linux-uclibc/bin/x86_64-c++
export CXX
CPP=/mnt/onie/build/x-tools/x86_64-g6.3.0-lnx4.9.80-uClibc-ng-1.0.22/install/x86_64-onie-linux-uclibc/bin/x86_64-cpp
export CPP
LIBS=-L/mnt/onie/build//user/x86_64-g6.3.0-lnx4.9.80-uClibc-ng-1.0.22/dev-sysroot/usr/lib
export LIBS
#!/bin/sh
#
# Copyright (c) 2000-2018 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
# This file is part of the Emulab network testbed software.
#
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
# License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this file. If not, see <http://www.gnu.org/licenses/>.
#
# }}}
#
# The device is always the same in ONIE.
DISKDEV=/dev/sda
if [ -r /etc/emulab/paths.sh ]; then
. /etc/emulab/paths.sh
else
BINDIR=/etc/testbed
BOOTDIR=/etc/testbed
ETCDIR=/etc/testbed
fi
TMCC="$BINDIR/tmcc"
BOSSNAME=`$TMCC bossinfo | cut -d ' ' -f 2`
#
# Extract a variable of interest from the VAR=VALUE string and return value.
# If variable does not exist, return the given default (if provided).
#
getvar() {
local _VAR=$1
local _STR=$2
local _DFL=$3
for _kv in $_STR; do
_k=${_kv%%=*}
if [ -n "$_k" -a "$_k" = "$_VAR" ]; then
echo "${_kv##*=}"
return 0
fi
done
echo "$_DFL"
return 0
}
get_value()
{
local data=$1
local key=$2
echo `getvar $key "$data"`
return 0
}
#
# Zap whatever is installed on the "disk". We do this with parted
# rather then let onie uninstall do it, since it takes forever to
# zap the flash (which we do not want to do anyway).
#
zap_flash()
{
echo "Zapping the flash"
for i in 3 4 5 6 7 8 9 10 11 12 13 14 15; do
echo "-> clearing partition $i"
parted -s $DISKDEV rm $i
done
}
#
# Install the image using the onie installer. The only thing we care
# about in the loadinfo results is the path, which we have to munge
# into a URL into the downloads directory.
#
write_image()
{
local imagepath=$1
$TMCC state RELOADING
onie-nos-install $imagepath
rc=$?
return $rc
}
handle_loadinfo()
{
local LOADINFO="$1"
local IMAGEPATH=`get_value "$LOADINFO" PATH`
#
# Munge the path into a URL.
#
IMAGENAME=`basename $IMAGEPATH`
IMAGEPATH="http://$BOSSNAME/downloads/$IMAGENAME"
echo "Munged image path to $IMAGEPATH";
zap_flash
write_image $IMAGEPATH || {
return 1
}
echo "Image load complete at `date`"
return 0
}
get_loadinfo()
{
# Occasionally there is some delay before tmcd reports back valid
# loadinfo, so try repeatedly for 30 seconds and give up if we don't
# get any data.
time=30
while [ $time -gt 0 ]; do
# Just write it out to a tempfile to avoid extra nasty
# shell script hacks.
$TMCC loadinfo > /tmp/loadinfo.out
[ -s /tmp/loadinfo.out ] && break
sleep 1
time=$(( $time - 1 ))
done
if [ $time -eq 0 ]; then
return 1
fi
return 0
}
$TMCC state RELOADSETUP
echo "Requesting loadinfo data... "
if ! get_loadinfo; then
echo "*** Failed to get loadinfo data" 1>&2
exit 2
fi
echo "Got loadinfo data"
#
# We expect just one image to load.
# If a load fails, we exit non-zero so that the rc script will drop into
# single-user mode.
#
while read line; do
echo "Loading image"
echo " LOADINFO=\"$line\""
if ! handle_loadinfo "$line"; then
echo "Failed to load disk, dropping to login prompt at `date`" 1>&2
exit 1
fi
done < /tmp/loadinfo.out
echo "`date`: Load finished"
echo "`date`: sending RELOADDONE"
$TMCC state RELOADDONE
echo "`date`: waiting a bit for server to react"
sleep 15;
exit 0
#!/bin/sh
#
# Copyright (c) 2000-2018 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
# This file is part of the Emulab network testbed software.
#
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
# License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this file. If not, see <http://www.gnu.org/licenses/>.
#
# }}}
#
# The device is always the same in ONIE.
DISKDEV=/dev/sda
# Special grub env file for our flipping.
EMULABENV=/mnt/onie-boot/emulabenv
if [ -r /etc/emulab/paths.sh ]; then
. /etc/emulab/paths.sh
else
BINDIR=/etc/testbed
BOOTDIR=/etc/testbed
ETCDIR=/etc/testbed
fi
TMCC="$BINDIR/tmcc"
#
# Extract a variable of interest from the VAR=VALUE string and return value.
# If variable does not exist, return the given default (if provided).
#
getvar() {
local _VAR=$1
local _STR=$2
local _DFL=$3
for _kv in $_STR; do
_k=${_kv%%=*}
if [ -n "$_k" -a "$_k" = "$_VAR" ]; then
echo "${_kv##*=}"
return 0
fi
done
echo "$_DFL"
return 0
}
get_value()
{
local data=$1
local key=$2
echo `getvar $key "$data"`
return 0
}
#
# Wait for bootinfo to send us a command.
#
waitmode()
{
echo "Waiting for something to do"
#
# We use bootinfoclient. If we get a reboot command do that,
# otherwise we just return to query bootwhat again.
#
local WHAT=`$BINDIR/bootinfoclient -s boss`
if [ $rc -ne 0 ]; then
echo "bootinfoclient returned $rc."
# Wait so we do not go into a tight loop trying to query. No rush.
sleep 10
return 1
fi
echo "bootinfo said to $WHAT"
# We reboot if told.
if [ "$WHAT" = "reboot" ]; then
/sbin/reboot
exit 0
fi
# Otherwise just return to query again.
return 0
}
#
# Reload the flash with a NOS.
#
reload_nos()
{
echo "Setting up to reload the NOS"
# Tell boss we are booting.
$TMCC state BOOTING
$BINDIR/rc.reload
if [ $rc -ne 0 ]; then
echo "Dropping into admin shell"
return 1
fi
boot_nos
# Should not return
return 1;
}
#
# Update the grubenv to tell grub to boot the NOS.
#
boot_nos()
{
echo "Setting up to boot the NOS"
if [ ! -s $EMULABENV ]; then
grub-editenv $EMULABENV create
if [ $rc -ne 0 ]; then
echo "Failed to create new grub env"
return 1
fi
fi
grub-editenv $EMULABENV set bootnos=yes
if [ $rc -ne 0 ]; then
echo "Failed to update grub env with bootnos=yes"
return 1
fi
echo "Rebooting into the NOS"
/sbin/reboot
exit 0;
}
#
# We might need to wait for something to do, so loop.
#
while : ; do
# Ask what we are supposed to boot.
BOOTWHAT=`$TMCC bootwhat`
rc=$?
if [ $rc -ne 0 -o "$BOOTWHAT" = "" ]; then
echo "Failed to get bootwhat, status $rc. Waiting a bit."
sleep 10
continue
fi
TYPE=`get_value "$BOOTWHAT" TYPE`
#
# Look to see if we are in wait mode.
#
if [ $TYPE -eq 4 ]; then
waitmode
# Just loop to query again.
continue;
fi
WHAT=`get_value "$BOOTWHAT" WHAT`
case $WHAT in
1)
boot_nos
# Does not return
exit 1
;;
*onie_reload)
reload_nos
# Does not return
exit 1
;;
*onie_admin)
echo "Dropping into admin mode"
# Tell boss we are running
$TMCC state ISUP
exit 0
;;
*)
echo "Bad BOOTWHAT: $BOOTWHAT";
echo "Dropping into shell"
exit 1
;;
esac
done
#!/bin/sh
cmd="$1"
daemon="testbed"
ARGS=
. /lib/onie/functions
case $cmd in
start)
log_begin_msg "Starting: $daemon"
/etc/testbed/rc.testbed &
log_end_msg
;;
stop)
;;
*)
esac
# #
# Copyright (c) 2000-2015 University of Utah and the Flux Group. # Copyright (c) 2000-2018 University of Utah and the Flux Group.
# #
# {{{EMULAB-LICENSE # {{{EMULAB-LICENSE
# #
...@@ -53,6 +53,7 @@ mfs: ...@@ -53,6 +53,7 @@ mfs:
mfs-install: mfs-install:
frisbee-mfs: frisbee-mfs:
frisbee-mfs-install: frisbee-mfs-install:
onie-dongle-install:
newnode-mfs: newnode-mfs:
@$(MAKE) -C teachswitch all @$(MAKE) -C teachswitch all
......
...@@ -7188,6 +7188,7 @@ outfiles="$outfiles clientside/GNUmakefile clientside/setversion \ ...@@ -7188,6 +7188,7 @@ outfiles="$outfiles clientside/GNUmakefile clientside/setversion \
clientside/tmcc/linux-sg/GNUmakefile clientside/tmcc/ubuntu7/GNUmakefile \ clientside/tmcc/linux-sg/GNUmakefile clientside/tmcc/ubuntu7/GNUmakefile \
clientside/tmcc/centos6/GNUmakefile \ clientside/tmcc/centos6/GNUmakefile \
clientside/tmcc/centos7/GNUmakefile \ clientside/tmcc/centos7/GNUmakefile \
clientside/tmcc/onie/GNUmakefile \
clientside/tmcc/ubuntu10/GNUmakefile \ clientside/tmcc/ubuntu10/GNUmakefile \
clientside/tmcc/ubuntu11/GNUmakefile \ clientside/tmcc/ubuntu11/GNUmakefile \
clientside/tmcc/ubuntu14/GNUmakefile \ clientside/tmcc/ubuntu14/GNUmakefile \
......
...@@ -1509,6 +1509,7 @@ outfiles="$outfiles clientside/GNUmakefile clientside/setversion \ ...@@ -1509,6 +1509,7 @@ outfiles="$outfiles clientside/GNUmakefile clientside/setversion \
clientside/tmcc/linux-sg/GNUmakefile clientside/tmcc/ubuntu7/GNUmakefile \ clientside/tmcc/linux-sg/GNUmakefile clientside/tmcc/ubuntu7/GNUmakefile \
clientside/tmcc/centos6/GNUmakefile \ clientside/tmcc/centos6/GNUmakefile \
clientside/tmcc/centos7/GNUmakefile \ clientside/tmcc/centos7/GNUmakefile \
clientside/tmcc/onie/GNUmakefile \
clientside/tmcc/ubuntu10/GNUmakefile \ clientside/tmcc/ubuntu10/GNUmakefile \
clientside/tmcc/ubuntu11/GNUmakefile \ clientside/tmcc/ubuntu11/GNUmakefile \
clientside/tmcc/ubuntu14/GNUmakefile \ clientside/tmcc/ubuntu14/GNUmakefile \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment