blob: a438dbf8debd4cd92aeaa7d945cb55afb33bceb6 [file] [log] [blame]
alexz1c02cd62018-04-15 22:18:03 +02001#!/bin/bash -xe
2
Denis Egorenkoc2656402019-04-19 18:17:50 +04003functionsFile="$(pwd)/functions.sh"
4
5if [[ ! -f ${functionsFile} ]]; then
6 echo "ERROR: Can not find 'functions' libfile (${functionsFile}), check your mcp/mcp-common-scripts repo."
7 exit 1
8else
9 source ${functionsFile}
10fi
alexz1c02cd62018-04-15 22:18:03 +020011
12if [[ -z ${VM_NAME} ]]; then
13 echo "ERROR: \$VM_NAME not set!"
14 exit 1
15fi
Denis Egorenkoc2656402019-04-19 18:17:50 +040016if [[ -z ${VM_SOURCE_DISK} ]] || [[ ! -f ${VM_SOURCE_DISK} ]]; then
alexz1c02cd62018-04-15 22:18:03 +020017 echo "ERROR: \$VM_SOURCE_DISK not set, or file does not exist!"
18 exit 1
19fi
Denis Egorenkoc2656402019-04-19 18:17:50 +040020if [[ -z ${VM_CONFIG_DISK} ]] || [[ ! -f ${VM_CONFIG_DISK} ]]; then
alexz1c02cd62018-04-15 22:18:03 +020021 echo "ERROR: \$VM_CONFIG_DISK not set, or file does not exist!"
22 exit 1
23fi
24
Denis Egorenkodcc233d2019-03-06 18:09:24 +040025check_packages
26
Denis Egorenkob04de352019-05-29 17:09:34 +040027if [ -z "${NON_DEFAULT_LIBVIRT_DIR}" ]; then
28 #### Make sure that both files are saved to system path which is available for libvirt-qemu:kvm
29 export VM_SOURCE_DISK=$(place_file_under_libvirt ${VM_SOURCE_DISK})
30 export VM_CONFIG_DISK=$(place_file_under_libvirt ${VM_CONFIG_DISK})
31fi
Denis Egorenkoc2656402019-04-19 18:17:50 +040032export CREATE_NETWORKS=${CREATE_NETWORKS:-true}
Denis Egorenkoc2656402019-04-19 18:17:50 +040033render_config "${VM_NAME}" "${VM_MEM_KB}" "${VM_CPUS}" "${VM_SOURCE_DISK}" "${VM_CONFIG_DISK}" "${CREATE_NETWORKS}"
alexz1c02cd62018-04-15 22:18:03 +020034
35virsh define $(pwd)/${VM_NAME}-vm.xml
36virsh autostart ${VM_NAME}