gh-85: Disk resize/attach triggers forced contextualization

pull/100/merge
Vlastimil Holer 7 years ago
parent f67fedc4ac
commit 27db916569
No known key found for this signature in database
GPG Key ID: EB549BADEFD07C53

@ -0,0 +1,15 @@
#!/sbin/openrc-run
name="OpenNebula forced run"
depend() {
use one-context one-context-local
keyword -stop -shutdown
}
start() {
ebegin "Starting one-context-force"
export TIMEOUT=0
/usr/sbin/one-context-run force
eend $?
}

@ -0,0 +1,44 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2010-2017, OpenNebula Systems #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
### BEGIN INIT INFO
# Provides: one-context-force
# Required-Start: one-context-local one-context
# Required-Stop:
# Should-Start: $time
# Should-Stop:
# Default-Start:
# Default-Stop: 0 1 2 3 4 5 6
# Short-Description: OpenNebula forced run
### END INIT INFO
. /lib/lsb/init-functions
case "$1" in
start)
export TIMEOUT=0
log_daemon_msg $"Starting OpenNebula forced reconfiguration"
/usr/sbin/one-context-run force
log_end_msg $?
;;
*)
log_action_msg $"Usage: $0 {start}"
exit 2
esac
exit $?

@ -0,0 +1,47 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2010-2017, OpenNebula Systems #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
# chkconfig: - 99 1
# description: OpenNebula forced run
### BEGIN INIT INFO
# Provides: one-context-force
# Required-Start: one-context-local one-context
# Required-Stop:
# Should-Start: $time
# Should-Stop:
# Default-Start:
# Default-Stop: 0 1 2 3 4 5 6
# Short-Description: OpenNebula forced run
### END INIT INFO
# Source function library.
. /etc/rc.d/init.d/functions
case "$1" in
start)
export TIMEOUT=0
action $"Starting OpenNebula forced reconfiguration: " \
/usr/sbin/one-context-run force
;;
*)
echo $"Usage: $0 {start}"
exit 2
esac
exit $?

@ -10,6 +10,6 @@ depend() {
start() {
ebegin "Starting one-context-reconfigure"
export TIMEOUT=0
/usr/sbin/one-context-reconfigure
/usr/sbin/one-context-run
eend $?
}

@ -33,7 +33,7 @@ case "$1" in
start)
export TIMEOUT=0
log_daemon_msg $"Starting OpenNebula reconfiguration"
/usr/sbin/one-context-reconfigure
/usr/sbin/one-context-run
log_end_msg $?
;;
*)

@ -37,7 +37,7 @@ case "$1" in
start)
export TIMEOUT=0
action $"Starting OpenNebula reconfiguration: " \
/usr/sbin/one-context-reconfigure
/usr/sbin/one-context-run
;;
*)
echo $"Usage: $0 {start}"

@ -9,6 +9,6 @@ depend() {
start() {
ebegin "Starting one-context-reconfigure-delayed"
/usr/sbin/one-context-reconfigure
/usr/sbin/one-context-run
eend $?
}

@ -32,7 +32,7 @@
case "$1" in
start)
log_daemon_msg $"Starting OpenNebula delayed reconfiguration"
/usr/sbin/one-context-reconfigure
/usr/sbin/one-context-run
log_end_msg $?
;;
*)

@ -36,7 +36,7 @@
case "$1" in
start)
action $"Starting OpenNebula delayed reconfiguration: " \
/usr/sbin/one-context-reconfigure
/usr/sbin/one-context-run
;;
*)
echo $"Usage: $0 {start}"

@ -0,0 +1,9 @@
description "OpenNebula forced run"
author "OpenNebula Systems <support@opennebula.systems>"
manual
task
env TIMEOUT=0
exec /usr/sbin/one-context-run force

@ -5,4 +5,4 @@ manual
task
expect fork
exec /usr/sbin/one-context-reconfigure
exec /usr/sbin/one-context-run

@ -6,4 +6,4 @@ task
env TIMEOUT=0
exec /usr/sbin/one-context-reconfigure
exec /usr/sbin/one-context-run

@ -6,3 +6,13 @@ SUBSYSTEM=="net", ACTION=="add", \
SUBSYSTEM=="block", ACTION=="change", \
ENV{ID_FS_TYPE}=="iso9660" ENV{ID_FS_LABEL_ENC}=="CONTEXT", \
RUN+="/sbin/service one-context-reconfigure restart"
# Handle disk resize
SUBSYSTEM=="block", ACTION=="change", \
ENV{RESIZE}=="1", \
RUN+="/sbin/service one-context-force restart"
# Handle swap hot-attach
SUBSYSTEM=="block", ACTION=="add", \
ENV{ID_FS_TYPE}=="swap", \
RUN+="/sbin/service one-context-force restart"

