Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[device/arista]: Update #2336

Merged
merged 8 commits into from
Dec 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions device/arista/x86_64-arista_7170_64c/fancontrol
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
INTERVAL=5
DEVPATH=hwmon1=devices/pci0000:00/0000:00:1c.0/0000:06:00.0/i2c-8/8-004c hwmon3=devices/pci0000:ff/0000:ff:0b.3/i2c-93/93-0060
DEVNAME=hwmon1=max6658 hwmon3=rook_cpld
FCTEMPS=hwmon3/pwm4=hwmon1/temp1_input hwmon3/pwm3=hwmon1/temp1_input hwmon3/pwm2=hwmon1/temp1_input hwmon3/pwm1=hwmon1/temp1_input
FCFANS=hwmon3/pwm4=hwmon3/fan4_input hwmon3/pwm3=hwmon3/fan3_input hwmon3/pwm2=hwmon3/fan2_input hwmon3/pwm1=hwmon3/fan1_input
MINTEMP=hwmon3/pwm4=50 hwmon3/pwm3=50 hwmon3/pwm2=50 hwmon3/pwm1=50
MINPWM=hwmon3/pwm4=128 hwmon3/pwm3=128 hwmon3/pwm2=128 hwmon3/pwm1=128
MAXTEMP=hwmon3/pwm4=60 hwmon3/pwm3=60 hwmon3/pwm2=60 hwmon3/pwm1=60
MINSTART=hwmon3/pwm4=128 hwmon3/pwm3=128 hwmon3/pwm2=128 hwmon3/pwm1=128
MINSTOP=hwmon3/pwm4=128 hwmon3/pwm3=128 hwmon3/pwm2=128 hwmon3/pwm1=128
DEVPATH=hwmon2=devices/pci0000:00/0000:00:1c.0/0000:06:00.0/i2c-8/8-004c hwmon4=devices/pci0000:ff/0000:ff:0b.3/i2c-93/93-0060
DEVNAME=hwmon2=max6658 hwmon4=rook_cpld
FCTEMPS=hwmon4/pwm4=hwmon2/temp1_input hwmon4/pwm3=hwmon2/temp1_input hwmon4/pwm2=hwmon2/temp1_input hwmon4/pwm1=hwmon2/temp1_input
FCFANS=hwmon4/pwm4=hwmon4/fan4_input hwmon4/pwm3=hwmon4/fan3_input hwmon4/pwm2=hwmon4/fan2_input hwmon4/pwm1=hwmon4/fan1_input
MINTEMP=hwmon4/pwm4=50 hwmon4/pwm3=50 hwmon4/pwm2=50 hwmon4/pwm1=50
MINPWM=hwmon4/pwm4=128 hwmon4/pwm3=128 hwmon4/pwm2=128 hwmon4/pwm1=128
MAXTEMP=hwmon4/pwm4=60 hwmon4/pwm3=60 hwmon4/pwm2=60 hwmon4/pwm1=60
MINSTART=hwmon4/pwm4=128 hwmon4/pwm3=128 hwmon4/pwm2=128 hwmon4/pwm1=128
MINSTOP=hwmon4/pwm4=128 hwmon4/pwm3=128 hwmon4/pwm2=128 hwmon4/pwm1=128
14 changes: 10 additions & 4 deletions device/arista/x86_64-arista_7170_64c/sensors.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ chip "max6658-i2c-8-4c"

set temp1_max 100
set temp1_crit 110
set temp1_min -55

set temp2_max 100
set temp2_crit 110
set temp2_min -55
ignore temp2

chip "dps1900-i2c-6-58"
Expand Down Expand Up @@ -42,10 +46,12 @@ chip "max6658-i2c-81-4c"
label temp1 "Rear air temp1"
label temp2 "Rear air temp2"

set temp1_max 50
set temp1_crit 60
set temp2_max 50
set temp2_crit 60
set temp1_max 70
set temp1_crit 80
set temp1_min -55
set temp2_max 70
set temp2_crit 80
set temp2_min -55

