virtualman 0.0.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/virtualman.rb +23 -10
- metadata +1 -1
data/lib/virtualman.rb
CHANGED
@@ -26,16 +26,20 @@ class Vm
|
|
26
26
|
puts `VBoxManage #{action} #{@name} #{param.join(" ")}`
|
27
27
|
end
|
28
28
|
|
29
|
-
# A method to
|
30
|
-
#
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
29
|
+
# A method to stop properly a vm
|
30
|
+
# It assumes that you have the name of the VM on your personnal hosts file or DNS
|
31
|
+
# It can be modified to use GuestAdditions instead
|
32
|
+
def stop!
|
33
|
+
$stdout.sync = true
|
34
|
+
if self.running?
|
35
|
+
`ssh root@#{self.name.delete "\""} "shutdown -h now"`
|
36
|
+
puts "Waiting for complete shutdown of #{self.name}"
|
37
|
+
while self.running?
|
38
|
+
print "."
|
39
|
+
sleep (1)
|
40
|
+
end
|
41
|
+
end
|
37
42
|
|
38
|
-
self.manage("startvm", "--type headless")
|
39
43
|
end
|
40
44
|
end
|
41
45
|
|
@@ -80,6 +84,15 @@ class VmLister < Array
|
|
80
84
|
|
81
85
|
# A method to automatically export the list of VMs
|
82
86
|
def backup!(folder)
|
83
|
-
self.each {|vm| vm.
|
87
|
+
self.each {|vm| vm.stop!}
|
88
|
+
sleep (5)
|
89
|
+
|
90
|
+
self.each do |vm|
|
91
|
+
filename = Time.now().strftime("#{vm.name.delete "\""}_%Y%m%dT%H%M")
|
92
|
+
vm.manage("export","-o #{folder}/#{filename}.ova")
|
93
|
+
sleep(5)
|
94
|
+
end
|
95
|
+
|
96
|
+
self.each {|vm| vm.manage("startvm", "--type headless")}
|
84
97
|
end
|
85
98
|
end
|