[cleanup] FN VMs: Fold user-data templates 01/62101/2
authorAlexandru Avadanii <Alexandru.Avadanii@enea.com>
Tue, 11 Sep 2018 04:59:03 +0000 (06:59 +0200)
committerAlexandru Avadanii <Alexandru.Avadanii@enea.com>
Tue, 11 Sep 2018 15:05:28 +0000 (17:05 +0200)
While at it, retire obsolete MAAS_IP global variable and let mas01
VM get a DHCP address from virsh-managed mcpcontrol network.

Change-Id: Ifd85dbcab10894a5d0d675d37f0c35f09776d9b4
Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
ci/deploy.sh
mcp/scripts/.gitignore
mcp/scripts/docker-compose/docker-compose.yaml.j2
mcp/scripts/globals.sh
mcp/scripts/lib.sh
mcp/scripts/user-data.mcp.sh.j2 [deleted file]
mcp/scripts/user-data.sh.j2 [moved from mcp/scripts/user-data.admin.sh.j2 with 63% similarity]
mcp/scripts/virsh_net/net_mcpcontrol.xml.j2

index 5aa6c66..1121819 100755 (executable)
@@ -305,7 +305,6 @@ else
     do_sysctl_cfg
     do_udev_cfg
     create_vms "${MCP_STORAGE_DIR}" "${virtual_nodes_data}" "${OPNFV_BRIDGES[@]}"
-    update_mcpcontrol_network
     start_vms "${virtual_nodes[@]}"
 fi
 
index a7f658e..6a95545 100644 (file)
@@ -1,3 +1,3 @@
 mcp.rsa*
-user-data.*.sh
+user-data.sh
 xdf_data.sh
index ed0400d..7cd8455 100644 (file)
@@ -40,7 +40,7 @@ networks:
       config:
         - subnet: {{ net_mcpcontrol }}
           gateway: {{ net_mcpcontrol | ipnet_hostaddr(1) }}
-          ip_range: {{ [net_mcpcontrol | ipnet_hostaddr(2), conf.MCPCONTROL_PREFIX] | join("/") }}
+          ip_range: {{ [conf.SALT_MASTER, conf.MCPCONTROL_PREFIX] | join("/") }}
   pxebr:
     driver: macvlan
     driver_opts:
index 54f015c..d95448d 100644 (file)
@@ -1,6 +1,6 @@
 #!/bin/bash -e
 ##############################################################################
-# Copyright (c) 2017 Ericsson AB, Mirantis Inc., Enea AB and others.
+# Copyright (c) 2018 Ericsson AB, Mirantis Inc., Enea AB and others.
 # All rights reserved. This program and the accompanying materials
 # are made available under the terms of the Apache License, Version 2.0
 # which accompanies this distribution, and is available at
@@ -16,7 +16,6 @@ export SALT_MASTER_USER=${SALT_MASTER_USER:-ubuntu}
 # Derived from INSTALLER_IP
 export MCPCONTROL_NET=${MCPCONTROL_NET:-${SALT_MASTER%.*}.0}
 export MCPCONTROL_PREFIX=${MCPCONTROL_PREFIX:-24}
-export MAAS_IP=${MAAS_IP:-${SALT_MASTER%.*}.3}
 
 # Derived from above global vars, not overideable
 export SSH_OPTS="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i ${SSH_KEY}"
index 9b1e32c..34229df 100644 (file)
@@ -287,13 +287,8 @@ function prepare_vms {
 
   # Create config ISO and resize OS disk image for each foundation node VM
   for node in "${vnodes[@]}"; do
-    if [[ "${node}" =~ ^(cfg01|mas01) ]]; then
-      user_data='user-data.mcp.sh'
-    else
-      user_data='user-data.admin.sh'
-    fi
     ./create-config-drive.sh -k "$(basename "${SSH_KEY}").pub" \
-       -u "${user_data}" -h "${node}" "${image_dir}/mcp_${node}.iso"
+       -u 'user-data.sh' -h "${node}" "${image_dir}/mcp_${node}.iso"
     cp "${image_dir}/${image}" "${image_dir}/mcp_${node}.qcow2"
     qemu-img resize "${image_dir}/mcp_${node}.qcow2" 100G
     # Prepare dedicated drive for cinder on cmp nodes
@@ -468,13 +463,6 @@ function create_vms {
   done
 }
 
-function update_mcpcontrol_network {
-  # set static ip address for salt master node, MaaS node
-  local amac=$(virsh domiflist mas01 2>&1| awk '/mcpcontrol/ {print $5; exit}')
-  [ -z "${amac}" ] || virsh net-update "mcpcontrol" add ip-dhcp-host \
-    "<host mac='${amac}' name='mas01' ip='${MAAS_IP}'/>" --live --config
-}
-
 function reset_vms {
   local vnodes=("$@")
   local cmd_str="ssh ${SSH_OPTS} ${SSH_SALT}"
diff --git a/mcp/scripts/user-data.mcp.sh.j2 b/mcp/scripts/user-data.mcp.sh.j2
deleted file mode 100644 (file)
index bd80961..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/bin/bash
-##############################################################################
-# Copyright (c) 2018 Mirantis Inc., Enea AB and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-rm /etc/salt/minion_id
-rm -f /etc/salt/pki/minion/minion_master.pub
-echo "id: $(hostname).{{ conf.cluster.domain }}" > /etc/salt/minion
-echo "master: {{ conf.SALT_MASTER }}" >> /etc/salt/minion
-service salt-minion restart
similarity index 63%
rename from mcp/scripts/user-data.admin.sh.j2
rename to mcp/scripts/user-data.sh.j2
index d777732..cebf3bc 100644 (file)
@@ -7,8 +7,13 @@
 # http://www.apache.org/licenses/LICENSE-2.0
 ##############################################################################
 {%- import 'net_map.j2' as nm with context %}
+{%- set infra_nodes = conf[conf.MCP_JUMP_ARCH].default.virtual.nodes.infra %}
 rm /etc/salt/minion_id
 rm -f /etc/salt/pki/minion/minion_master.pub
 echo "id: $(hostname).{{ conf.cluster.domain }}" > /etc/salt/minion
-echo "master: {{ nm.net_admin | ipnet_hostaddr(nm.start_ip[nm.net_admin] + nm.net_admin_hosts.index('opnfv_infra_config_pxe_admin_address') +1) }}" >> /etc/salt/minion
+if [[ "{{ infra_nodes or [] | join(' ') }}" =~ $(hostname) ]]; then
+  echo "master: {{ conf.SALT_MASTER }}" >> /etc/salt/minion
+else
+  echo "master: {{ nm.net_admin | ipnet_hostaddr(nm.start_ip[nm.net_admin] + nm.net_admin_hosts.index('opnfv_infra_config_pxe_admin_address') +1) }}" >> /etc/salt/minion
+fi
 service salt-minion restart
index 569fa70..46798a3 100644 (file)
@@ -14,7 +14,7 @@
   <forward mode="nat"/>
   <ip address="{{ net_mcpcontrol | ipnet_hostaddr(1) }}" netmask="{{ net_mcpcontrol | ipnet_netmask }}">
     <dhcp>
-      <range start="{{ net_mcpcontrol | ipnet_hostaddr(2) }}" end="{{ net_mcpcontrol | ipnet_hostmax }}"/>
+      <range start="{{ net_mcpcontrol | ipnet_hostaddr(3) }}" end="{{ net_mcpcontrol | ipnet_hostmax }}"/>
     </dhcp>
   </ip>
 </network>