From 20f627c0f0a440062a8a256ec2c393c1ca22b007 Mon Sep 17 00:00:00 2001 From: James Slagle Date: Fri, 9 Dec 2016 16:52:22 -0500 Subject: 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 --- network/scripts/run-os-net-config.sh | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'network') diff --git a/network/scripts/run-os-net-config.sh b/network/scripts/run-os-net-config.sh index 5df67b78..e65f922a 100755 --- a/network/scripts/run-os-net-config.sh +++ b/network/scripts/run-os-net-config.sh @@ -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 -- cgit 1.2.3-korg