meta data for this page
VM-ek diszkjeinek listázása
#!/bin/bash
. ovm_functions.sh
kulcs_ellenorzes
printf $yel
echo "VM" "Disk_name" "Repository/WWN" "Disk_Size" "Virt/Phys"| awk '{printf "%-40s %-30s %-40s %10s %3s\n",$1,$2,$3,$4,$5}'
printf $end
ovm_cli "list vmdiskMapping" | egrep -v '(EMPTY_CDROM)' | grep -v '^$' | grep ')' | while read SOR; do
ID=$(echo $SOR | grep -oP "(?<=id:)[^ ]+(?= )")
DISK_ID=$(echo $SOR | grep -oP "(?<=\()[^ ]+(?=\))")
VM=$(ovm_cli "show vmdiskMapping id=$ID" | grep "[[:space:]][[:space:]]Vm" | grep -oP "(?<=\[)[^ ]+(?=\])")
[[ $DISK_ID =~ \.iso$ ]] && continue;
if [[ $DISK_ID =~ img$ ]]; then
DISK_FILENAME=$DISK_ID
DISK_NAME=$(ovm_exec "show virtualdisk name=$DISK_ID" "[[:space:]][[:space:]]Name")
DISK_REPO=$(ovm_cli "show virtualdisk name=$DISK_ID" | grep "Repository Id" | grep -oP "(?<=\[)[^ ]+(?=\])")
DISK_SIZE=$(ovm_exec "show virtualdisk name=$DISK_ID" "Max \(GiB\)")
printf ${whi}
echo "$VM" "$DISK_NAME" "[$DISK_REPO]" "${DISK_SIZE}G" "V" | awk '{printf "%-40s %-30s %-40s %10s %3s\n",$1,$2,$3,$4,$5}'
printf ${end}
else
DISK_ID=$(ovm_exec "show vmdiskMapping id=$ID" "Physical Disk")
DISK_WWN=$(ovm_exec "show physicalDisk id=$DISK_ID" "User-Friendly Name")
DISK_NAME=$(ovm_exec "show physicalDisk id=$DISK_ID" "[[:space:]][[:space:]]Name")
DISK_SIZE=$(ovm_exec "show physicalDisk id=$DISK_ID" "Size \(GiB\)")
echo "$VM" "$DISK_NAME" "[$DISK_WWN]" "${DISK_SIZE}G" "P" | awk '{printf "%-40s %-30s %-40s %10s %3s\n",$1,$2,$3,$4,$5}'
fi
done | sort -k1
Fizikai diszkek listája guest device névvel és UUID-val:
#!/bin/bash
. ovm_functions.sh
kulcs_ellenorzes
OUT_FILE=ovm_list_vm_phys_disks.lst
TMP_FILE=${0}.tmp
ovm_cli "list vmdiskmapping" | awk -F' ' '/id:/{print $2}' | sed 's/id://' | while read SOR; do
[[ ! $(ovm_cli "show vmdiskmapping id=$SOR") =~ Physical.Disk || $(grep -c $SOR $OUT_FILE) -gt 0 ]] && continue;
ovm_cli "show vmdiskmapping id=$SOR" 2>&1 > ${TMP_FILE}.1
PHYS_DISK=$(cat ${TMP_FILE}.1 | grep 'Physical.Disk' | sed -r 's/(^.*\[)(.*)(\])/\2/')
PHYS_DISK_ID=$(cat ${TMP_FILE}.1 | egrep 'Physical.Disk' | awk '{print $5}')
PHYS_DISK_UUID=$(ovm_exec "show PhysicalDisk id=$PHYS_DISK_ID" "User-Friendly Name")
SLOT_NR=$(cat ${TMP_FILE}.1 | awk -F'=' '/Slot/{print $2}')
VM_NAME=$(cat ${TMP_FILE}.1 | egrep 'Vm' | sed -r 's/(^.*\[)(.*)(\])/\2/')
VM_ID=$(cat ${TMP_FILE}.1 | egrep 'Vm' | awk '{print $4}')
LNX_DEV=$(ovm_cli "getVmCfgFileContent vm id=$VM_ID" |grep "disk =" | perl -ne 's/,(?=[a-z]{3}[a-z]*:)/#/g; print;' | sed 's/\(.*\[\)\(.*\)\]/\2/' | tr '#' '\n' | awk -F',' '/'${PHYS_DISK_UUID,,}'/{print $2}')
echo -e "${SOR}\t${VM_NAME}\t${LNX_DEV}\t${PHYS_DISK}\t${SLOT_NR}"
done | tee -a $OUT_FILE
rm -f $TMP_FILE