From b666bc50b2b8b1bb8cde5cdab280f0409bde4958 Mon Sep 17 00:00:00 2001 From: Alexandru Avadanii Date: Tue, 11 Sep 2018 06:59:03 +0200 Subject: [cleanup] FN VMs: Fold user-data templates 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 --- mcp/scripts/.gitignore | 2 +- mcp/scripts/docker-compose/docker-compose.yaml.j2 | 2 +- mcp/scripts/globals.sh | 3 +-- mcp/scripts/lib.sh | 14 +------------- mcp/scripts/user-data.admin.sh.j2 | 14 -------------- mcp/scripts/user-data.mcp.sh.j2 | 13 ------------- mcp/scripts/user-data.sh.j2 | 19 +++++++++++++++++++ mcp/scripts/virsh_net/net_mcpcontrol.xml.j2 | 2 +- 8 files changed, 24 insertions(+), 45 deletions(-) delete mode 100644 mcp/scripts/user-data.admin.sh.j2 delete mode 100644 mcp/scripts/user-data.mcp.sh.j2 create mode 100644 mcp/scripts/user-data.sh.j2 (limited to 'mcp') diff --git a/mcp/scripts/.gitignore b/mcp/scripts/.gitignore index a7f658e4e..6a95545c4 100644 --- a/mcp/scripts/.gitignore +++ b/mcp/scripts/.gitignore @@ -1,3 +1,3 @@ mcp.rsa* -user-data.*.sh +user-data.sh xdf_data.sh diff --git a/mcp/scripts/docker-compose/docker-compose.yaml.j2 b/mcp/scripts/docker-compose/docker-compose.yaml.j2 index ed0400da5..7cd845511 100644 --- a/mcp/scripts/docker-compose/docker-compose.yaml.j2 +++ b/mcp/scripts/docker-compose/docker-compose.yaml.j2 @@ -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: diff --git a/mcp/scripts/globals.sh b/mcp/scripts/globals.sh index 54f015cf6..d95448d45 100644 --- a/mcp/scripts/globals.sh +++ b/mcp/scripts/globals.sh @@ -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}" diff --git a/mcp/scripts/lib.sh b/mcp/scripts/lib.sh index 9b1e32c04..34229df08 100644 --- a/mcp/scripts/lib.sh +++ b/mcp/scripts/lib.sh @@ -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 \ - "" --live --config -} - function reset_vms { local vnodes=("$@") local cmd_str="ssh ${SSH_OPTS} ${SSH_SALT}" diff --git a/mcp/scripts/user-data.admin.sh.j2 b/mcp/scripts/user-data.admin.sh.j2 deleted file mode 100644 index d77773260..000000000 --- a/mcp/scripts/user-data.admin.sh.j2 +++ /dev/null @@ -1,14 +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 -############################################################################## -{%- import 'net_map.j2' as nm with context %} -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 -service salt-minion restart diff --git a/mcp/scripts/user-data.mcp.sh.j2 b/mcp/scripts/user-data.mcp.sh.j2 deleted file mode 100644 index bd80961e6..000000000 --- a/mcp/scripts/user-data.mcp.sh.j2 +++ /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 diff --git a/mcp/scripts/user-data.sh.j2 b/mcp/scripts/user-data.sh.j2 new file mode 100644 index 000000000..cebf3bc61 --- /dev/null +++ b/mcp/scripts/user-data.sh.j2 @@ -0,0 +1,19 @@ +#!/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 +############################################################################## +{%- 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 +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 diff --git a/mcp/scripts/virsh_net/net_mcpcontrol.xml.j2 b/mcp/scripts/virsh_net/net_mcpcontrol.xml.j2 index 569fa7089..46798a3c6 100644 --- a/mcp/scripts/virsh_net/net_mcpcontrol.xml.j2 +++ b/mcp/scripts/virsh_net/net_mcpcontrol.xml.j2 @@ -14,7 +14,7 @@ - + -- cgit 1.2.3-korg