reclass, states: Parametrize runtime configuration 95/41595/8
authorAlexandru Avadanii <Alexandru.Avadanii@enea.com>
Sun, 10 Sep 2017 21:33:36 +0000 (23:33 +0200)
committerAlexandru Avadanii <Alexandru.Avadanii@enea.com>
Tue, 12 Sep 2017 02:52:30 +0000 (04:52 +0200)
mcpcontrol virsh network, as well as MaaS PXE network are installer
specific, and not POD specific.
Therefore, these should be easily parametrized without the PDF,
using only installer inputs (e.g. env vars passed via Jenkins).

- add new <all-mcp-ocata-common.opnfv.runtime> reclass class;
- parametrize at runtime new reclass class based on global vars;
- factor out MaaS deploy address / config using new mechanism;
- parametrize at runtime virsh network definitions based on template;
- add new "maas.pxe_route" sls for configuring routing on cfg01;
- replace env vars with the new sls in "maas" state;

NOTE: baremetal parametrization will be handled later.

Change-Id: Ifd61143d818fb088b3f4395388ba769bbc49156e
Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
18 files changed:
.gitignore
ci/deploy.sh
mcp/config/states/maas
mcp/patches/0005-maas-module-Obtain-fabric-ID-from-CIDR.patch
mcp/reclass/classes/cluster/all-mcp-ocata-common/init.yml
mcp/reclass/classes/cluster/all-mcp-ocata-common/opnfv/.gitignore [new file with mode: 0644]
mcp/reclass/classes/cluster/all-mcp-ocata-common/opnfv/init.yml [new file with mode: 0644]
mcp/reclass/classes/cluster/all-mcp-ocata-common/opnfv/runtime.yml.template [new file with mode: 0644]
mcp/reclass/classes/cluster/baremetal-mcp-ocata-odl-ha/infra/init.yml
mcp/reclass/classes/cluster/baremetal-mcp-ocata-odl-ha/infra/maas.yml
mcp/reclass/classes/cluster/baremetal-mcp-ocata-ovs-dpdk-ha/infra/init.yml
mcp/reclass/classes/cluster/baremetal-mcp-ocata-ovs-dpdk-ha/infra/maas.yml
mcp/reclass/classes/cluster/baremetal-mcp-ocata-ovs-ha/infra/init.yml
mcp/reclass/classes/cluster/baremetal-mcp-ocata-ovs-ha/infra/maas.yml
mcp/reclass/classes/cluster/virtual-mcp-ocata-common/infra/config.yml
mcp/salt-formulas/maas/pxe_route.sls [new file with mode: 0644]
mcp/scripts/net_mcpcontrol.xml [deleted file]
mcp/scripts/net_mcpcontrol.xml.template [new file with mode: 0644]

index 72e939c..c8064d4 100644 (file)
@@ -12,3 +12,4 @@ deploy/autodeploy.log
 mcp/deploy/images/
 mcp/scripts/mcp.rsa*
 mcp/scripts/user-data.sh
