File: kvm-ssh.dev

package info (click to toggle)
powerman 2.4.4-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,432 kB
  • sloc: ansic: 19,458; sh: 7,225; yacc: 694; makefile: 455; lex: 272
file content (41 lines) | stat: -rw-r--r-- 1,166 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
###KVM (Kernel-based Virtual Machine) over ssh script###
# PowerMan script for controlling virtual machines running on remote KVM (Kernel-based Virtual Machine) hypervisors, e.g.
#  after setting up passwordless ssh access to hypervisor:
#  device   "hypervisor_hostname/IP_address"    "kvm-ssh"                           "/usr/bin/ssh -o StrictHostKeyChecking=no -a -l username -p 22 hypervisor_hostname/IP_address|&"
#  node     "vm_name"                           "hypervisor_hostname/IP_address"    "vm_name"
#

specification "kvm-ssh" {
	timeout 	5

	script login {
		expect "#"
	}
	script logout {
		send "exit\n"
	}

	script status {
		send "virsh domstate %s\n"
		expect "(running|off)"
		setplugstate $1 off="off" on="running"
	}

	script on {
		send "virsh start %s\n"
		expect "started|Domain is already active"
	}
	script off {
		send "virsh destroy %s\n"
		expect "destroyed|domain is not running"
	}
	script cycle {
		#yes, there is a reset command, but it does nothing if the vm is powered off
		send "virsh destroy %s\n"
		expect "destroyed|domain is not running"
		delay 1
		send "virsh start %s\n"
		expect "started|Domain is already active"
	}
}