Files
training-labs/labs/osbash/lib/functions.fedora.sh
Roger Luethi 3967ba4f4f Refactoring osbash networking code
In preparation for Liberty, which removes some networks and adds a new
type of network interface configuration (manual), this patch refactors
the osbash networking code.

- fewer hardcoded settings (e.g., removed hardcoded list of networks
  from osbash.sh)

- eliminated code duplication for client-side network configuration and
  split remaining code into separate libraries (functions.ubuntu.sh,
  functions.fedora.sh)

- simplify code, e.g. by removing some magic that deduced network names
  for KVM from variable names like MGMT_NET

- universal functions for reading network and network interface
  configuration into arrays (get_host_network_config,
  get_node_netif_config)

- the number of networks is no longer hardcoded in the template for
  Windows hostnet creation

- renamed some variables, functions and files to (hopefully) be easier
  to understand

Change-Id: Ib0ed26e24d07e093f7a2bf29723b53b558cd769b
2015-12-19 21:39:03 +01:00

46 lines
1.1 KiB
Bash

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Fedora /etc/sysconfig/network-scripts/ifcfg-* configuration
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function _ifnum_to_ifname {
local if_num=$1
local -a if_names=('p2p1' 'p7p1' 'p8p1' 'p9p1')
echo "${if_names[$if_num]}"
}
function config_netif {
local if_type=$1
local if_num=${2:-""}
local ip_address=${3:-""}
local template
if [ "$if_type" = "dhcp" ]; then
template="template-fedora-ifcfg-dhcp"
else
template="template-fedora-ifcfg-static"
fi
local if_name="$(_ifnum_to_ifname "$if_num")"
local if_file=/etc/sysconfig/network-scripts/ifcfg-$if_name
sed -e "
s,%IF_NAME%,$if_name,g;
s,%IP_ADDRESS%,$ip_address,g;
" "$TEMPLATE_DIR/$template" | sudo tee "$if_file"
}
function netcfg_init {
: # Not needed for Fedora
}
function netcfg_show {
local cfg
for cfg in /etc/sysconfig/network-scripts/ifcfg-*; do
echo ---------- "$cfg"
cat "$cfg"
done
echo ---------------------------------------------------------------
}