blob: 98400dc62a78e8b93224f953a22bf6501f1b5848 [file] [log] [blame]
Denis Egorenko0d045ae2019-06-04 18:23:11 +04001#!/bin/bash
2
3set -e
alexz1c02cd62018-04-15 22:18:03 +02004
Denis Egorenkoc2656402019-04-19 18:17:50 +04005functionsFile="$(pwd)/functions.sh"
6
7if [[ ! -f ${functionsFile} ]]; then
8 echo "ERROR: Can not find 'functions' libfile (${functionsFile}), check your mcp/mcp-common-scripts repo."
9 exit 1
10else
11 source ${functionsFile}
12fi
alexz1c02cd62018-04-15 22:18:03 +020013
14if [[ -z ${VM_NAME} ]]; then
15 echo "ERROR: \$VM_NAME not set!"
16 exit 1
17fi
Denis Egorenkoc2656402019-04-19 18:17:50 +040018if [[ -z ${VM_SOURCE_DISK} ]] || [[ ! -f ${VM_SOURCE_DISK} ]]; then
alexz1c02cd62018-04-15 22:18:03 +020019 echo "ERROR: \$VM_SOURCE_DISK not set, or file does not exist!"
20 exit 1
21fi
Denis Egorenkoc2656402019-04-19 18:17:50 +040022if [[ -z ${VM_CONFIG_DISK} ]] || [[ ! -f ${VM_CONFIG_DISK} ]]; then
alexz1c02cd62018-04-15 22:18:03 +020023 echo "ERROR: \$VM_CONFIG_DISK not set, or file does not exist!"
24 exit 1
25fi
26
Denis Egorenkoabe23c52019-05-30 16:53:55 +040027prereq_check
Denis Egorenkodcc233d2019-03-06 18:09:24 +040028
Denis Egorenkoabe23c52019-05-30 16:53:55 +040029#### Make sure that both files are saved to system path which is available for libvirt-qemu:kvm
30export VM_SOURCE_DISK=$(place_file_under_libvirt_owned_dir ${VM_SOURCE_DISK} ${NON_DEFAULT_LIBVIRT_DIR})
31export VM_CONFIG_DISK=$(place_file_under_libvirt_owned_dir ${VM_CONFIG_DISK} ${NON_DEFAULT_LIBVIRT_DIR})
32
33render_config "${VM_NAME}" "${VM_MEM_KB}" "${VM_CPUS}" "${VM_SOURCE_DISK}" "${VM_CONFIG_DISK}"
alexz1c02cd62018-04-15 22:18:03 +020034
35virsh define $(pwd)/${VM_NAME}-vm.xml
36virsh autostart ${VM_NAME}
Denis Egorenko892089e2019-07-12 16:01:40 +040037
38allocationDataFile=$(isoinfo -i ${VM_CONFIG_DISK} -J -f | grep -w "allocation_data.yml")
39secretsFile=$(isoinfo -i ${VM_CONFIG_DISK} -J -f | grep "infra/secrets.yml")
Denis Egorenko6cb60522019-07-17 21:36:52 +040040cfgJenkinsPassword=$(isoinfo -i ${VM_CONFIG_DISK} -J -x ${secretsFile} | grep 'jenkins_cfg_admin_password_generated' | cut -f 2 -d ':' | tr -d ' ')
41cfgJenkinsAddress=$(isoinfo -i ${VM_CONFIG_DISK} -J -x ${allocationDataFile} | grep 'infra_config_deploy_address' | cut -f 2 -d ':' | tr -d ' ')
Denis Egorenko892089e2019-07-12 16:01:40 +040042echo "Once deployed, Jenkins will be available via: http://${cfgJenkinsAddress}:8081 and login creds are: admin / ${cfgJenkinsPassword}"