blob: 11bff46495f760923c9ed02e81752225cd921bac [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 Egorenkoc2656402019-04-19 18:17:50 +040027#### Make sure that both files are saved to system path which is available for libvirt-qemu:kvm
28export VM_SOURCE_DISK=$(place_file_under_libvirt ${VM_SOURCE_DISK})
29export VM_CONFIG_DISK=$(place_file_under_libvirt ${VM_CONFIG_DISK})
30export CREATE_NETWORKS=${CREATE_NETWORKS:-true}
Denis Egorenkodcc233d2019-03-06 18:09:24 +040031
Denis Egorenkoc2656402019-04-19 18:17:50 +040032render_config "${VM_NAME}" "${VM_MEM_KB}" "${VM_CPUS}" "${VM_SOURCE_DISK}" "${VM_CONFIG_DISK}" "${CREATE_NETWORKS}"
alexz1c02cd62018-04-15 22:18:03 +020033
34virsh define $(pwd)/${VM_NAME}-vm.xml
35virsh autostart ${VM_NAME}