diff options
author | James Slagle <jslagle@redhat.com> | 2016-12-09 16:52:22 -0500 |
---|---|---|
committer | James Slagle <jslagle@redhat.com> | 2016-12-22 08:34:06 -0500 |
commit | 20f627c0f0a440062a8a256ec2c393c1ca22b007 (patch) | |
tree | a208ee3848561a7f6b6ee5c5ac112457e12bc264 | |
parent | d291083e7f990362a5bb4b3b2b22a006d8bc16c1 (diff) |
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
-rwxr-xr-x | network/scripts/run-os-net-config.sh | 6 |
1 files changed, 6 insertions, 0 deletions
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 |