@ -10,3 +10,13 @@ SUBSYSTEM=="block", ACTION=="change", \
ENV{ID_FS_TYPE}=="iso9660" ENV{ID_FS_LABEL_ENC}=="CONTEXT", \
ENV{SEQNUM}=="*[02468]", \
RUN+="/usr/sbin/service one-context-reconfigure start"
# Handle disk resize
SUBSYSTEM=="block", ACTION=="change", \
ENV{RESIZE}=="1", \
RUN+="/usr/sbin/service one-context-force start"
# Handle swap hot-attach
SUBSYSTEM=="block", ACTION=="add", \
ENV{ID_FS_TYPE}=="swap", \
RUN+="/usr/sbin/service one-context-force start"

@ -9,3 +9,13 @@ SUBSYSTEM=="block", ACTION=="change", \
ENV{ID_FS_TYPE}=="iso9660" ENV{ID_FS_LABEL_ENC}=="CONTEXT", \
ENV{SEQNUM}=="*[02468]", \
RUN+="/bin/systemctl start one-context-reconfigure.service"
# Handle disk resize
SUBSYSTEM=="block", ACTION=="change", \
ENV{RESIZE}=="1", \
RUN+="/bin/systemctl start one-context-force.service"
# Handle swap hot-attach
SUBSYSTEM=="block", ACTION=="add", \
ENV{ID_FS_TYPE}=="swap", \
RUN+="/bin/systemctl start one-context-force.service"

@ -1,3 +1,13 @@
# On NIC hogplug the delayed reconfiguration is triggered.
SUBSYSTEM=="net", ACTION=="add", \
RUN+="/sbin/service one-context-reconfigure-delayed start"
# Handle disk resize
SUBSYSTEM=="block", ACTION=="change", \
ENV{RESIZE}=="1", \
RUN+="/sbin/service one-context-force start"
# Handle swap hot-attach
SUBSYSTEM=="block", ACTION=="add", \
ENV{ID_FS_TYPE}=="swap", \
RUN+="/sbin/service one-context-force start"

@ -0,0 +1,12 @@
[Unit]
Description=OpenNebula forced reconfiguration
After=one-context.service
Requisite=one-context.service
[Service]
Type=oneshot
Environment=TIMEOUT=0
ExecStart=/usr/sbin/one-context-run force
[Install]
WantedBy=multi-user.target

@ -6,7 +6,7 @@ ConditionPathExists=/var/run/one-context/context.sh.network
[Service]
Type=forking
ExecStart=/usr/sbin/one-context-reconfigure
ExecStart=/usr/sbin/one-context-run
[Install]
WantedBy=multi-user.target

@ -8,7 +8,7 @@ ConditionPathExists=/var/run/one-context/context.sh.network
[Service]
Type=oneshot
Environment=TIMEOUT=0
ExecStart=/usr/sbin/one-context-reconfigure
ExecStart=/usr/sbin/one-context-run
[Install]
WantedBy=multi-user.target

@ -20,6 +20,7 @@
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
TIMEOUT=${TIMEOUT:-60}
COMMAND=${1:-reconfigure}
CONTEXT_BASE=${CONTEXT_BASE:-/var/run/one-context/context.sh}
if [ -f ${CONTEXT_BASE}.local ] && [ -f ${CONTEXT_BASE}.network ]; then
@ -27,11 +28,11 @@ if [ -f ${CONTEXT_BASE}.local ] && [ -f ${CONTEXT_BASE}.network ]; then
(
set -e
sleep "${TIMEOUT}"
/usr/sbin/one-contextd all reconfigure
/usr/sbin/one-contextd all ${COMMAND}
) &>/dev/null &
disown
else
/usr/sbin/one-contextd all reconfigure
/usr/sbin/one-contextd all ${COMMAND}
fi
else
echo 'Contextualization must start first as a boot service' >&2

@ -200,7 +200,8 @@ function run_context {
local _command=$2
export CONTEXT_FILE="${CONTEXT_BASE}.${_type}"
if check_context "${CONTEXT_NEW}" "${CONTEXT_FILE}"; then
if [ "${COMMAND}" == 'force' ] || check_context "${CONTEXT_NEW}" "${CONTEXT_FILE}"; then
cp -f "${CONTEXT_NEW}" "${CONTEXT_FILE}"
export_rc_vars "${CONTEXT_FILE}"
execute_scripts "${_type}" "${_command}"

Loading…
Cancel
Save