Commit 7c0a04b2 authored by Nikos Skalkotos's avatar Nikos Skalkotos

Add support for NetworkManager

Introduce the new NM_NETWORKING image property that will force the
creation of Network Manager configuration files if defined
parent 8d01d9f2
......@@ -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
......
......@@ -294,13 +294,17 @@ get_networking_tool() {
local root_dir distro tool
root_dir=$1
distro=$(get_base_distro "$root_dir")
if [ "$distro" = debian ]; then
tool=ifupdown
elif [ "$distro" = redhat ]; then
tool=ifcfg
if check_yes_no SNF_IMAGE_PROPERTY_NM_NETWORKING; then
tool="nm"
else
tool=$distro
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"
......
networkingdir=$(libdir)/$(PACKAGE)/networking
dist_networking_SCRIPTS = ifupdown.sh ifcfg.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 :
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