Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Fix network context #200

Closed
wants to merge 2 commits into from
Closed
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
73 changes: 52 additions & 21 deletions src/etc/one-context.d/loc-10-network##apk.one
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion src/lib/udev/rules.d/65-context.rules##apk.one
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# On NIC hogplug the delayed reconfiguration is triggered.
# On NIC hotplug the delayed reconfiguration is triggered.
SUBSYSTEM=="net", ACTION=="add", \
RUN+="/bin/sh -c 'echo >> /var/run/one-context/context.sh.local && echo >> /var/run/one-context/context.sh.network'"
SUBSYSTEM=="net", ACTION=="add", \
RUN+="/sbin/service one-context-reconfigure-delayed restart"

# On NIC detach - workaround for the older OpenNebula versions <5.10.2
SUBSYSTEM=="net", ACTION=="remove", \
RUN+="/bin/sh -c 'echo >> /var/run/one-context/context.sh.local && echo >> /var/run/one-context/context.sh.network'"
SUBSYSTEM=="net", ACTION=="remove", \
RUN+="/sbin/service one-context-reconfigure-delayed restart"

# On CONTEXT CD-ROM change the immediate reconfiguration is triggered.
Expand Down
11 changes: 10 additions & 1 deletion src/lib/udev/rules.d/65-context.rules##deb.one
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# On NIC hogplug the delayed reconfiguration is triggered.
# On NIC hotplug the delayed reconfiguration is triggered.
SUBSYSTEM=="net", ACTION=="add", \
RUN+="/bin/sh -c 'echo >> /var/run/one-context/context.sh.local && echo >> /var/run/one-context/context.sh.network'"
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"

# On NIC detach - workaround for the older OpenNebula versions <5.10.2
SUBSYSTEM=="net", ACTION=="remove", \
RUN+="/bin/sh -c 'echo >> /var/run/one-context/context.sh.local && echo >> /var/run/one-context/context.sh.network'"
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"

Expand Down
10 changes: 9 additions & 1 deletion src/lib/udev/rules.d/65-context.rules##rpm.systemd.one
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
# On NIC hogplug the delayed reconfiguration is triggered.
# On NIC hotplug the delayed reconfiguration is triggered.
SUBSYSTEM=="net", ACTION=="add", \
RUN+="/bin/sh -c 'echo >> /var/run/one-context/context.sh.local && echo >> /var/run/one-context/context.sh.network'"
SUBSYSTEM=="net", ACTION=="add", \
TAG+="systemd", ENV{SYSTEMD_WANTS}+="one-context-reconfigure-delayed.service"

# On NIC detach - workaround for the older OpenNebula versions <5.10.2
SUBSYSTEM=="net", ACTION=="remove", \
RUN+="/bin/sh -c 'echo >> /var/run/one-context/context.sh.local && echo >> /var/run/one-context/context.sh.network'"
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.
Expand Down
10 changes: 9 additions & 1 deletion src/lib/udev/rules.d/65-context.rules##rpm.sysv.one
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# On NIC hogplug the delayed reconfiguration is triggered.
# On NIC hotplug the delayed reconfiguration is triggered.
SUBSYSTEM=="net", ACTION=="add", \
RUN+="/bin/sh -c 'echo >> /var/run/one-context/context.sh.local && echo >> /var/run/one-context/context.sh.network'"
SUBSYSTEM=="net", ACTION=="add", \
RUN+="/sbin/service one-context-reconfigure-delayed start"

# On NIC detach - workaround for the older OpenNebula versions <5.10.2
SUBSYSTEM=="net", ACTION=="remove", \
RUN+="/bin/sh -c 'echo >> /var/run/one-context/context.sh.local && echo >> /var/run/one-context/context.sh.network'"
SUBSYSTEM=="net", ACTION=="remove", \
RUN+="/sbin/service one-context-reconfigure-delayed start"

# Handle disk resize
Expand Down