lib/testlab.rb in testlab-0.4.0 vs lib/testlab.rb in testlab-0.4.1
- old
+ new
@@ -20,11 +20,12 @@
# apt-get -y update
# apt-get -y install dnsutils
# EOF
#
# config Hash[
-# :domain => "default.zone"
+# :domain => "default.zone",
+# :repo => File.join(ENV['HOME'], "code", "personal", "testlab-repo")
# ]
#
# node :localhost do
# components %w(resolv bind)
# route true
@@ -37,12 +38,11 @@
# :user => "vagrant",
# :port => 22,
# :cpus => 8,
# :memory => 16384,
# :box => 'raring64'
-# },
-# :repo => File.join(ENV['HOME'], "code", "personal", "testlab-repo")
+# }
# ]
#
# network :east do
# address '10.10.0.1/16'
# bridge :br0
@@ -101,10 +101,11 @@
self.ui = (options[:ui] || ZTK::UI.new)
labfile = (options[:labfile] || 'Labfile')
labfile_path = ZTK::Locator.find(labfile)
@labfile = TestLab::Labfile.load(labfile_path)
+ @labfile.config.merge!(:testlab => self)
end
# Test Lab Nodes
#
# Returns an array of our defined nodes.
@@ -200,10 +201,21 @@
end
true
end
+ # TestLab Configuration Directory
+ #
+ # Returns the path to the test lab configuration directory which is located
+ # off the repo directory under '.testlab'.
+ #
+ # @return [String] The path to the TestLab configuration directory.
+ def config_dir
+ directory = File.join(self.config[:repo], '.testlab')
+ File.expand_path(directory, File.dirname(__FILE__))
+ end
+
# Provider Method Handler
#
# Proxies missing provider method calls to all nodes.
#
# @see TestLab::Provider::PROXY_METHODS
@@ -219,11 +231,11 @@
# Test Lab Class Methods
#
# These are special methods that we both include and extend on the parent
# class.
- module ClassMethods
+ module DualMethods
@@ui ||= nil
# Get Test Lab User Interface
#
@@ -264,15 +276,15 @@
# simply rely on */bin/env* to find the executable for us via the
# *PATH* environment variable.
#
# @return [String] Constructed command line with arguments.
def build_command_line(name, *args)
- executable = (ZTK::Locator.find('bin', name) rescue "/bin/env #{name}")
+ executable = (ZTK::Locator.find('bin', name) rescue "/usr/bin/env #{name}")
[executable, args].flatten.compact.join(' ')
end
end
- include TestLab::ClassMethods
- extend TestLab::ClassMethods
+ include TestLab::DualMethods
+ extend TestLab::DualMethods
end