lib/testlab/provisioners/shell.rb in testlab-0.1.0 vs lib/testlab/provisioners/shell.rb in testlab-0.2.0

- old
+ new

@@ -7,13 +7,30 @@ # Shell Provisioner Class # # @author Zachary Patten <zachary@jovelabs.net> class Shell + require 'tempfile' def initialize(config={}, ui=nil) - @config = config - @ui = (ui || TestLab.ui) + @config = (config || Hash.new) + @ui = (ui || TestLab.ui) + + @config[:shell] ||= "/bin/bash" + end + + def setup(container) + if !@config[:setup].nil? + tempfile = Tempfile.new("bootstrap") + container.node.ssh.file(:target => File.join(container.lxc.fs_root, tempfile.path), :chmod => '0777', :chown => 'root:root') do |file| + file.puts(@config[:setup]) + end + container.lxc.attach(@config[:shell], tempfile.path) + end + end + + def teardown(container) + # NOOP end end end