bugfix & cleanup of the vm loading and a speedup / bugfix for the regex lib
git-svn-id: file:///home/svn/framework3/trunk@12032 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
ea274d1537
commit
d45b2aaa20
|
@ -27,30 +27,18 @@ module Controllers
|
||||||
include Lab::Controllers::RemoteWorkstationController ## gives access to workstation-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::QemuController ## gives access to qemu-specific controller methods
|
||||||
#include Lab::Controllers::AmazonController ## gives access to amazon-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::VirtualBoxController ## gives access to virtualbox-specific controller methods
|
||||||
#include Lab::Controllers::DynagenController ## gives access to dynagen-specific controller methods
|
#include Lab::Controllers::DynagenController ## gives access to dynagen-specific controller methods
|
||||||
|
|
||||||
|
|
||||||
def initialize (labdef = nil)
|
def initialize (labdef = nil)
|
||||||
|
|
||||||
@vms = [] ## Start with an empty array of vms
|
@vms = [] ## Start with an empty array of vms
|
||||||
|
|
||||||
## labdef is a big array of hashes (vms) - generally loaded from yaml
|
## labdef is a big array of hashes, use yaml to store
|
||||||
if !labdef
|
labdef = [] unless labdef
|
||||||
labdef = [] ## Just use a blank lab to start
|
|
||||||
else
|
|
||||||
labdef = labdef
|
|
||||||
end
|
|
||||||
|
|
||||||
## Create vm objects from the lab definition
|
## Create vm objects from the lab definition
|
||||||
labdef.each do |item|
|
load_vms(labdef)
|
||||||
begin
|
|
||||||
@vms << Vm.new(item)
|
|
||||||
rescue Exception => e
|
|
||||||
puts "Invalid VM definition"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def clear!
|
def clear!
|
||||||
|
@ -85,17 +73,22 @@ module Controllers
|
||||||
|
|
||||||
def from_file(file)
|
def from_file(file)
|
||||||
labdef = YAML::load_file(file)
|
labdef = YAML::load_file(file)
|
||||||
|
load_vms(labdef)
|
||||||
|
end
|
||||||
|
|
||||||
labdef.each do |item|
|
def load_vms(vms)
|
||||||
#puts "Lab item: " + item.inspect
|
vms.each do |item|
|
||||||
@vms << Vm.new(item)
|
begin
|
||||||
|
vm = Vm.new(item)
|
||||||
|
@vms << vm unless includes_vmid? vm.vmid
|
||||||
|
rescue Exception => e
|
||||||
|
puts "Invalid VM definition"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_file(file)
|
def to_file(file)
|
||||||
File.open(file, 'w') do |f|
|
File.open(file, 'w') { |f| @vms.each { |vm| f.puts vm.to_yaml } }
|
||||||
@vms.each { |vm| f.puts vm.to_yaml }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def each &block
|
def each &block
|
||||||
|
@ -107,7 +100,10 @@ module Controllers
|
||||||
end
|
end
|
||||||
|
|
||||||
def includes_vmid?(vmid)
|
def includes_vmid?(vmid)
|
||||||
@vms.each { |vm| if (vm.vmid.to_s == vmid.to_s) then return true end }
|
@vms.each do |vm|
|
||||||
|
return true if (vm.vmid == vmid)
|
||||||
|
end
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_from_dir(type, dir, clear=false)
|
def build_from_dir(type, dir, clear=false)
|
||||||
|
|
|
@ -13,9 +13,12 @@ class Regexr
|
||||||
|
|
||||||
# Check for the beginning and end lines. Handy when you need to ensure a log has started & completed
|
# Check for the beginning and end lines. Handy when you need to ensure a log has started & completed
|
||||||
def verify_start_and_end(data,the_start,the_end)
|
def verify_start_and_end(data,the_start,the_end)
|
||||||
|
return false unless data
|
||||||
|
|
||||||
data_lines = data.split("\n")
|
data_lines = data.split("\n")
|
||||||
regex_start = Regexp.new(the_start, @case_insensitive)
|
regex_start = Regexp.new(the_start, @case_insensitive)
|
||||||
regex_end = Regexp.new(the_end, @case_insensitive)
|
regex_end = Regexp.new(the_end, @case_insensitive)
|
||||||
|
|
||||||
if regex_start =~ data_lines.first
|
if regex_start =~ data_lines.first
|
||||||
return regex_end =~ data_lines.last
|
return regex_end =~ data_lines.last
|
||||||
end
|
end
|
||||||
|
@ -25,6 +28,8 @@ class Regexr
|
||||||
|
|
||||||
# Scan for any number of success lines. In order to pass, all successes must match.
|
# Scan for any number of success lines. In order to pass, all successes must match.
|
||||||
def find_strings_that_dont_exist_in_data(data,regexes=[])
|
def find_strings_that_dont_exist_in_data(data,regexes=[])
|
||||||
|
return false unless data
|
||||||
|
|
||||||
data_lines = data.split("\n")
|
data_lines = data.split("\n")
|
||||||
|
|
||||||
return nil unless regexes ## count as a pass
|
return nil unless regexes ## count as a pass
|
||||||
|
@ -60,6 +65,9 @@ class Regexr
|
||||||
|
|
||||||
# Scan for failures -- if any single failure matches, the test returns true.
|
# Scan for failures -- if any single failure matches, the test returns true.
|
||||||
def find_strings_that_exist_in_data_except(data,regexes=[],exceptions=[])
|
def find_strings_that_exist_in_data_except(data,regexes=[],exceptions=[])
|
||||||
|
|
||||||
|
return false unless data
|
||||||
|
|
||||||
data_lines = data.split("\n")
|
data_lines = data.split("\n")
|
||||||
|
|
||||||
return nil unless regexes ## count as a pass
|
return nil unless regexes ## count as a pass
|
||||||
|
|
Loading…
Reference in New Issue