Compare commits

...

4 Commits

Author SHA1 Message Date
Vlastimil Holer 44f2b63262
F #196: Force recontextualization on NIC detach
5 years ago
Petr Ospalý 2497f7fb32
B #4439: fix Alpine networking
5 years ago
Vlastimil Holer 8455ac3f61
B #194: Live-resize boot disk on SCSI
5 years ago
Vlastimil Holer c551ab4c59
B #190: Drop Python dependency
5 years ago

@ -294,34 +294,65 @@ configure_network()
deactivate_network()
{
. /etc/os-release
if [ $ID = "ubuntu" ]; then
IFACES=`/sbin/ifquery --list -a`
for i in $IFACES; do
if [ $i != 'lo' ]; then
/sbin/ifdown $i
/sbin/ip addr flush dev $i
fi
done
else
service networking stop
fi
case "$ID" in
'ubuntu')
IFACES=$(/sbin/ifquery --list -a)
for i in $IFACES; do
if [ $i != 'lo' ]; then
/sbin/ifdown $i
/sbin/ip addr flush dev $i
fi
done
;;
'alpine')
service networking stop || true
#IFACES=$(ip a | \
# sed -n 's#^[0-9]\+:[[:space:]]\+\([^:]\+\):[[:space:]].*#\1#p')
# took from find_ifaces in the networking service
IFACES=$(\
awk '$1 == "auto" {
for (i = 2; i <= NF; i = i + 1) printf("%s ", $i)
}' /etc/network/interfaces)
for i in $IFACES; do
if [ $i != 'lo' ]; then
/sbin/ip link set dev $i down || true
/sbin/ip addr flush dev $i || true
fi
done
;;
*)
service networking stop
;;
esac
}
activate_network()
{
. /etc/os-release
if [ $ID = "ubuntu" ]; then
IFACES=`/sbin/ifquery --list -a`
for i in $IFACES; do
/sbin/ifup $i
done
else
service networking stop
sleep 1
service networking start
fi
case "$ID" in
'ubuntu')
IFACES=$(/sbin/ifquery --list -a)
for i in $IFACES; do
/sbin/ifup $i
done
;;
'alpine')
deactivate_network
service networking start
;;
*)
service networking stop
sleep 1
service networking start
;;
esac
}
[ $ACTION == "reconfigure" ] && deactivate_network

@ -1,7 +1,16 @@
# On NIC hogplug the delayed reconfiguration is triggered.
# NIC detach workaround for recontextualization on OpenNebula < 5.10.3
# https://github.com/OpenNebula/one/issues/4130
# https://github.com/OpenNebula/one/issues/4194
SUBSYSTEM=="net", ACTION=="remove", \
RUN+="/bin/sh -c 'test -f /var/run/one-context/context.sh.local && echo >> /var/run/one-context/context.sh.local; test -f /var/run/one-context/context.sh.network && echo >> /var/run/one-context/context.sh.network'"
# On NIC hotplug the delayed reconfiguration is triggered.
SUBSYSTEM=="net", ACTION=="add", \
RUN+="/sbin/service one-context-reconfigure-delayed restart"
SUBSYSTEM=="net", ACTION=="remove", \
RUN+="/sbin/service one-context-reconfigure-delayed restart"
# On CONTEXT CD-ROM change the immediate reconfiguration is triggered.
SUBSYSTEM=="block", ACTION=="change", \
ENV{ID_CDROM}=="1", \
@ -13,6 +22,10 @@ SUBSYSTEM=="block", ACTION=="change", \
ENV{RESIZE}=="1", \
RUN+="/sbin/service one-context-force restart"
SUBSYSTEM=="scsi", ACTION=="change", \
ENV{SDEV_UA}=="CAPACITY_DATA_HAS_CHANGED", \
RUN+="/sbin/service one-context-force restart"
# Handle swap hot-attach
SUBSYSTEM=="block", ACTION=="add", \
ENV{ID_FS_TYPE}=="swap", \

@ -1,8 +1,18 @@
# On NIC hogplug the delayed reconfiguration is triggered.
# NIC detach workaround for recontextualization on OpenNebula < 5.10.3
# https://github.com/OpenNebula/one/issues/4130
# https://github.com/OpenNebula/one/issues/4194
SUBSYSTEM=="net", ACTION=="remove", \
RUN+="/bin/sh -c 'test -f /var/run/one-context/context.sh.local && echo >> /var/run/one-context/context.sh.local; test -f /var/run/one-context/context.sh.network && echo >> /var/run/one-context/context.sh.network'"
# On NIC hotplug the delayed reconfiguration is triggered.
SUBSYSTEM=="net", ACTION=="add", \
TAG+="systemd", ENV{SYSTEMD_WANTS}+="one-context-reconfigure-delayed.service", \
RUN+="/usr/bin/timeout 5 /usr/sbin/service one-context-reconfigure-delayed start"
SUBSYSTEM=="net", ACTION=="remove", \
TAG+="systemd", ENV{SYSTEMD_WANTS}+="one-context-reconfigure-delayed.service", \
RUN+="/usr/bin/timeout 5 /usr/sbin/service one-context-reconfigure-delayed start"
# When CONTEXT CD-ROM is changed, it generates 2 events. This rule takes
# every second event and triggers systemd service one-context-reconfigure.
# This service also stops any existing delayed reconfiguration.
@ -17,6 +27,10 @@ SUBSYSTEM=="block", ACTION=="change", \
ENV{RESIZE}=="1", \
RUN+="/usr/sbin/service one-context-force start"
SUBSYSTEM=="scsi", ACTION=="change", \
ENV{SDEV_UA}=="CAPACITY_DATA_HAS_CHANGED", \
RUN+="/usr/sbin/service one-context-force start"
# Handle swap hot-attach
SUBSYSTEM=="block", ACTION=="add", \
ENV{ID_FS_TYPE}=="swap", \

