Commit 7d8c80c9 authored by Yiannis Tsiouris's avatar Yiannis Tsiouris Committed by GitHub

Merge pull request #86 from skalkoto/develop

Add support for Network Manager
parents 7538331f fc552789
......@@ -228,6 +228,12 @@ All image formats properties
you want to write a custom configuration task check
:ref:`Configuration Tasks Environment<configuration-tasks-environment>`.
* **NM_NETWORKING=bool**
If this property is defined with a yes value, the *ConfigureNetwork* task
will try to configure the Ganeti-provided NICs by creating Network Manager
configuration files, instead of using the distro-specific network
configuration mechanism (*ifupdown* for Debian, *ifcfg* for Red Hat, etc.).
* **EXCLUDE_ALL_TASKS=bool**
If this property is defined with a yes value, the image will not be
configured at all, during the deployment. This is really handy because it
......
......@@ -290,6 +290,26 @@ get_distro() {
fi
}
get_networking_tool() {
local root_dir distro tool
root_dir=$1
if check_yes_no SNF_IMAGE_PROPERTY_NM_NETWORKING; then
tool="nm"
else
distro=$(get_base_distro "$root_dir")
if [ "$distro" = debian ]; then
tool=ifupdown
elif [ "$distro" = redhat ]; then
tool=ifcfg
else
tool=$distro
fi
fi
echo "@networkingdir@/$tool.sh"
}
get_partition_table() {
local dev output
dev="$1"
......
networkingdir=$(libdir)/$(PACKAGE)/networking
dist_networking_SCRIPTS = debian.sh redhat.sh freebsd.sh openbsd.sh netbsd.sh
dist_networking_SCRIPTS = ifupdown.sh ifcfg.sh freebsd.sh openbsd.sh netbsd.sh nm.sh
edit = sed \
-e 's|@sysconfdir[@]|$(sysconfdir)|g' \
......
#! /bin/bash
# Copyright (C) 2016 GRNET S.A.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
# Script for configuring network manager connections
set -e
. "@commondir@/common.sh"
networking_opts "$@"
SYSTEM_CONNECTIONS="$SNF_IMAGE_TARGET/etc/NetworkManager/system-connections/"
if [ "$initialize" = yes ]; then
exit 0
fi
if [ "$finalize" = yes ]; then
exit 0
fi
if [ "$ipv4" = "none" ]; then
ipv4_section+="method=disabled"
elif [ "$ipv4" = "dhcp" ]; then
ipv4_section+="method=auto"
else
ipv4_section+="method=manual
address1=$IP/${SUBNET##*/}"
if [ -n "$GATEWAY" ]; then
ipv4_section+=",$GATEWAY"
fi
fi
if [ "$ipv6" != 'none' ]; then
ipv6_section="method=auto"
else
ipv6_section="method=disabled"
fi
connection="$SYSTEM_CONNECTIONS/Wired connection $index"
cat > "$connection" <<EOF
[connection]
id=Wired connection $index
uuid=$(cat /proc/sys/kernel/random/uuid)
type=ethernet
autoconnect=true
[ethernet]
mac-address=$MAC
mac-address-blacklist=
[ipv4]
dns-search=
$ipv4_section
[ipv6]
addr-gen-mode=eui64
dns-search=
ip6-privacy=0
$ipv6_section
EOF
# For security, the 'keyfile' plugin that will read the connection files found
# under /etc/NetworkManager/system-connections will ignore files that are
# readable or writeable by any user or group other than 'root' since private
# keys and passphrases may be stored in plaintext inside the file.
chown 0:0 "$connection"
chmod 600 "$connection"
# vim: set sta sts=4 shiftwidth=4 sw=4 et ai :
......@@ -42,17 +42,20 @@ fi
# Check if the image overwrites the task
check_if_overwritten
distro=$(get_base_distro "$SNF_IMAGE_TARGET")
networking_tool=$(get_networking_tool "$SNF_IMAGE_TARGET")
if [ ! -f "@networkingdir@/$distro.sh" ]; then
if [ ! -f "$networking_tool" ]; then
warn "Don't know how to configure the network for this OS"
exit 0
else
echo "Using $networking_tool"
fi
export SNF_IMAGE_TARGET
# Initialize the driver
"@networkingdir@/$distro.sh" -i
echo "Running: $networking_tool -i"
"$networking_tool" -i
for index in $(seq 0 $((SNF_IMAGE_NIC_COUNT-1))); do
dhcp=no
......@@ -129,12 +132,14 @@ for index in $(seq 0 $((SNF_IMAGE_NIC_COUNT-1))); do
fi
fi
"@networkingdir@/$distro.sh" $ARGS
echo "Running: $networking_tool $ARGS"
"$networking_tool" $ARGS
done
# Finalize the driver
"@networkingdir@/$distro.sh" -f
echo "Running: $networking_tool -f"
"$networking_tool" -f
# vim: set sta sts=4 shiftwidth=4 sw=4 et ai :
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment