make the _snapshot / running_list methods a little more sane
git-svn-id: file:///home/svn/framework3/trunk@11742 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
parent
5bb3a16e7a
commit
f8d03ea257
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue