#!/bin/bash # configuration OVIRT_URL="https://engine/api" OVIRT_USERNAME="admin@internal" OVIRT_PASSWORD="password" # the main script starts here VM_NAME=`sed -n 's|\(.*\)|\1|p' $_hook_domxml | tr -s ' ' ' ' | cut -d' ' -f2` VM_ID=`sed -n 's|\(.*\)|\1|p' $_hook_domxml | tr -s ' ' ' ' | cut -d' ' -f2` VM_NAME=`echo ${VM_NAME} | tr -d ' '` VM_ID=`echo ${VM_ID} | tr -d ' '` PAYLOAD="hostname: ${VM_NAME}" # set payload curl -X PUT -H "Accept: application/xml" -H "Content-Type: application/xml" -u $OVIRT_USERNAME:$OVIRT_PASSWORD -k $OVIRT_URL/vms/${VM_ID} -d "${PAYLOAD}" || exit 1 exit 0