Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script to update/upgrade all components of SDC/Triton
[root@headnode (barovia) ~]# cat /opt/custom/bin/update-all
#!/bin/bash
set -o errexit
set -o xtrace
imgadm vacuum -f
sdcadm update --all --just-images -y
sdcadm self-update --allow-major-update --latest
sdcadm dc-maint start && printf "DC maintenance has started at %s\n" "$(date)"
sdcadm update --all -y
sdcadm experimental update-agents --latest --all -y
sdcadm experimental update-other
sdcadm experimental update-gz-tools --latest
sdcadm dc-maint stop && printf "DC maintenance has ended at %s\n" "$(date)"
sdcadm platform remove -a --cleanup-cache -y
sdcadm platform install --latest
sdcadm platform assign --latest --all
sdcadm platform set-default --latest
sdc-oneachnode -a 'sdc-usbkey update'
# Optional, will disrupt fabric network traffic
sdcadm update portolan --force-data-path
printf 'Update of all components complete\n'
now=$(date +%Y%m%dT%H%M%SZ)
sdc-vmapi /vms?state=active\&tag.smartdc_type=core | json -Ha > "/opt/custom/core_services_${now}.json"
exit
update-agents Update SDC agents
dc-maint Show and modify the DC maintenance mode.
update-other Temporary grabbag for small SDC update steps.
update-gz-tools Temporary grabbag for updating the SDC global zone tools.
add-new-agent-svcs Temporary grabbag for installing the SDC global zone new agents.
update-docker Add/update the docker service.
install-docker-cert Installs a custom TLS certificate to be used by sdc-docker.
portolan Add/update the portolan service.
fabrics Initialize fabrics in the datacenter.
default-fabric Initialize a default fabric for an account.
@bahamat

This comment has been minimized.

Copy link
Owner Author

@bahamat bahamat commented May 15, 2020

The following script can be used to reboot all compute nodes, but you need to be sure this isn't going to disrupt your tenants.

#!/bin/bash

if [[ -n "$TRACE" ]]; then
    export PS4='[\D{%FT%TZ}] ${BASH_SOURCE}:${LINENO}: ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
    set -o xtrace
fi

# Stage each CN to reboot in 10m intervals
for s in $(sdc-server lookup hostname!=headnode -j | sort | json -ga hostname); do
        printf '%s will reboot in %d m.\n' "$s" "${time:=1}"
        sdc-oneachnode -n "$s" 'echo "init 6" | at now +'${time}'minute'
        time=$(( time + 10 ))
done
printf 'headnode will reboot in %d m.\n' "$time"
echo "init 6" | at now +${time}minute
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment