From 9c3ecbb5238fa815e3f6b46c1933d69d588a5430 Mon Sep 17 00:00:00 2001 From: Alexandru Avadanii Date: Mon, 29 Jan 2018 06:02:10 +0100 Subject: [virtual] Split 'pxebr' from 'mcpcontrol' net - add new virsh managed network 'pxebr' (to mimic baremetal behavior on virtual PODs, this will be the equivalent of PXE/admin network); - connect 'pxebr' to 3rd interface for cfg01, mas01 for all deploys (used to be baremetal-specific), replacing 'internal'; - keep 'mcpcontrol' connected only to 'cfg01' (+ 'mas01' if present) for initial infrastructure bring-up (1st interface); - switch all virtual cluster nodes to 'pxebr' (1st interface); - use 'pxebr' for all Salt cluster nodes traffic, 'mcpcontrol' only for mas01<=>cfg01 Salt traffic; - convert to jinja2 and expand it based on PDF instead of using `envsubst`; - split into two versions, one for each network used for Salt traffic; - ci/deploy.sh: Read scenario data before template parsing for cluster domain variable, needed in virsh network def; - leave docs diagram refresh to later after all possible deploy types have settled; - limit keyserver proxy usage to nodes where the configured http proxy matches the first nameserver (true for all MaaS-provisioned nodes), so we can re-use the same pillar for FN VMs and baremetal nodes; - add PXE/admin IP on cfg01's 3rd interface and switch other vnodes `salt_master_host` to point to it; JIRA: FUEL-322 Change-Id: Ie4f7aedddf2ef81046f1127b377d88dce79f0fda Signed-off-by: Alexandru Avadanii --- mcp/scripts/.gitignore | 1 + mcp/scripts/lib.sh | 19 ++++++++++++------- mcp/scripts/user-data.admin.sh.j2 | 14 ++++++++++++++ mcp/scripts/user-data.mcp.sh.j2 | 13 +++++++++++++ mcp/scripts/user-data.template | 13 ------------- mcp/scripts/virsh_net/net_pxebr.xml.j2 | 26 ++++++++++++++++++++++++++ 6 files changed, 66 insertions(+), 20 deletions(-) create mode 100644 mcp/scripts/.gitignore create mode 100644 mcp/scripts/user-data.admin.sh.j2 create mode 100644 mcp/scripts/user-data.mcp.sh.j2 delete mode 100644 mcp/scripts/user-data.template create mode 100644 mcp/scripts/virsh_net/net_pxebr.xml.j2 (limited to 'mcp/scripts') diff --git a/mcp/scripts/.gitignore b/mcp/scripts/.gitignore new file mode 100644 index 000000000..b235933e2 --- /dev/null +++ b/mcp/scripts/.gitignore @@ -0,0 +1 @@ +user-data.*.sh diff --git a/mcp/scripts/lib.sh b/mcp/scripts/lib.sh index 7920a4e0d..6f3c4383c 100644 --- a/mcp/scripts/lib.sh +++ b/mcp/scripts/lib.sh @@ -282,12 +282,15 @@ function prepare_vms { ln -sf "${image_dir}/${_tmp}" "${image_dir}/${image}" fi - envsubst < user-data.template > user-data.sh # CWD should be - # Create config ISO and resize OS disk image for each foundation node VM for node in "${vnodes[@]}"; do - ./create-config-drive.sh -k "$(basename "${SSH_KEY}").pub" -u user-data.sh \ - -h "${node}" "${image_dir}/mcp_${node}.iso" + 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" cp "${image_dir}/${image}" "${image_dir}/mcp_${node}.qcow2" qemu-img resize "${image_dir}/mcp_${node}.qcow2" 100G done @@ -335,7 +338,6 @@ function create_vms { # vnode data should be serialized with the following format: # ',,|,,[...]' IFS='|' read -r -a vnodes <<< "$1"; shift - local vnode_networks=("$@") # AArch64: prepare arch specific arguments local virt_extra_args="" @@ -349,10 +351,13 @@ function create_vms { IFS=',' read -r -a vnode_data <<< "${serialized_vnode_data}" # prepare network args - net_args=" --network network=mcpcontrol,model=virtio" - if [ "${DEPLOY_TYPE:-}" = 'baremetal' ]; then + local vnode_networks=("$@") + if [[ "${vnode_data[0]}" =~ ^(cfg01|mas01) ]]; then + net_args=" --network network=mcpcontrol,model=virtio" # 3rd interface gets connected to PXE/Admin Bridge (cfg01, mas01) vnode_networks[2]="${vnode_networks[0]}" + else + net_args=" --network bridge=${vnode_networks[0]},model=virtio" fi for net in "${vnode_networks[@]:1}"; do net_args="${net_args} --network bridge=${net},model=virtio" diff --git a/mcp/scripts/user-data.admin.sh.j2 b/mcp/scripts/user-data.admin.sh.j2 new file mode 100644 index 000000000..b4c89b29c --- /dev/null +++ b/mcp/scripts/user-data.admin.sh.j2 @@ -0,0 +1,14 @@ +#!/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 +{#- should be in sync with 'opnfv_infra_config_pxe_address' in 'pharos/config/installers/fuel/pod_config.yml.j2 #} +echo "master: {{ conf.idf.net_config.admin.network | ipaddr_index(2) }}" >> /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 new file mode 100644 index 000000000..4bd0d1d09 --- /dev/null +++ b/mcp/scripts/user-data.mcp.sh.j2 @@ -0,0 +1,13 @@ +#!/bin/bash +############################################################################## +# Copyright (c) 2017 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.template b/mcp/scripts/user-data.template deleted file mode 100644 index 189310be4..000000000 --- a/mcp/scripts/user-data.template +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -############################################################################## -# Copyright (c) 2017 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).${CLUSTER_DOMAIN}" > /etc/salt/minion -echo "master: ${SALT_MASTER}" >> /etc/salt/minion -service salt-minion restart diff --git a/mcp/scripts/virsh_net/net_pxebr.xml.j2 b/mcp/scripts/virsh_net/net_pxebr.xml.j2 new file mode 100644 index 000000000..f82780cf7 --- /dev/null +++ b/mcp/scripts/virsh_net/net_pxebr.xml.j2 @@ -0,0 +1,26 @@ + +{%- if conf.idf.net_config.admin is defined %} + {%- set pxebr_network = conf.idf.net_config.admin.network %} + {%- set pxebr_prefix = conf.idf.net_config.admin.mask %} +{%- else %} + {%- set pxebr_network = '192.168.11.0' %} + {%- set pxebr_prefix = '24' %} +{%- endif %} + + pxebr + + + + + + + + + -- cgit 1.2.3-korg