@ -1,7 +1,16 @@
# On NIC hogplug the delayed reconfiguration is triggered.
# NIC detach workaround for recontextualization on OpenNebula < 5.10.3
# https://github.com/OpenNebula/one/issues/4130
# https://github.com/OpenNebula/one/issues/4194
SUBSYSTEM=="net", ACTION=="remove", \
RUN+="/bin/sh -c 'test -f /var/run/one-context/context.sh.local && echo >> /var/run/one-context/context.sh.local; test -f /var/run/one-context/context.sh.network && echo >> /var/run/one-context/context.sh.network'"
# On NIC hotplug the delayed reconfiguration is triggered.
SUBSYSTEM=="net", ACTION=="add", \
TAG+="systemd", ENV{SYSTEMD_WANTS}+="one-context-reconfigure-delayed.service"
SUBSYSTEM=="net", ACTION=="remove", \
RUN+="/bin/systemctl --no-block start one-context-reconfigure-delayed.service"
# When CONTEXT CD-ROM is changed, it generates 2 events. This rule takes
# every second event and triggers systemd service one-context-reconfigure.
# This service also stops any existing delayed reconfiguration.
@ -16,6 +25,10 @@ SUBSYSTEM=="block", ACTION=="change", \
ENV{RESIZE}=="1", \
RUN+="/bin/systemctl --no-block start one-context-force.service"
SUBSYSTEM=="scsi", ACTION=="change", \
ENV{SDEV_UA}=="CAPACITY_DATA_HAS_CHANGED", \
RUN+="/bin/systemctl --no-block start one-context-force.service"
# Handle swap hot-attach
SUBSYSTEM=="block", ACTION=="add", \
ENV{ID_FS_TYPE}=="swap", \

@ -1,12 +1,25 @@
# On NIC hogplug the delayed reconfiguration is triggered.
# NIC detach workaround for recontextualization on OpenNebula < 5.10.3
# https://github.com/OpenNebula/one/issues/4130
# https://github.com/OpenNebula/one/issues/4194
SUBSYSTEM=="net", ACTION=="remove", \
RUN+="/bin/sh -c 'test -f /var/run/one-context/context.sh.local && echo >> /var/run/one-context/context.sh.local; test -f /var/run/one-context/context.sh.network && echo >> /var/run/one-context/context.sh.network'"
# On NIC hotplug the delayed reconfiguration is triggered.
SUBSYSTEM=="net", ACTION=="add", \
RUN+="/sbin/service one-context-reconfigure-delayed start"
SUBSYSTEM=="net", ACTION=="remove", \
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"
SUBSYSTEM=="scsi", ACTION=="change", \
ENV{SDEV_UA}=="CAPACITY_DATA_HAS_CHANGED", \
RUN+="/sbin/service one-context-force start"
# Handle swap hot-attach
SUBSYSTEM=="block", ACTION=="add", \
ENV{ID_FS_TYPE}=="swap", \

@ -160,7 +160,7 @@ case "${TARGET}" in
RELSUFFIX=${RELSUFFIX:-}
TYPE=${TYPE:-deb}
TAGS=${TAGS:-deb sysv systemd upstart one}
DEPENDS=${DEPENDS:-util-linux bash curl bind9-host cloud-utils parted ruby python ifupdown acpid sudo passwd dbus openssh-server open-vm-tools qemu-guest-agent}
DEPENDS=${DEPENDS:-util-linux bash curl bind9-host cloud-utils parted ruby ifupdown acpid sudo passwd dbus openssh-server open-vm-tools qemu-guest-agent}
PROVIDES=${PROVIDES:-}
REPLACES=${REPLACES:-cloud-init}
CONFLICTS=${CONFLICTS:-${REPLACES} one-context-ec2}
@ -175,7 +175,7 @@ case "${TARGET}" in
RELSUFFIX=${RELSUFFIX:-}
TYPE=${TYPE:-deb}
TAGS=${TAGS:-deb sysv systemd upstart ec2}
DEPENDS=${DEPENDS:-util-linux bash curl bind9-host cloud-utils parted ruby python ifupdown sudo passwd dbus openssh-server resolvconf}
DEPENDS=${DEPENDS:-util-linux bash curl bind9-host cloud-utils parted ruby ifupdown sudo passwd dbus openssh-server resolvconf}
PROVIDES=${PROVIDES:-}
REPLACES=${REPLACES:-cloud-init}
CONFLICTS=${CONFLICTS:-${REPLACES} one-context}

Loading…
Cancel
Save