local net="${ip_bits%/*}"
local netname="acnet_${net//./_}"
- local ip="${net%.*}.${IPNUM}"
- local mask="255.255.255.0"
+ local ip="${net%.*}.${IPNUM}/${ip_bits#*/}"
# This can be used to override the variables in the echo
# statement below. The hook can use any other variables
# available in this function.
run_hooks hack_network_map_hooks
- echo "${netname} ${dev} ${ip} ${mask} ${mac} ${opts}"
+ echo "${netname} ${dev} ${ip} ${mac} ${opts}"
count=$(($count + 1))
done >"$network_map"
}
# specified then use the IP address associated with it.
INSTALL_IP=""
INSTALL_GW=""
- local netname dev ip mask mac opts
- while read netname dev ip mask mac opts; do
+ local netname dev ip mac opts
+ while read netname dev ip mac opts; do
local o
for o in $opts ; do
case "$o" in
diskimage rm_rf "/etc/udev/rules.d/70-persistent-net.rules"
echo "Setting up network interfaces: "
- local netname dev ip mask mac opts
- while read netname dev ip mask mac opts; do
+ local netname dev ip mac opts
+ while read netname dev ip mac opts; do
echo " $dev"
- local o gw
+ local o gw addr mask
gw=""
for o in $opts ; do
case "$o" in
esac
done
+ addr=${ip%/*}
+ mask=$(ipv4_prefix_to_netmask ${ip#*/})
+
cat <<EOF | \
diskimage put - "/etc/sysconfig/network-scripts/ifcfg-${dev}"
DEVICE=$dev
ONBOOT=yes
TYPE=Ethernet
-IPADDR=$ip
+IPADDR=$addr
NETMASK=$mask
HWADDR=$mac
${gw:+GATEWAY=}${gw}
# * First network is private and contains the CTDB node addresses.
# * Items look like: net/bits,dev[,nat|bridge=host_iface][,gw=gateway_ip]
-# * Right now autocluster only supports 24 bit networks. This will
-# be improved in the future.
defconf NETWORKS "10.0.0.0/24,eth0,gw=10.0.0.1 10.0.1.0/24,eth1 10.0.2.0/24,eth2" \
"<list>" "description of IP networks"
networks_post_config_hook ()
{
- local n
- for n in $NETWORKS ; do
- local ip_mask="${n%%,*}"
- local mask="${ip_mask#*/}"
-
- [ "$mask" = "24" ] || \
- die "Network maskbits other than 24 unsupported in \"$n\""
- done
-
[ -z "$IPBASE" -a -z "$IPNET0" -a -z "$IPNET1" -a -z "$IPNET2" ] || \
die "Configuration variables IPBASE, IPNET0/1/2 unsupported - please use NETWORKS"
network_template ()
{
- local netname dev ip mask mac opts
- while read netname dev ip mask mac opts ; do
+ local netname dev ip mac opts
+ while read netname dev ip mac opts ; do
cat <<EOF
<interface type='network'>
<mac address='${mac}'/>
{
local netname="$1"
local ip="$2"
- local mask="$3"
- local opts="$4"
+ local opts="$3"
local uuid=$(uuidgen)
EOF
fi
+ ip_addr=${ip%/*}
+ ip_mask=${ip#*/}
+
cat <<EOF
<bridge name='${netname}' stp='on' forwardDelay='0' />
- <ip address='${ip}' netmask='${mask}'>
- </ip>
+ <ip address='${ip_addr}' prefix='${ip_mask}' />
</network>
EOF
}
fi
-while read netname dev ip mask mac opts ; do
+while read netname dev ip mac opts ; do
echo "Setting up network \"${netname}\""
t=$(mktemp)
- gen_xml "$netname" "$ip" "$mask" "$opts" >"$t"
+ gen_xml "$netname" "$ip" "$opts" >"$t"
if $dry_run ; then
cat "$t"
else
echo "Forcing up network interface \"$dev\""
ip link set $dev up
-ip addr add @@INSTALL_IP@@/24 dev $dev
+ip addr add @@INSTALL_IP@@ dev $dev
if [ -n "@@INSTALL_GW@@" ] ; then
ip route add default via @@INSTALL_GW@@
fi