blob: 17f0e8ed7f87ab2e5d4cf0381c951eb5587317cd (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
############################################
# Include: Get needed values from XML file #
############################################
## Functions ##
parse_xml() {
# Sanity checks
if ! check_dep get_xml; then
writelog "Could not find 'get_xml'"
EXIT_TYPE="internal" EXIT_REASON="Keine XML-Unterstützung!" cleanexit 1
fi
writelog "Parsing XML..."
declare -rg VMSTORE_PATH=/mnt/vmstore
declare -rg IMGUUID=$(get_xml "uuid")
if isempty IMGUUID; then
writelog "Error parsing XML: No value for 'uuid'."
EXIT_TYPE="user" EXIT_REASON="Konnte keine ID für das ausgewählte Image ermitteln!" cleanexit 1
fi
# Set resource URLs for this lecture
[ -n "$url_lecture_config" ] && readonly url_lecture_config="${url_lecture_config//%UUID%/${IMGUUID}}"
[ -n "$url_lecture_metadata" ] && readonly url_lecture_metadata="${url_lecture_metadata//%UUID%/${IMGUUID}}"
[ -n "$url_lecture_netshares" ] && readonly url_lecture_netshares="${url_lecture_netshares//%UUID%/${IMGUUID}}"
[ -n "$url_lecture_runscript" ] && readonly url_lecture_runscript="${url_lecture_runscript//%UUID%/${IMGUUID}}"
# Relative / Absolute path to image
declare -g SRC_IMG_RELATIVE=$(get_xml "image_name")
declare -g SRC_IMG_ABSOLUTE=$(get_xml "image_path")
if notempty SRC_IMG_ABSOLUTE && [ "${SRC_IMG_ABSOLUTE:0:1}" != "/" ]; then
writelog "Error parsing XML: Parsed value for absolute path doesn't start with '/': '$SRC_IMG_ABSOLUTE'"
EXIT_TYPE="user" EXIT_REASON="Ungültiger asboluter Pfad zur virtuellen Maschine!" cleanexit 1
fi
VM_DISPLAYNAME=$(get_xml "short_description")
# image is for the following virtual machine
declare -rg PLUGIN_ID=$(get_xml "virtualmachine")
if isempty PLUGIN_ID; then
writelog "Error parsing XML: No value for 'virtualmachine'."
EXIT_TYPE="user" EXIT_REASON="Konnte kein Virtualisierer für das ausgewählte Image ermitteln." cleanexit 1
fi
# Extracting OS type (VM_OS_TYPE) from xml file. We don't care here whether VM_OS_TYPE is empty, as then
# it will yield the default entries later on.
declare -g VM_OS_TYPE=$(get_xml "os")
# Print summary to log
writelog "\tVirtualization plugin: $PLUGIN_ID"
writelog "\tVM filename: $IMG_BASENAME"
writelog "\tVM UUID: $IMGUUID"
writelog "\tVM name: $VM_DISPLAYNAME"
writelog "\tVM short name: $VM_CLEANNAME"
writelog "\tVM OS: $VM_OS_TYPE"
writelog "Done parsing XML."
return 0
}
## MAIN ##
call_post_source parse_xml
|