chip "lm73-i2c-96-48"
label temp1 "Front air temp"
Expand Down
87 changes: 71 additions & 16 deletions files/Aboot/boot0.j2
Original file line number Diff line number Diff line change
Expand Up @@ -32,31 +32,37 @@
# - KERNEL : relative path to the kernel to execute
# - INITRD : relative path to the initrd to load
# - CMDLINE : place to find the default kernel cmdline to use for the platform
# - VERBOSE : setting it to 1 will enable debug traces
#
# By default the boot0 script will behave for an Aboot based behavior.
# Options can be provided to only run some features of this script.
#
# Extra kernel parameters can be provided at runtime by the user by adding them
# into a kernel-params file.

set -x

image_name="image-%%IMAGE_VERSION%%"
dockerfs="{{ FILESYSTEM_DOCKERFS }}"

do_not_clean="do-not-clean"
kernel_params="kernel-params"

aboot_machine="arista_unknown"

info() { printf "%04.2f: $@\n" "$(cut -f1 -d' ' /proc/uptime)"; }
err() { info "Error: $@"; }
warn() { info "Warning: $@"; }

# extract mount point from the swi path, e.g., /mnt/flash/sonic.swi --> /mnt/flash
if [ -z "$target_path" ]; then
if [ -z "$swipath" ]; then
echo "target_path= is required when swipath= is not provided"
err "target_path= is required when swipath= is not provided"
exit 1
fi
target_path=$(df "$swipath" | tail -1 | tr -s " " | cut -d ' ' -f6)
fi
image_path="$target_path/$image_name"
hook_path="$image_path/platform/hooks"
data_path="$image_path/platform/data"

cmdline_base="$target_path/kernel-params-base"
cmdline_image="$image_path/kernel-cmdline"
Expand All @@ -65,6 +71,9 @@ boot_config="$target_path/boot-config"
bootconfigvars="KERNEL INITRD CONSOLESPEED PASSWORD NETDEV NETAUTO NETIP NETMASK NETGW NETDOMAIN NETDNS NETHW memtest"
flash_re=" /mnt/flash| /host"

# for backward compatibility with the sonic_upgrade= behavior
install="${install:-${sonic_upgrade:-}}"

