opennebula / addon-context-alpine Goto Github PK
View Code? Open in Web Editor NEW*OBSOLETE* AlpineLinux VM contextualization
*OBSOLETE* AlpineLinux VM contextualization
Issue from Nicolas Belan
Hi,
When using multiple network on vrouter, you may have multiple default gateway defined (1 per vnet)
To choose the right gateway, it is possible to set "metric", as in:
localhost:~# cat /etc/network/interfaces
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 172.25.104.254
network 172.25.104.0
netmask 255.255.255.0
gateway 172.25.104.254
metric 1000
auto eth1
iface eth1 inet static
address 172.25.101.201
network 172.25.101.0
netmask 255.255.0.0
gateway 172.25.8.20
metric 101
Metric may be set in context variable, and retrieve from context, using something like:
# Gets the gateway metric
get_metric() {
if is_gateway; then
metric=$(get_iface_var "METRIC")
if [ -z "$metric" ]; then
if [ "$DEV" = "eth0" ]; then
metric=1000
else
metric=$((100+$IFACE_NUM))
fi
fi
echo $metric
fi
}
Using that code, by default, the second network interface is the default gateway (1=LAN, 2=WAN), and that can be change using ETH{X}_METRIC=10
Perhaps a hardcoded "eth0" is not correct; but this is a starting point.
Adding the right call "METRIC=$(get_metric)" in the interface loop, this makes the job for me :)
--- /etc/one-context.d/00-network.orig
+++ /etc/one-context.d/00-network
@@ -88,7 +88,23 @@
echo $gateway
fi
}
+# Gets the gateway metric
+get_metric() {
+ if is_gateway; then
+ metric=$(get_iface_var "METRIC")
+ if [ -z "$metric" ]; then
+ if [ "$DEV" = "eth0" ]; then
+ metric=1000
+ else
+ metric=$((100+$IFACE_NUM))
+ fi
+ fi
+
+ echo $metric
+ fi
+}
+
# Gets the network gateway6
get_gateway6() {
if is_gateway; then
@@ -147,6 +163,10 @@
echo " gateway $GATEWAY6"
fi
+ if [ -n "$METRIC" ]; then
+ echo " metric $METRIC"
+ fi
+
echo ""
}
@@ -191,6 +211,7 @@
MASK=$(get_mask)
MTU=$(get_mtu)
GATEWAY=$(get_gateway)
+ METRIC=$(get_metric)
IPV6=$(get_iface_var "IPV6")
[[ -z $IPV6 ]] && IPV6=$(get_iface_var "IP6")
If gateway is not set it is generated using the network address:
if [ -z "$gateway" ]; then
if [ "$DEV" = "eth0" ]; then
net_prefix=$(echo $NETWORK | cut -d'.' -f1,2,3)
gateway="${net_prefix}.1"
fi
fi
Disable this behavior and only configure gateway when its explicitly set.
We should probably by default install acpi and enable it, unless we're in a xen pv domU.
(Or just disable it on first boot if /proc/xen is present)
For anything else, OpenNebula doesn't know how to shut it down (not exposed by hypervisor & no event channel)
It seems by default, without acpi(d) alpine won't do a shut down action on power button press.
Could someone confirm?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.