+mcp/scripts/net_mcpcontrol.xml
index 603d6e5..f6af1b5 100755 (executable)
@@ -135,6 +135,7 @@ clean() {
 SCRIPT_PATH=$(readlink -f "$(dirname "${BASH_SOURCE[0]}")")
 DEPLOY_DIR=$(cd "${SCRIPT_PATH}/../mcp/scripts"; pwd)
 STORAGE_DIR=$(cd "${SCRIPT_PATH}/../mcp/deploy/images"; pwd)
+RECLASS_CLUSTER_DIR=$(cd "${SCRIPT_PATH}/../mcp/reclass/classes/cluster"; pwd)
 DEPLOY_TYPE='baremetal'
 OPNFV_BRIDGES=('pxebr' 'mgmt' 'internal' 'public')
 URI_REGEXP='(file|https?|ftp)://.*'
@@ -143,6 +144,11 @@ export SSH_KEY=${SSH_KEY:-"/var/lib/opnfv/mcp.rsa"}
 export SALT_MASTER=${INSTALLER_IP:-10.20.0.2}
 export SALT_MASTER_USER=${SALT_MASTER_USER:-ubuntu}
 export MAAS_IP=${MAAS_IP:-${SALT_MASTER%.*}.3}
+export MAAS_PXE_NETWORK=${MAAS_PXE_NETWORK:-192.168.11.0}
+
+# Derivated from above global vars
+export MCP_CTRL_NETWORK_ROOTSTR=${SALT_MASTER%.*}
+export MAAS_PXE_NETWORK_ROOTSTR=${MAAS_PXE_NETWORK%.*}
 export SSH_OPTS="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i ${SSH_KEY}"
 export SSH_SALT="${SALT_MASTER_USER}@${SALT_MASTER}"
 
@@ -327,6 +333,10 @@ for node in "${virtual_nodes[@]}"; do
     virtual_nodes_vcpus[$node]=${!virtual_custom_vcpus:-$virtual_default_vcpus}
 done
 
+# Expand reclass and virsh network templates
+for tp in "${RECLASS_CLUSTER_DIR}/all-mcp-ocata-common/opnfv/"*.template \
+    net_*.template; do envsubst < "${tp}" > "${tp%.template}"; done
+
 # Infra setup
 generate_ssh_key
 prepare_vms virtual_nodes "${base_image}" "${STORAGE_DIR}"
index 67a7c21..0d733ba 100755 (executable)
@@ -56,8 +56,7 @@ salt -C 'mas01*' state.apply linux,salt,openssh,ntp
 salt -C 'mas01*' state.apply linux.network.interface
 salt -C 'mas01*' state.apply maas.pxe_nat
 salt -C 'mas01*' state.apply maas.cluster
-salt -C 'cfg01*' cmd.run \
-  "route add -net 192.168.11.0/24 gw ${MAAS_IP:-10.20.0.3}"
+salt -C 'cfg01*' state.apply maas.pxe_route
 
 wait_for 10 "salt -C 'mas01*' state.apply maas.region"
 
index 5c77a63..9489b90 100644 (file)
@@ -20,9 +20,17 @@ Signed-off-by: Guillermo Herrero <Guillermo.Herrero@enea.com>
 ---
 
 diff --git a/_modules/maas.py b/_modules/maas.py
-index d3227ca..8a2243d 100644
 --- a/_modules/maas.py
 +++ b/_modules/maas.py
+@@ -126,6 +126,8 @@
+
+             def process_single(name, config_data):
+                 self._update = False
++                if isinstance(config_data, dict) and 'name' in config_data:
++                    name = config_data['name']
+                 try:
+                     data = self.fill_data(name, config_data, **extra)
+                     if data is None:
 @@ -198,7 +198,8 @@
      def fill_data(self, name, subnet, fabrics):
          data = {
diff --git a/mcp/reclass/classes/cluster/all-mcp-ocata-common/opnfv/.gitignore b/mcp/reclass/classes/cluster/all-mcp-ocata-common/opnfv/.gitignore
new file mode 100644 (file)
index 0000000..4b9ab2b
--- /dev/null
@@ -0,0 +1 @@
+runtime.yml
diff --git a/mcp/reclass/classes/cluster/all-mcp-ocata-common/opnfv/init.yml b/mcp/reclass/classes/cluster/all-mcp-ocata-common/opnfv/init.yml
new file mode 100644 (file)
index 0000000..28619ba
--- /dev/null
@@ -0,0 +1,2 @@
+classes:
+- cluster.all-mcp-ocata-common.opnfv.runtime
diff --git a/mcp/reclass/classes/cluster/all-mcp-ocata-common/opnfv/runtime.yml.template b/mcp/reclass/classes/cluster/all-mcp-ocata-common/opnfv/runtime.yml.template
new file mode 100644 (file)
index 0000000..121f706
--- /dev/null
@@ -0,0 +1,9 @@
+parameters:
+  _param:
+    reclass_config_master: ${SALT_MASTER}
+
+    opnfv_fuel_maas_mcp_address: ${MAAS_IP}
+    opnfv_fuel_maas_pxe_network: ${MAAS_PXE_NETWORK}
+    opnfv_fuel_maas_pxe_address: ${MAAS_PXE_NETWORK_ROOTSTR}.3
+    opnfv_fuel_maas_pxe_iprange_start: ${MAAS_PXE_NETWORK_ROOTSTR}.5
+    opnfv_fuel_maas_pxe_iprange_end: ${MAAS_PXE_NETWORK_ROOTSTR}.250
index d08bdbb..730193a 100644 (file)
@@ -1,5 +1,6 @@
 classes:
 - system.linux.system.single
+- cluster.all-mcp-ocata-common
 - cluster.baremetal-mcp-ocata-odl-ha.openstack
 # - cluster.baremetal-mcp-ocata-odl-ha.stacklight
 # - cluster.baremetal-mcp-ocata-odl-ha.stacklight.client
@@ -19,7 +20,7 @@ parameters:
     infra_config_address: 10.167.4.100
     infra_config_deploy_address: 10.20.0.2
     infra_maas_node01_address: 10.167.4.3
-    infra_maas_node01_deploy_address: 192.168.11.3
+    infra_maas_node01_deploy_address: ${_param:opnfv_fuel_maas_pxe_address}
     infra_maas_node01_external_address: 10.16.0.3
     infra_compute_node01_address: 10.167.4.141
     infra_compute_node02_address: 10.167.4.142
index c4bc929..72b9f52 100644 (file)
@@ -32,13 +32,13 @@ parameters:
         network_discovery: 'enabled'
         default_min_hwe_kernel: 'hwe-16.04'
       subnets:
-        # TODO: parametrize address root (192.168.11), dhcp start/end?
-        192.168.11.0/24:
-          cidr: 192.168.11.0/24
+        opnfv_fuel_maas_pxe:
+          name: ${_param:opnfv_fuel_maas_pxe_network}/24
+          cidr: ${_param:opnfv_fuel_maas_pxe_network}/24
           gateway_ip: ${_param:single_address}
           iprange:
-            start: 192.168.11.5
-            end: 192.168.11.250
+            start: ${_param:opnfv_fuel_maas_pxe_iprange_start}
+            end: ${_param:opnfv_fuel_maas_pxe_iprange_end}
             type: dynamic
           vlans:
             untagged:
index 7d029b3..94ccc9e 100644 (file)
@@ -1,5 +1,6 @@
 classes:
 - system.linux.system.single
+- cluster.all-mcp-ocata-common
 - cluster.baremetal-mcp-ocata-ovs-dpdk-ha.openstack
 # - cluster.baremetal-mcp-ocata-ovs-dpdk-ha.stacklight
 # - cluster.baremetal-mcp-ocata-ovs-dpdk-ha.stacklight.client
@@ -19,7 +20,7 @@ parameters:
     infra_config_address: 10.167.4.100
     infra_config_deploy_address: 10.20.0.2
     infra_maas_node01_address: 10.167.4.3
-    infra_maas_node01_deploy_address: 192.168.11.3
+    infra_maas_node01_deploy_address: ${_param:opnfv_fuel_maas_pxe_address}
     infra_maas_node01_external_address: 10.16.0.3
     infra_compute_node01_address: 10.167.4.141
     infra_compute_node02_address: 10.167.4.142
index b83aa1e..bdf7fea 100644 (file)
@@ -32,13 +32,13 @@ parameters:
         network_discovery: 'enabled'
         default_min_hwe_kernel: 'hwe-16.04'
       subnets:
-        # TODO: parametrize address root (192.168.11), dhcp start/end?
-        192.168.11.0/24:
-          cidr: 192.168.11.0/24
+        opnfv_fuel_maas_pxe:
+          name: ${_param:opnfv_fuel_maas_pxe_network}/24
+          cidr: ${_param:opnfv_fuel_maas_pxe_network}/24
           gateway_ip: ${_param:single_address}
           iprange:
-            start: 192.168.11.5
-            end: 192.168.11.250
+            start: ${_param:opnfv_fuel_maas_pxe_iprange_start}
+            end: ${_param:opnfv_fuel_maas_pxe_iprange_end}
             type: dynamic
           vlans:
             untagged:
index b6261f6..6bf0fbe 100644 (file)
@@ -1,5 +1,6 @@
 classes:
 - system.linux.system.single
+- cluster.all-mcp-ocata-common
 - cluster.baremetal-mcp-ocata-ovs-ha.openstack
 # - cluster.baremetal-mcp-ocata-ovs-ha.stacklight
 # - cluster.baremetal-mcp-ocata-ovs-ha.stacklight.client
@@ -19,7 +20,7 @@ parameters:
     infra_config_address: 10.167.4.100
     infra_config_deploy_address: 10.20.0.2
     infra_maas_node01_address: 10.167.4.3
-    infra_maas_node01_deploy_address: 192.168.11.3
+    infra_maas_node01_deploy_address: ${_param:opnfv_fuel_maas_pxe_address}
     infra_maas_node01_external_address: 10.16.0.3
     infra_compute_node01_address: 10.167.4.141
     infra_compute_node02_address: 10.167.4.142
index d193469..f77abea 100644 (file)
@@ -32,13 +32,13 @@ parameters:
         network_discovery: 'enabled'
         default_min_hwe_kernel: 'hwe-16.04'
       subnets:
-        # TODO: parametrize address root (192.168.11), dhcp start/end?
-        192.168.11.0/24:
-          cidr: 192.168.11.0/24
+        opnfv_fuel_maas_pxe:
+          name: ${_param:opnfv_fuel_maas_pxe_network}/24
+          cidr: ${_param:opnfv_fuel_maas_pxe_network}/24
           gateway_ip: ${_param:single_address}
           iprange:
-            start: 192.168.11.5
-            end: 192.168.11.250
+            start: ${_param:opnfv_fuel_maas_pxe_iprange_start}
+            end: ${_param:opnfv_fuel_maas_pxe_iprange_end}
             type: dynamic
           vlans:
             untagged:
index 0e3a264..73e2da5 100644 (file)
@@ -16,7 +16,6 @@ parameters:
     reclass_data_repository: local
     salt_master_environment_repository: "https://github.com/tcpcloud"
     salt_master_environment_revision: master
-    reclass_config_master: 10.20.0.2
     single_address: 172.16.10.100
     salt_master_host: 127.0.0.1
     salt_master_base_environment: prd
diff --git a/mcp/salt-formulas/maas/pxe_route.sls b/mcp/salt-formulas/maas/pxe_route.sls
new file mode 100644 (file)
index 0000000..5f7cebd
--- /dev/null
@@ -0,0 +1,8 @@
+routes:
+  network.routes:
+    - name: {{ salt['pillar.get']('_param:opnfv_fn_vm_primary_interface') }}
+    - routes:
+      - name: maas_mcp_to_pxe_network
+        ipaddr: {{ salt['pillar.get']('_param:opnfv_fuel_maas_pxe_network') }}
+        netmask: 255.255.255.0
+        gateway: {{ salt['pillar.get']('_param:opnfv_fuel_maas_mcp_address') }}
diff --git a/mcp/scripts/net_mcpcontrol.xml b/mcp/scripts/net_mcpcontrol.xml
deleted file mode 100644 (file)
index 6a4cfd5..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-<network>
-  <name>mcpcontrol</name>
-  <bridge name="mcpcontrol"/>
-  <forward mode="nat"/>
-  <ip address="10.20.0.1" netmask="255.255.255.0">
-    <dhcp>
-      <range start="10.20.0.2" end="10.20.0.254"/>
-    </dhcp>
-  </ip>
-</network>
diff --git a/mcp/scripts/net_mcpcontrol.xml.template b/mcp/scripts/net_mcpcontrol.xml.template
new file mode 100644 (file)
index 0000000..722a66a
--- /dev/null
@@ -0,0 +1,10 @@
+<network>
+  <name>mcpcontrol</name>
+  <bridge name="mcpcontrol"/>
+  <forward mode="nat"/>
+  <ip address="${MCP_CTRL_NETWORK_ROOTSTR}.1" netmask="255.255.255.0">
+    <dhcp>
+      <range start="${MCP_CTRL_NETWORK_ROOTSTR}.2" end="${MCP_CTRL_NETWORK_ROOTSTR}.254"/>
+    </dhcp>
+  </ip>
+</network>