Add network_config_hook interface to run-os-net-config.sh

run-os-net-config.sh only allows for limited customization of the
network configuration in config.json. Namely, it only customizes the
bridge_name and interface_name.

This will likely not be sufficient for all use cases. This patch adds a
generic network_config_hook bash function that will be called if it is
defined. The function is an entry point for deployers to write custom
code to further influence run-os-net-config.sh.

A possible alternative approach would be to pass the server resource
into the NetworkConfig template. That would allow running arbitrary
SoftwareDeployments on the server before NetworkDeployment is executed.
However, the interface of NetworkDeployment is likely still not as
flexible as this approach as the inputs are hardcoded in the role
template files (role.role.j2.yaml), which are not meant to be modified
by deployers.

The immediate use case for this work is using os-net-config in our
multinode CI jobs where we need to create vxlan tunnels between the
nodes and we need to know the local private IP of each node for the
tunnel endpoint. As the IP is different for each node, it's not a
parameter we could specify in the templates.

Change-Id: I26d0ebdaba6fcd3fe885e41ed234eb79a2405228
Implements: blueprint multinode-ci-os-net-config
This commit is contained in:
James Slagle 2016-12-09 16:52:22 -05:00
parent d291083e7f
commit 20f627c0f0
1 changed files with 6 additions and 0 deletions

View File

@ -113,11 +113,17 @@ if [ -n '$network_config' ]; then
mkdir -p /etc/os-net-config
# Note these variables come from the calling heat SoftwareConfig
echo '$network_config' > /etc/os-net-config/config.json
if [ "$(type -t network_config_hook)" = "function" ]; then
network_config_hook
fi
sed -i "s/bridge_name/${bridge_name:-''}/" /etc/os-net-config/config.json
sed -i "s/interface_name/${interface_name:-''}/" /etc/os-net-config/config.json
os-net-config -c /etc/os-net-config/config.json -v --detailed-exit-codes
RETVAL=$?
if [[ $RETVAL == 2 ]]; then
ping_metadata_ip