summaryrefslogtreecommitdiffstats
path: root/mcp/scripts
diff options
context:
space:
mode:
authorAlexandru Avadanii <Alexandru.Avadanii@enea.com>2019-05-06 13:32:24 +0000
committerGerrit Code Review <gerrit@opnfv.org>2019-05-06 13:32:24 +0000
commit6fc9ea86375b3fafba3de494ba32a4c65f39ca93 (patch)
treef3b838cf95b8e36cc5bd5d2f4eb60f00dc68795d /mcp/scripts
parent7522bdb0e898144da2b6dc361dbdd549b39bc025 (diff)
parent9e5b19768d6eb9b32564240065ecba6c791cac12 (diff)
Merge "[virtual] Parameterize scenarios based on PDF/IDF"
Diffstat (limited to 'mcp/scripts')
-rw-r--r--mcp/scripts/lib_jump_deploy.sh48
-rw-r--r--mcp/scripts/lib_template.sh6
-rw-r--r--mcp/scripts/xdf_data.sh.j23
3 files changed, 28 insertions, 29 deletions
diff --git a/mcp/scripts/lib_jump_deploy.sh b/mcp/scripts/lib_jump_deploy.sh
index 5d442eb0b..aad6ce586 100644
--- a/mcp/scripts/lib_jump_deploy.sh
+++ b/mcp/scripts/lib_jump_deploy.sh
@@ -215,7 +215,6 @@ function prepare_vms {
local base_image=$1; shift
local image_dir=$1; shift
local repos_pkgs_str=$1; shift # ^-sep list of repos, pkgs to install/rm
- local vnodes=("$@")
local image=base_image_opnfv_fuel.img
local vcp_image=${image%.*}_vcp.img
local _o=${base_image/*\/}
@@ -249,18 +248,6 @@ function prepare_vms {
ln -sf "${image_dir}/${_tmp}" "${image_dir}/${image}"
fi
- # 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"
- 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
- if [[ "${node}" =~ ^(cmp) ]]; then
- qemu-img create "${image_dir}/mcp_${node}_storage.qcow2" 100G
- fi
- done
-
# VCP VMs base image specific changes
if [[ ! "${repos_pkgs_str}" =~ \^{3}$ ]] && [ -n "${repos_pkgs[*]:4}" ]; then
echo "[INFO] Lookup cache / build patched VCP image for md5sum: ${_h}"
@@ -342,8 +329,9 @@ function create_networks {
function create_vms {
local image_dir=$1; shift
+ local image=base_image_opnfv_fuel.img
# vnode data should be serialized with the following format:
- # <name0>,<ram0>,<vcpu0>[,<sockets0>,<cores0>,<threads0>[,<cell0name0>,<cell0memory0>,
+ # <name0>,<disks0>,<ram0>,<vcpu0>[,<sockets0>,<cores0>,<threads0>[,<cell0name0>,<cell0memory0>,
# <cell0cpus0>,<cell1name0>,<cell1memory0>,<cell1cpus0>]]|<name1>,...'
IFS='|' read -r -a vnodes <<< "$1"; shift
@@ -358,18 +346,34 @@ function create_vms {
for serialized_vnode_data in "${vnodes[@]}"; do
if [ -z "${serialized_vnode_data}" ]; then continue; fi
IFS=',' read -r -a vnode_data <<< "${serialized_vnode_data}"
+ IFS=';' read -r -a disks_data <<< "${vnode_data[1]}"
+
+ # Create config ISO and resize OS disk image for each foundation node VM
+ ./create-config-drive.sh -k "$(basename "${SSH_KEY}").pub" \
+ -u 'user-data.sh' -h "${vnode_data[0]}" "${image_dir}/mcp_${vnode_data[0]}.iso"
+ cp "${image_dir}/${image}" "${image_dir}/mcp_${vnode_data[0]}.qcow2"
+ qemu-img resize "${image_dir}/mcp_${vnode_data[0]}.qcow2" "${disks_data[0]}"
+ # Prepare additional drives if present
+ idx=0
+ virt_extra_storage=
+ for dsize in "${disks_data[@]:1}"; do
+ ((idx+=1))
+ qcow_file="${image_dir}/mcp_${vnode_data[0]}_${idx}.qcow2"
+ qemu-img create "${qcow_file}" "${dsize}"
+ virt_extra_storage+=" --disk path=${qcow_file},format=qcow2,bus=virtio,cache=none,io=native"
+ done
# prepare VM CPU model, count, topology (optional), NUMA cells (optional, requires topo)
local virt_cpu_args=' --cpu host-passthrough'
- local idx=6 # cell0.name index in serialized data
+ local idx=7 # cell0.name index in serialized data
while [ -n "${vnode_data[${idx}]}" ]; do
virt_cpu_args+=",${vnode_data[${idx}]}.memory=${vnode_data[$((idx + 1))]}"
virt_cpu_args+=",${vnode_data[${idx}]}.cpus=${vnode_data[$((idx + 2))]}"
idx=$((idx + 3))
done
- virt_cpu_args+=" --vcpus vcpus=${vnode_data[2]}"
- if [ -n "${vnode_data[5]}" ]; then
- virt_cpu_args+=",sockets=${vnode_data[3]},cores=${vnode_data[4]},threads=${vnode_data[5]}"
+ virt_cpu_args+=" --vcpus vcpus=${vnode_data[3]}"
+ if [ -n "${vnode_data[6]}" ]; then
+ virt_cpu_args+=",sockets=${vnode_data[4]},cores=${vnode_data[5]},threads=${vnode_data[6]}"
fi
# prepare network args
@@ -379,18 +383,12 @@ function create_vms {
net_args="${net_args} --network bridge=${net},model=virtio"
done
- # dedicated storage drive for cinder on cmp nodes
- virt_extra_storage=
- if [[ "${vnode_data[0]}" =~ ^(cmp) ]]; then
- virt_extra_storage="--disk path=${image_dir}/mcp_${vnode_data[0]}_storage.qcow2,format=qcow2,bus=virtio,cache=none,io=native"
- fi
-
[ ! -e "${image_dir}/virt-manager" ] || VIRT_PREFIX="${image_dir}/virt-manager/"
# shellcheck disable=SC2086
${VIRT_PREFIX}${VIRSH/virsh/virt-install} --name "${vnode_data[0]}" \
${virt_cpu_args} --accelerate \
${net_args} \
- --ram "${vnode_data[1]}" \
+ --ram "${vnode_data[2]}" \
--disk path="${image_dir}/mcp_${vnode_data[0]}.qcow2",format=qcow2,bus=virtio,cache=none,io=native \
${virt_extra_storage} \
--os-type linux --os-variant none \
diff --git a/mcp/scripts/lib_template.sh b/mcp/scripts/lib_template.sh
index 980827c7a..b44702235 100644
--- a/mcp/scripts/lib_template.sh
+++ b/mcp/scripts/lib_template.sh
@@ -47,9 +47,6 @@ function do_templates_scenario {
notify_e "[ERROR] IDF does not match yaml schema!"
fi
fi
- for _yaml in "${extra_yaml[@]}"; do
- awk '/^---$/{f=1;next;}f' "${_yaml}" >> "${LOCAL_PDF}"
- done
if ! "${PHAROS_GEN_CFG}" -y "${LOCAL_PDF}" \
-i "$(dirname "$(readlink -f "${PHAROS_IA}")")" \
-j "${PHAROS_IA}" -v > "${image_dir}/pod_config.yml"; then
@@ -63,6 +60,9 @@ function do_templates_scenario {
-i "$(dirname "$(readlink -f "${PHAROS_IA}")")"; then
notify_e '[ERROR] Could not convert j2 scenario definitions!'
fi
+ for _yaml in "${extra_yaml[@]}"; do
+ awk '/^---$/{f=1;next;}f' "${_yaml}" >> "${LOCAL_PDF}"
+ done
}
# Expand reclass and virsh network templates based on PDF + IDF + others
diff --git a/mcp/scripts/xdf_data.sh.j2 b/mcp/scripts/xdf_data.sh.j2
index 187f09296..346a9e53e 100644
--- a/mcp/scripts/xdf_data.sh.j2
+++ b/mcp/scripts/xdf_data.sh.j2
@@ -44,7 +44,8 @@
{%- do V[n].update({'s_numa': c if 's_numa' not in V[n] else pack([c, V[n].s_numa])}) -%}
{%- endfor -%}
{%- endif -%}
- {%- do arr.append(pack([n, V[n].ram or arch.default.ram,
+ {%- do arr.append(pack([n, V[n].disks or arch.default.disks,
+ V[n].ram or arch.default.ram,
V[n].vcpus or arch.default.vcpus,
'' if not cpu_topo else pack([
V[n].cpu_topology.sockets,