parse_environment_config() {
for n in ${bootconfigvars}; do
eval v="\$$n"
Expand All @@ -81,6 +90,7 @@ clean_flash() {
[ $f != "boot-config" ] &&
[ $f != "$kernel_params" ] &&
[ $f != "$cmdline_base" ] &&
[ $f != "aquota.user" ] &&
[ $f != "old_config" ] &&
[ $f != "minigraph.xml" ]
then
Expand Down Expand Up @@ -110,7 +120,7 @@ update_next_boot() {
local default="$(get_boot_config SWI_DEFAULT)"

if [ -z "$default" ]; then
echo "warning: no variable SWI_DEFAULT available"
warn "boot-config has no variable SWI_DEFAULT"
else
update_boot_config SWI "$default"
fi
Expand All @@ -119,26 +129,29 @@ update_next_boot() {
extract_image() {
mkdir -p "$image_path"

info "Extracting swi content"
## Unzip the image except boot0 and dockerfs archive
unzip -oq "$swipath" -x boot0 {{ FILESYSTEM_DOCKERFS }} -d "$image_path"
unzip -oq "$swipath" -x boot0 "$dockerfs" -d "$image_path"

## detect rootfs type
rootfs_type=`grep " $target_path " /proc/mounts | cut -d' ' -f3`

info "Extracting $dockerfs from swi"
## vfat does not support symbol link
if [ -n "$sonic_upgrade" ] || [ "$rootfs_type" != "vfat" ]; then
if [ -n "$install" ] || [ "$rootfs_type" != "vfat" ]; then
mkdir -p "$image_path/{{ DOCKERFS_DIR }}"

if [ -n "$sonic_upgrade" ]; then
TAR_EXTRA_OPTION="--numeric-owner"
if [ -n "$install" ]; then
TAR_EXTRA_OPTION="--numeric-owner --warning=no-timestamp"
fi

## extract docker archive
unzip -oqp "$swipath" {{ FILESYSTEM_DOCKERFS }} | tar xzf - -C "$image_path/{{ DOCKERFS_DIR }}" $TAR_EXTRA_OPTION
info "Unpacking $dockerfs"
unzip -oqp "$swipath" "$dockerfs" | tar xzf - -C "$image_path/{{ DOCKERFS_DIR }}" $TAR_EXTRA_OPTION
else
## save dockerfs archive in the image directory
unzip -oq "$swipath" {{ FILESYSTEM_DOCKERFS }} -d "$image_path"
echo "$target_path is $rootfs_type, extract {{ FILESYSTEM_DOCKERFS }} in later stage"
unzip -oq "$swipath" "$dockerfs" -d "$image_path"
info "Unpacking $dockerfs delayed to initrd because $target_path is $rootfs_type"
fi

## use new reduced-size boot swi
Expand Down Expand Up @@ -263,7 +276,7 @@ write_boot_configs() {
elif [ -f /sys/class/net/eth0/address ]; then
echo "hwaddr_ma1=$(cat /sys/class/net/eth0/address)" >> /tmp/append
else
echo "ERROR: Management port is not found."
err "Management port not found."
fi

# use extra parameters from kernel-params hook if the file exists
Expand Down Expand Up @@ -292,13 +305,34 @@ run_kexec() {
local kernel="${KERNEL:-$(find $image_path/boot -name 'vmlinuz-*' -type f | head -n 1)}"
local initrd="${INITRD:-$(find $image_path/boot -name 'initrd.img-*' -type f | head -n 1)}"

if ! $verbose; then
# Start showing systemd information from the first failing unit if any.
# systemd.show_status=false or quiet can be used to silence systemd entierly
cmdline="$cmdline systemd.show_status=auto"
fi

kexec --load --initrd="$initrd" --append="$cmdline" "$kernel"

[ -z "$testonly" ] || exit 0
echo "kexecing..."
info "Kexecing..."
kexec --exec
}

get_sorted_hooks() {
echo $(find "$1" -name '[0-9][0-9]-*' -type f)
}

run_hooks() {
if [ -d "$hook_path/$1" ]; then
for hook in $(get_sorted_hooks "$hook_path/$1"); do
if [ ! -z "$hook" ]; then
info "Running hook $hook"
. "$hook"
fi
done
fi
}

# In Aboot no option will be provided therefore these are the default values to use
in_aboot=true
do_clean=true
Expand All @@ -311,7 +345,7 @@ if [ -f "$target_path/$do_not_clean" ]; then
fi

# Parse the cmdline options (used from EOS or from SONiC)
if [ ! -z "$install" ] || [ ! -z "$sonic_upgrade" ]; then
if [ ! -z "$install" ]; then
# install from SONiC or EOS
in_aboot=false
do_clean=false
Expand All @@ -326,11 +360,24 @@ elif [ $# -ne 0 ]; then
exit 1
fi

# Verbosity can be defined by the caller, default to false otherwise
verbose=${verbose:-false}
if [ -f "$target_path/verbose-boot" ] ||
[ "$(get_boot_config VERBOSE)" = "1" ] ||
! $in_aboot; then
verbose=true
fi

# enable shell debug mode to get the most verbosity
if $verbose; then
set -x
fi

# install the image if newer
if $do_install; then
# we expect the swi to install to be a non empty file
if [ ! -s "$swipath" ]; then
echo "The swipath= environment variable does not point to a valid SWI"
err "The swipath= environment variable does not point to a valid SWI"
exit 1
fi

Expand All @@ -340,17 +387,25 @@ if $do_install; then

if [ "$GIT_REVISION" != "$LOCAL_IMAGEHASH" ] || [ ! -z "$force" ]; then
if $do_clean; then
info "Cleaning flash content $target_path"
clean_flash
fi

info "Installing image under $image_path"
extract_image

info "Generating boot-config, machine.conf and cmdline"
write_boot_configs

run_hooks post-install
else
info "Using previously installed image"
fi
fi

# chainloading using kexec
if $do_kexec; then
run_hooks pre-kexec
update_next_boot
run_kexec
fi

89 changes: 57 additions & 32 deletions files/initramfs-tools/arista-convertfs.j2
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,25 @@ block_flash=''
aboot_flag=''
backup_file=''

# Get the fullpath of flash device, e.g., /dev/sda
get_flash_dev() {
for dev in $(ls /sys/block); do
local is_mmc=$(echo "$dev" | grep 'mmcblk.*boot.*' | cat)
if [ -n "$is_mmc" ]; then
continue
fi
local devid=$(realpath "/sys/block/$dev/device")
local is_device=$(echo "$devid" | grep '^/sys/devices/' | cat)
local is_flash=$(echo "$devid" | grep "$block_flash" | cat)
if [ -n "$is_device" -a -n "$is_flash" ]; then
flash_dev="/dev/$dev"
return 0
fi
# Wait until get the fullpath of flash device, e.g., /dev/sda
wait_get_flash_dev() {
local try_rounds=30
while [ $try_rounds -gt 0 ]; do
for dev in $(ls /sys/block); do
local is_mmc=$(echo "$dev" | grep 'mmcblk.*boot.*' | cat)
if [ -n "$is_mmc" ]; then
continue
fi
local devid=$(realpath "/sys/block/$dev/device")
local is_device=$(echo "$devid" | grep '^/sys/devices/' | cat)
local is_flash=$(echo "$devid" | grep "$block_flash" | cat)
if [ -n "$is_device" -a -n "$is_flash" ]; then
flash_dev="/dev/$dev"
return 0
fi
done
sleep 1
try_rounds=$(( $try_rounds - 1 ))
done
return 1
}
Expand Down Expand Up @@ -95,6 +100,22 @@ fixup_flash_permissions() {
setfacl -Rb "$flash_mnt"
}

# Update ROOT device referring to the path under block_flash
# This is for the occasional name swap between /dev/sda and /dev/sdb
update_root() {
# Check that root=/dev/*, ignoring any cases like root=UUID=*
[ "${ROOT#/dev}" = "${ROOT}" ] && return 0

# Replace the beginning chars of ROOT by the ones of flash_dev with same index
{% raw %}
prefix_length="${#flash_dev}"
{% endraw %}
part_id="${ROOT:$prefix_length}"
ROOT="$flash_dev$part_id"

echo "ROOT=$ROOT" > /conf/param.conf
}

# Extract kernel parameters
set -- $(cat /proc/cmdline)
for x in "$@"; do
Expand All @@ -111,10 +132,24 @@ for x in "$@"; do
;;
esac
done
root_dev="$ROOT"

#Check aboot and root_dev is vfat
#Check aboot
[ -z "$aboot_flag" ] && exit 0

# Get flash dev name
if [ -z "$block_flash" ]; then
echo "Error: flash device info is not provided"
exit 1
fi
if ! wait_get_flash_dev; then
echo "Error: flash device is not found"
exit 1
fi

# If root=/dev/*, update ROOT to the device under block_flash
update_root

root_dev="$ROOT"
if [ -z "$root_dev" ]; then
echo "Error: root device name is not provided"
exit 1
Expand All @@ -126,22 +161,12 @@ fi

# exit when the root is ext4
if ! blkid | grep "$root_dev.*vfat" -q; then
mkdir -p "$root_mnt"
mount -t ext4 "$root_dev" "$root_mnt"
fixup_flash_permissions "$root_mnt"
umount "$root_mnt"
rmdir "$root_mnt"
exit 0
fi

# Get flash dev name
if [ -z "$block_flash" ]; then
echo "Error: flash device info is not provided"
exit 1
fi
if ! get_flash_dev; then
echo "Error: flash device is not found"
exit 1
mkdir -p "$root_mnt"
mount -t ext4 "$root_dev" "$root_mnt"
fixup_flash_permissions "$root_mnt"
umount "$root_mnt"
rmdir "$root_mnt"
exit 0
fi

# Check memory size for tmpfs
Expand Down