diff --git a/lib/lab/amazon_driver.rb b/lib/lab/amazon_driver.rb index 3b0cb523c8..87adb88b54 100644 --- a/lib/lab/amazon_driver.rb +++ b/lib/lab/amazon_driver.rb @@ -58,10 +58,10 @@ module Drivers def reset end - def snapshot(name) + def create_snapshot(name) end - def revert(name) + def revert_snapshot(name) end def delete_snapshot(name) diff --git a/lib/lab/dynagen_driver.rb b/lib/lab/dynagen_driver.rb index 4d1b5dd691..c1d4af702e 100644 --- a/lib/lab/dynagen_driver.rb +++ b/lib/lab/dynagen_driver.rb @@ -55,11 +55,11 @@ module Drivers raise Exception, "Unsupported Command" end - def snapshot(name) + def create_snapshot(name) raise Exception, "Unsupported Command" end - def revert(name) + def revert_snapshot(name) raise Exception, "Unsupported Command" end diff --git a/lib/lab/remote_workstation_controller.rb b/lib/lab/remote_workstation_controller.rb index 819f3688c8..eaa09dafeb 100644 --- a/lib/lab/remote_workstation_controller.rb +++ b/lib/lab/remote_workstation_controller.rb @@ -2,7 +2,7 @@ module Lab module Controllers module RemoteWorkstationController - def self.workstation_running_list(user, host) + def self.running_list(user, host) user.gsub!(/^[[:alnum:]_-]*$/, '') host.gsub!(/^[[:alnum:]_-]*$/, '') @@ -12,7 +12,7 @@ module RemoteWorkstationController return vm_list end - def self.workstation_dir_list(basepath=nil) + def self.dir_list(basepath=nil) vm_list = Find.find(basepath).select { |f| f =~ /\.vmx$/ } return vm_list diff --git a/lib/lab/remote_workstation_driver.rb b/lib/lab/remote_workstation_driver.rb index c70e7b0265..609eb3bffa 100644 --- a/lib/lab/remote_workstation_driver.rb +++ b/lib/lab/remote_workstation_driver.rb @@ -50,11 +50,11 @@ class RemoteWorkstationDriver < VmDriver system_command("ssh #{@user}@#{@host} vmrun -T ws reset \\\'#{@location}\\\' nogui") end - def create(snapshot) + def create_snapshot(snapshot) system_command("ssh #{@user}@#{@host} vmrun -T ws snapshot \\\'#{@location}\\\' #{snapshot} nogui") end - def revert(snapshot) + def revert_snapshot(snapshot) system_command("ssh #{@user}@#{@host} vmrun -T ws revertToSnapshot \\\'#{@location}\\\' #{snapshot} nogui") end diff --git a/lib/lab/virtualbox_driver.rb b/lib/lab/virtualbox_driver.rb index 2231c92ae9..18ac662520 100644 --- a/lib/lab/virtualbox_driver.rb +++ b/lib/lab/virtualbox_driver.rb @@ -52,11 +52,11 @@ module Drivers system_command("VBoxManage controlvm #{@name} reset") end - def snapshot(name) + def create_snapshot(name) system_command("VBoxManage snapshot #{@name} take " + name) end - def revert(name) + def revert_snapshot(name) system_command("VBoxManage snapshot #{@name} restore " + name) end diff --git a/lib/lab/vm.rb b/lib/lab/vm.rb index 3c1ec25b4f..acc83015b6 100644 --- a/lib/lab/vm.rb +++ b/lib/lab/vm.rb @@ -91,16 +91,20 @@ class Vm @driver.resume end - def snapshot(name) - @driver.snapshot(name) + def create_snapshot(snapshot) + @driver.create_snapshot(snapshot) end - def revert(snapshot) - @driver.revert(snapshot) + def revert_snapshot(snapshot) + @driver.revert_snapshot(snapshot) end - + + def delete_snapshot(snapshot) + @driver.delete_snapshot(snapshot) + end + def revert_and_start(snapshot) - self.revert(snapshot) + self.revert_snapshot(snapshot) self.start end diff --git a/lib/lab/vm_controller.rb b/lib/lab/vm_controller.rb index 9b89979b33..da52c5a658 100644 --- a/lib/lab/vm_controller.rb +++ b/lib/lab/vm_controller.rb @@ -13,6 +13,7 @@ require 'vm' require 'yaml' require 'workstation_controller' require 'remote_workstation_controller' +#require 'qemu_controller' #require 'amazon_controller' #require 'virtualbox_controller' #require 'dynagen_controller' @@ -23,10 +24,11 @@ module Controllers include Enumerable include Lab::Controllers::WorkstationController ## gives access to workstation-specific controller methods - include Lab::Controllers::RemoteWorkstationController ## gives access to workstation-specific controller methods - #include Lab::AmazonController ## gives access to amazon-specific controller methods - #include Lab::VirtualBoxController ## gives access to virtualbox-specific controller methods - #include Lab::DynagenController ## gives access to dynagen-specific controller methods + include Lab::Controllers::RemoteWorkstationController ## gives access to workstation-specific controller methods + #include Lab::Controllers::QemuController ## gives access to qemu-specific controller methods + #include Lab::Controllers::AmazonController ## gives access to amazon-specific controller methods + #include Lab::Controllers::VirtualBoxController ## gives access to virtualbox-specific controller methods + #include Lab::Controllers::DynagenController ## gives access to dynagen-specific controller methods def initialize (labdef = nil) @@ -115,9 +117,9 @@ module Controllers end if type.downcase == "workstation" - vm_list = ::Lab::Controllers::WorkstationController::workstation_dir_list(dir) + vm_list = ::Lab::Controllers::WorkstationController::dir_list(dir) elsif type.downcase == "remote_workstation" - vm_list = ::Lab::Controllers::RemoteWorkstationController::workstation_dir_list(dir) + vm_list = ::Lab::Controllers::RemoteWorkstationController::dir_list(dir) else raise TypeError, "Unsupported VM Type" end @@ -136,9 +138,9 @@ module Controllers case type.intern when :workstation - vm_list = ::Lab::Controllers::WorkstationController::workstation_running_list + vm_list = ::Lab::Controllers::WorkstationController::running_list when :remote_workstation - vm_list = ::Lab::Controllers::RemoteWorkstationController::workstation_running_list(user, host) + vm_list = ::Lab::Controllers::RemoteWorkstationController::running_list(user, host) else raise TypeError, "Unsupported VM Type" end diff --git a/lib/lab/vm_driver.rb b/lib/lab/vm_driver.rb index 4dc505b019..57583a4744 100644 --- a/lib/lab/vm_driver.rb +++ b/lib/lab/vm_driver.rb @@ -39,10 +39,10 @@ class VmDriver def reset end - def snapshot(snapshot) + def create_snapshot(snapshot) end - def revert(snapshot) + def revert_snapshot(snapshot) end def delete_snapshot(snapshot) diff --git a/lib/lab/workstation_controller.rb b/lib/lab/workstation_controller.rb index 0666749a2e..1df19ebcd3 100644 --- a/lib/lab/workstation_controller.rb +++ b/lib/lab/workstation_controller.rb @@ -2,14 +2,14 @@ module Lab module Controllers module WorkstationController - def self.workstation_running_list + def self.running_list vm_list = `vmrun list`.split("\n") vm_list.shift return vm_list end - def self.workstation_dir_list(basepath=nil) + def self.dir_list(basepath=nil) vm_list = Find.find(basepath).select { |f| f =~ /\.vmx$/ } return vm_list diff --git a/lib/lab/workstation_driver.rb b/lib/lab/workstation_driver.rb index a0fb0bc2df..b6c5c79958 100644 --- a/lib/lab/workstation_driver.rb +++ b/lib/lab/workstation_driver.rb @@ -45,11 +45,11 @@ class WorkstationDriver < VmDriver system_command("vmrun -T ws reset " + "\"#{@location}\"") end - def create(snapshot) + def create_snapshot(snapshot) system_command("vmrun -T ws snapshot " + "\"#{@location}\" \"#{@snapshot}\"") end - def revert(snapshot) + def revert_snapshot(snapshot) system_command("vmrun -T ws revertToSnapshot " + "\"#{@location}\" \"#{@snapshot}\"") end