summaryrefslogblamecommitdiffstats
path: root/remote/modules/vmware/data/opt/openslx/vmchooser/vmware/includes/parse_vmx.inc
blob: 7b9f46c3f051a7a7a0b6186a37a9de5a220c4151 (plain) (tree)













































































                                                                                                                          
######################################################################
# Include: Parsing the non-legacy delivered vmxfile $TMPDIR/$IMGUUID #
######################################################################

writelog "Now in parse_vmx.inc."

# check for vmdk file marker %VM_DISK_PATH% and put vmdk path in it's place: also VM_DISK_MODE
# and VM_DISK_REDOLOGDIR.
# IMAGE=$(grep -io '<image_path.*"' "${xmlfile}" | sed -e "s/&.*;/; /g" | awk -F '"' '{ print $2 }')
sed -i 's#%VM_DISK_PATH%#'"$vm_diskfile"'#g' "$TMPDIR/$IMGUUID"
sed -i 's#%VM_DISK_MODE%#'"independent-nonpersistent"'#g' "$TMPDIR/$IMGUUID"
sed -i 's#%VM_DISK_REDOLOGDIR%#'"$redodir"'#g' "$TMPDIR/$IMGUUID"

# Ethernet: All we do is entering a generated MAC, as we do not want to interfere
# in the possible case no networking is wanted.
writelog "Guest MAC: $macaddr"
echo 'ethernet0.address = "'"${macaddr}"'"' >> "$TMPDIR/$IMGUUID"

# Massenspeicher: DVD, CDROM
cat >> "$TMPDIR/$IMGUUID" <<-HEREEND
ide1:0.present = "$cdrom0"
ide1:0.autodetect = "TRUE"
ide1:0.fileName = "auto detect"
ide1:0.deviceType = "cdrom-raw"
ide1:1.present = "$cdrom1"
ide1:1.autodetect = "TRUE"
ide1:1.fileName = "auto detect"
ide1:1.deviceType = "cdrom-raw"
HEREEND

# Floppies: 
cat >> "$TMPDIR/$IMGUUID" <<-HEREEND
floppy0.present = "$floppy0"
floppy0.startConnected = "FALSE"
floppy0.autodetect = "TRUE"
floppy0.fileName = "auto detect"
floppy1.present = "$floppy1"
floppy1.startConnected = "TRUE"
floppy1.fileType = "file"
floppy1.fileName = "$floppy1name"
HEREEND

# RAM, CPUs
cat >> "$TMPDIR/$IMGUUID" <<-HEREEND
numvcpus = "$cpu_cores"
cpuid.coresPerSocket = "$cores_per_socket"
maxvcpus = "$real_core_count"
memsize = "$mem"
MemAllowAutoScaleDown = "FALSE"
MemTrimRate = "-1"
HEREEND

# USB
cat >> "$TMPDIR/$IMGUUID" <<-HEREEND
usb.present = "TRUE"
usb.generic.autoconnect = "TRUE"
HEREEND

# Seriell, Parallel: Empty, nothing is being currently set. TODO later.

# rausziehen: Hardwareversion
# hwver=$(echo "${imghead}" | grep -m1 -ia "ddb.virtualHWVersion" | awk -F '"' '{print $2}')
# writelog "hwver: $hwver"
# sed -i	"s/virtualHW.version.*/virtualHW.version = $hwver/g" "$TMPDIR/$IMGUUID"
# cleanexit 1

# rausziehen: GuestOS

# Killing duplicate lines (output much nicer as sort -u):
awk '!a[$0]++' "${TMPDIR}/${IMGUUID}" > "${TMPDIR}/${IMGUUID}.tmp" && mv "${TMPDIR}/${IMGUUID}.tmp" "${TMPDIR}/${IMGUUID}"

# At last_ Let's copy it to $confdir/run-vmware.conf
cp -p "$TMPDIR/$IMGUUID" "$conffile" && writelog "Copied TMPDIR/IMGUUID -$TMPDIR/$IMGUUID- to conffile -$conffile-" || \
	( writelog "Could not copy TMPDIR/IMGUUID -$TMPDIR/$IMGUUID- to conffile -$conffile-!"; cleanexit 1 ) 

# TODO: Move this to cleanexit.
rm -f "$TMPDIR/$IMGUUID"	|| writelog "Could not delete $TMPDIR/$IMGUUID."
rmdir "$TMPDIR"			|| writelog "Could not rmdir $TMPDIR"