Merge "Add support for different public network netmask"
authorAlexandru Avadanii <Alexandru.Avadanii@enea.com>
Thu, 25 Jan 2018 18:33:54 +0000 (18:33 +0000)
committerGerrit Code Review <gerrit@opnfv.org>
Thu, 25 Jan 2018 18:33:54 +0000 (18:33 +0000)
mcp/config/states/networks
mcp/reclass/classes/cluster/all-mcp-arch-common/opnfv/pod_config.yml.example
mcp/reclass/classes/cluster/baremetal-mcp-pike-common-ha/infra/kvm_pdf.yml.j2
mcp/reclass/classes/cluster/baremetal-mcp-pike-common-ha/openstack_compute_pdf.yml.j2
mcp/reclass/classes/cluster/baremetal-mcp-pike-common-ha/openstack_interface_vcp_biport.yml
mcp/reclass/classes/cluster/baremetal-mcp-pike-common-ha/openstack_interface_vcp_triport.yml
mcp/scripts/lib.sh

index 5beabdb..222a072 100755 (executable)
@@ -9,17 +9,20 @@
 
 CI_DEBUG=${CI_DEBUG:-0}; [[ "${CI_DEBUG}" =~ (false|0) ]] || set -x
 
-# Determine public network based on external IPs from compute node
-# NOTE: mask currently hardcoded to /24
-PUBLIC_NET=$(salt --out yaml -C 'I@nova:compute and *01*' 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}')
+source "$(dirname "${BASH_SOURCE[0]}")/../../scripts/lib.sh"
 
-[ -n "${PUBLIC_NET}" ] || PUBLIC_NET=$(salt --out yaml -C 'I@nova:compute and *01*' \
-  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}')
+PUBLIC_NET=$(get_nova_compute_pillar_data 'opnfv_net_public')
+PUBLIC_NET_GATEWAY=$(get_nova_compute_pillar_data 'opnfv_net_public_gw')
+POOL_START_IP=$(get_nova_compute_pillar_data 'opnfv_net_public_pool_start')
+POOL_END_IP=$(get_nova_compute_pillar_data 'opnfv_net_public_pool_end')
 
-[ -n "${PUBLIC_NET}" ] && PUBLIC_NET="${PUBLIC_NET%.*}.0/24" || PUBLIC_NET="10.16.0.0/24"
+# Default values
+PUBLIC_NET="${PUBLIC_NET:-10.16.0.0/24}"
+PUBLIC_NET_GATEWAY="${PUBLIC_NET_GATEWAY:-10.16.0.1}"
+POOL_START_IP="${POOL_START_IP:-10.16.0.130}"
+POOL_END_IP="${POOL_END_IP:-10.16.0.254}"
 
+# Print openstack status and setup network
 salt -C 'I@nova:controller and *01*' cmd.run ". /root/keystonercv3; \
   openstack compute service list; \
   openstack network agent list; \
@@ -27,8 +30,8 @@ salt -C 'I@nova:controller and *01*' cmd.run ". /root/keystonercv3; \
   openstack volume service list"
 salt -C 'I@nova:controller and *01*' cmd.run ". /root/keystonercv3; \
   openstack network create --external --default --provider-network-type flat \
-    --provider-physical-network physnet1 floating_net"
+  --provider-physical-network physnet1 floating_net"
 salt -C 'I@nova:controller and *01*' 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"
+  openstack subnet create --gateway ${PUBLIC_NET_GATEWAY} --no-dhcp \
+  --allocation-pool start=${POOL_START_IP},end=${POOL_END_IP} \
+  --network floating_net --subnet-range ${PUBLIC_NET} floating_subnet"
index 3a70e5f..628aeba 100644 (file)
@@ -64,7 +64,11 @@ parameters:
 
     opnfv_opendaylight_server_node01_single_address: 10.167.4.111
 
+    opnfv_net_public: 172.30.10.0/24
+    opnfv_net_public_mask: 255.255.255.0
     opnfv_net_public_gw: 172.30.10.1
+    opnfv_net_public_pool_start: 172.30.10.80
+    opnfv_net_public_pool_end: 172.30.10.100
     opnfv_name_servers: ['8.8.8.8', '8.8.4.4']
     opnfv_dns_server01: '8.8.8.8'
 
index 42c3fcb..0aab6cb 100644 (file)
@@ -91,7 +91,7 @@ parameters:
           enabled: true
           proto: manual
           address: 0.0.0.0
-          netmask: 255.255.255.0
+          netmask: ${_param:opnfv_net_public_mask}
           type: bridge
           use_interfaces:
             - {{ nic_public }}{% if vlan_public and vlan_public != 'native' %}.{{ vlan_public }}{% endif %}
index 6485fef..c1c1094 100644 (file)
@@ -60,7 +60,11 @@ parameters:
           type: eth
           proto: manual
           address: 0.0.0.0
-          netmask: 255.255.255.0
+          {%- if nic == nic_public %}
+            netmask: ${_param:opnfv_net_public_mask}
+          {%- else %}
+            netmask: 255.255.255.0
+          {%- endif %}
           mtu: ${_param:interface_mtu}
           name: {{ nic }}
     {%- endif %}
index f5a4ad0..f0fabba 100644 (file)
@@ -26,4 +26,4 @@ parameters:
           proto: static
           name: ${_param:single_nic}
           address: ${_param:single_address}
-          netmask: 255.255.255.0
+          netmask: ${_param:opnfv_net_public_mask}
index 146e545..47f2f76 100644 (file)
@@ -27,7 +27,7 @@ parameters:
           proto: static
           name: ${_param:single_nic}
           address: ${_param:single_address}
-          netmask: 255.255.255.0
+          netmask: ${_param:opnfv_net_public_mask}
           route:
             public:
               address: 0.0.0.0
index 29c27d9..2985903 100644 (file)
@@ -456,3 +456,10 @@ function wait_for {
     return 1
   )
 }
+
+function get_nova_compute_pillar_data {
+  local value=$(salt -C 'I@nova:compute and *01*' pillar.get _param:"${1}" --out yaml | cut -d ' ' -f2)
+  if [ "${value}" != "''" ]; then
+    echo  ${value}
+  fi
+}