function CUSTOM_IMG(){ STOR=$1; ID=$2; PASS_HOST=$3; PASS_VM=$4; IMG=$(find $STOR -type f | grep $ID | grep -vE 'meta|lease') expect <<EOF set timeout 3 spawn virt-customize -a $IMG --root-password file:$PASS_VM --copy-in /oh-my-zsh:/ expect "Please enter your authentication name:" send "root\r" expect "Please enter your password:" send "$PASS_HOST\r" expect eof EOF echo $ID } function SYSPREP_IMG(){ STOR=$1; ID=$2; PASS_HOST=$3; IMG=$(find $STOR -type f | grep $ID | grep -vE 'meta|lease') expect <<EOF set timeout 3 virt-sysprep -a $IMG --operations defaults,-package-manager-cache,-ssh-userdir expect "Please enter your authentication name:" send "root\r" expect "Please enter your password:" send "$PASS_HOST\r" expect eof EOF echo $ID } |
# STOR=/rhev/data-center/mnt/glusterSD/n1.ovirt1.int:_vmstore01 # PASS_VM=pass_vm.txt # PASS_HOST=$(cat pass_host.txt) # ID=5c49b8ae-90cb-43e5-bc24-1a00d7e7d474; # CUSTOM_IMG $STOR $ID $PASS $PFILE; spawn virt-customize -a /rhev/data-center/mnt/glusterSD/n1.ovirt1.int:_vmstore01/fa2d78c0-edc2-401d-8d9b-1501b2940174/images/c7103ab1-d84f-43c1-8e5b-cf20cd961720/aab6c629-445f-4ce2-8bbd-afc7b6d991df --root-password file:pass.txt --copy-in /oh-my-zsh:/ [ 0.0] Examining the guest ... libvirt needs authentication to connect to libvirt URI qemu:///system (see also: http://libvirt.org/auth.html http://libvirt.org/uri.html) Please enter your authentication name: root Please enter your password: c7103ab1-d84f-43c1-8e5b-cf20cd961720 |