class Puter::Provider::Vm
Public Instance Methods
build(build_path, image_path, template_name, opts, &block)
click to toggle source
# File lib/puter/providers/vm.rb, line 22 def build(build_path, image_path, template_name, opts, &block) vmonkey.folder('/').mk_parent_folder build_path template = vmonkey.vm! template_name if opts[:force] build = template.clone_to! build_path else build = template.clone_to build_path end build.start build.wait_for_port 22 block.call(build.guest_ip) if block build.stop build.MarkAsTemplate() vmonkey.folder('/').mk_parent_folder image_path if opts[:force] build.move_to! image_path else build.move_to image_path end end
create(image_path, instance_path, opts)
click to toggle source
# File lib/puter/providers/vm.rb, line 51 def create(image_path, instance_path, opts) vmonkey.folder('/').mk_parent_folder instance_path if opts[:force] vmonkey.vm!(image_path).clone_to! instance_path else vmonkey.vm!(image_path).clone_to instance_path end end
host(name, &block)
click to toggle source
# File lib/puter/providers/vm.rb, line 17 def host(name, &block) target = vmonkey.vm! name block.call(target.guest_ip) end
images(path, sub="")
click to toggle source
# File lib/puter/providers/vm.rb, line 8 def images(path, sub="") folder = vmonkey.folder!(path) imgs = folder.templates.collect { |t| "#{sub}#{t.name}" } folder.folders.each do |sub_folder| imgs += images("#{path}/#{sub_folder.name}", "#{sub}#{sub_folder.name}/") end imgs end
init(path)
click to toggle source
# File lib/puter/providers/vm.rb, line 94 def init(path) root = vmonkey.folder '/' root.mk_folder "#{path}/Build" root.mk_folder "#{path}/Images" root.mk_folder "#{path}/Instances" end
kill(instance_name)
click to toggle source
# File lib/puter/providers/vm.rb, line 73 def kill(instance_name) instance = vmonkey.vm! instance_name instance.kill end
ps(instances_path, all, sub="")
click to toggle source
# File lib/puter/providers/vm.rb, line 78 def ps(instances_path, all, sub="") folder = vmonkey.folder! instances_path instances = folder.vms instances.select! { |vm| vm.runtime.powerState == 'poweredOn' } unless all ret = instances.collect { |i| "#{sub}#{i.name}" } folder.folders.each do |sub_folder| ret += ps("#{instances_path}/#{sub_folder.name}", all, "#{sub}#{sub_folder.name}/") end ret end
rm(path)
click to toggle source
# File lib/puter/providers/vm.rb, line 90 def rm(path) vmonkey.vm!(path).destroy end
rmi(path)
click to toggle source
# File lib/puter/providers/vm.rb, line 47 def rmi(path) vmonkey.template!(path).destroy end
start(instance_name, &block)
click to toggle source
# File lib/puter/providers/vm.rb, line 61 def start(instance_name, &block) instance = vmonkey.vm! instance_name instance.start instance.wait_for_port 22 block.call(instance.guest_ip) if block end
stop(instance_name)
click to toggle source
# File lib/puter/providers/vm.rb, line 68 def stop(instance_name) instance = vmonkey.vm! instance_name instance.stop end
vmonkey()
click to toggle source
# File lib/puter/providers/vm.rb, line 101 def vmonkey @vmonkey ||= VMonkey.connect end