diff options
author | Alexandru Avadanii <Alexandru.Avadanii@enea.com> | 2018-09-11 06:59:03 +0200 |
---|---|---|
committer | Alexandru Avadanii <Alexandru.Avadanii@enea.com> | 2018-09-11 17:05:28 +0200 |
commit | b666bc50b2b8b1bb8cde5cdab280f0409bde4958 (patch) | |
tree | bcf7e8085096b65c2e5fa5ffc18ecbe7fae7b97f /mcp | |
parent | d33f39782f945cae306ce44eead411ff9301a813 (diff) |
[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 <Alexandru.Avadanii@enea.com>
Diffstat (limited to 'mcp')
-rw-r--r-- | mcp/scripts/.gitignore | 2 | ||||
-rw-r--r-- | mcp/scripts/docker-compose/docker-compose.yaml.j2 | 2 | ||||
-rw-r--r-- | mcp/scripts/globals.sh | 3 | ||||
-rw-r--r-- | mcp/scripts/lib.sh | 14 | ||||
-rw-r--r-- | mcp/scripts/user-data.mcp.sh.j2 | 13 | ||||
-rw-r--r-- | mcp/scripts/user-data.sh.j2 (renamed from mcp/scripts/user-data.admin.sh.j2) | 7 | ||||
-rw-r--r-- | mcp/scripts/virsh_net/net_mcpcontrol.xml.j2 | 2 |
7 files changed, 11 insertions, 32 deletions
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 \ - "<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 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.admin.sh.j2 b/mcp/scripts/user-data.sh.j2 index d77773260..cebf3bc61 100644 --- a/mcp/scripts/user-data.admin.sh.j2 +++ b/mcp/scripts/user-data.sh.j2 @@ -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 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 @@ <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> |