Updated Auto Scripts - Alpha Tested on my KVM Domains

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dear Test Community:
    Some time ago I mentioned automatic scripts for starting and executing commands on a VM.  At the time the scripts were geared to VirtualBox-OSE.  Now I switched to using KVM and regeared the scripts for automatic starting, maintenance and shutdown of a VM on a host.

The attached script works on my F13_x86-64 Host running a KVM

Guest. I tested the script on F12i386 ; F12x8664 ; F13i386 and F13x8664.

The flags on my system are below:

[Bob@FedoraMythbox ~]$ egrep '^flags.*(vmx|svm)' /proc/cpuinfo
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov
pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm
constant_tsc arch_perfmon pebs bts rep_good aperfmperf pni dtes64
monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm lahf_lm tpr_shadow vnmi
flexpriority
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov
pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm
constant_tsc arch_perfmon pebs bts rep_good aperfmperf pni dtes64
monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm lahf_lm tpr_shadow vnmi
flexpriority
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov
pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm
constant_tsc arch_perfmon pebs bts rep_good aperfmperf pni dtes64
monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm lahf_lm tpr_shadow vnmi
flexpriority
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov
pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm
constant_tsc arch_perfmon pebs bts rep_good aperfmperf pni dtes64
monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm lahf_lm tpr_shadow vnmi
flexpriority

Sincerely,

Bob Lightfoot

P.S. - The comments at the start of the script should be self explanatory.  This is an alpha version and not fully "bullet-proof". It needs to run as root for the virsh commands to have authority.




#!/usr/bin/expect -f
#
# This Expect script was hand generated by BobLfoot on Mon Ju1 12 20:53:00 2010
# Expect and autoexpect were both written by Don Libes, NIST.
#
# It's purpose is to connect to and update the Fedora386Outgoing KVM Domain
#
# Establish the Constants for this Script
# vmname is the Domains Name
set vmname "SomeDomainName"
# domusername is the Domains Standard Users Name
set domusername "User"
# passuer is the Domains Standard Users Password
set passuser "PaSsWoRdHeRe"
# passroot is the Domains Root Users Password
set passroot "RoOtPaSsWoRdHeRe"
# vmip is the Domains Fixed IP address in the DHCP Table
set vmip "ip.to.kvm.domain"
# vmcmd is the super user level command you want the VM to run
# examples are as follow:
# set vmcmd "yum update --enablerepo=updates-testing --skip-broken -y"
set vmcmd "yum install fedora-easy-karma yum-plugin-filter-data --enablerepo=updates-testing --skip-broken -y"
# set vmcmd "ls -laZR /""
#set vmcmd "yum --filter-groups=core,critical-path-\* update --enablerepo=updates-testing -y --skip-broken"

# Boilerplate from Don Libes for conservative mode
set force_conservative 0  ;# set to 1 to force conservative mode even if
			  ;# script wasn't run conservatively originally
if {$force_conservative} {
	set send_slow {1 .1}
	proc send {ignore arg} {
		sleep .1
		exp_send -s -- $arg
	}
}

# Real Working Script Starts Here
set timeout -1
spawn $env(SHELL)
sleep .1
# Start target KVM Domain
send -- "virsh start $vmname\r"
expect 	"#" 
sleep 15
# SSH to Started VM
send -- "ssh $domusername\@$vmip\r"
expect {
	"password: " {
	  send -- "$passuser\r"
	}
	"No route to host" {
	  send -- "echo Waiting 15 More Seconds for $vmname to Boot\r"
	  sleep 15
	  send -- "ssh $domusername\@$vmip\r"
	  exp_continue
	}
	"timed out" {
	  send -- "echo Waiting 15 More Seconds for $vmname to Boot\r"
	  sleep 15
	  send -- "ssh $domusername\@$vmip\r"
	  exp_continue
	}
	"refused" {
	  send -- "echo Waiting 15 More Seconds for $vmname to Boot\r"
	  sleep 15
	  send -- "ssh $domusername\@$vmip\r"
	  exp_continue
	}
	"yes/no" {
	  send -- "yes\r"
	  sleep .1
	  exp_continue
	}}
sleep .1
expect "$ "
send -- "su\r"
sleep .1
expect "Password: "
send -- "$passroot\r"
sleep 1
expect "#"
send -- "$vmcmd\r"
expect "#"
send -- "exit\r"
sleep .1
expect "$ "
send -- "exit\r"
sleep .1
expect "# "

# Stop the Target KVM Domain
send -- "virsh shutdown $vmname\r"
sleep 15
expect "# "



-- 
test mailing list
test@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe: 
https://admin.fedoraproject.org/mailman/listinfo/test

[Index of Archives]     [Fedora Desktop]     [Fedora SELinux]     [Photo Sharing]     [Yosemite Forum]     [KDE Users]

  Powered by Linux