aboutsummaryrefslogtreecommitdiffstats
path: root/mcp/config/states
diff options
context:
space:
mode:
authorMichael Polenchuk <mpolenchuk@mirantis.com>2017-08-23 05:22:19 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-08-23 05:22:19 +0000
commit82b0ce54c84b0b20c3d3c7c686218bb6aa06e5bb (patch)
treeec151313fdfe9e88075985cd2865223641dbd3dc /mcp/config/states
parent4497ce6b74f1ca08b7f2d9c785fa7b4b0a6831a0 (diff)
parent7161058d87d2012074eb37109396a20651b586bc (diff)
Merge "states/network: parametrize Openstack public net"
Diffstat (limited to 'mcp/config/states')
-rwxr-xr-xmcp/config/states/networks28
1 files changed, 25 insertions, 3 deletions
diff --git a/mcp/config/states/networks b/mcp/config/states/networks
index 205e0a97c..6f294cea1 100755
--- a/mcp/config/states/networks
+++ b/mcp/config/states/networks
@@ -1,3 +1,25 @@
-salt 'ctl01*' cmd.run ". /root/keystonercv3; openstack compute service list; openstack network agent list; openstack stack list; openstack volume service list"
-salt 'ctl01*' cmd.run ". /root/keystonercv3; openstack network create --external --default --provider-network-type flat --provider-physical-network physnet1 floating_net"
-salt 'ctl01*' cmd.run ". /root/keystonercv3; openstack subnet create --gateway 10.16.0.1 --no-dhcp --allocation-pool start=10.16.0.130,end=10.16.0.254 --network floating_net --subnet-range 10.16.0.0/24 floating_subnet"
+#!/bin/bash
+
+# Determine public network based on external IPs from compute node
+# NOTE: mask currently hardcoded to /24
+PUBLIC_NET=$(salt --out yaml 'cmp*' pillar.get _param:external_address | \
+ awk --re-interval '/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/{print $2; exit}')
+
+[ -n "${PUBLIC_NET}" ] || PUBLIC_NET=$(salt --out yaml 'cmp*' \
+ pillar.get _param:openstack_compute_node01_external_address | \
+ awk --re-interval '/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/{print $2; exit}')
+
+[ -n "${PUBLIC_NET}" ] && PUBLIC_NET="${PUBLIC_NET%.*}.0/24" || PUBLIC_NET="10.16.0.0/24"
+
+salt 'ctl01*' cmd.run ". /root/keystonercv3; \
+ openstack compute service list; \
+ openstack network agent list; \
+ openstack stack list; \
+ openstack volume service list"
+salt 'ctl01*' cmd.run ". /root/keystonercv3; \
+ openstack network create --external --default --provider-network-type flat \
+ --provider-physical-network physnet1 floating_net"
+salt 'ctl01*' cmd.run ". /root/keystonercv3; \
+ openstack subnet create --gateway ${PUBLIC_NET%.*}.1 --no-dhcp \
+ --allocation-pool start=${PUBLIC_NET%.*}.130,end=${PUBLIC_NET%.*}.254 \
+ --network floating_net --subnet-range ${PUBLIC_NET} floating_subnet"