Provisioning beginning. Not much done yet.
This commit is contained in:
parent
19f82e72aa
commit
168c7e0f39
|
@ -12,4 +12,7 @@ Hobo::Config.run do |config|
|
|||
config.vm.base_mac = "0800279C2E41"
|
||||
config.vm.project_directory = "/hobo"
|
||||
config.vm.forward_port("ssh", 22, 2222)
|
||||
|
||||
config.chef.cookbooks_path = "cookbooks"
|
||||
config.chef.provisioning_path = "/tmp/hobo-chef"
|
||||
end
|
|
@ -12,6 +12,7 @@ require 'hobo/busy'
|
|||
require 'hobo/util'
|
||||
require 'hobo/config'
|
||||
require 'hobo/env'
|
||||
require 'hobo/provisioning'
|
||||
require 'hobo/ssh'
|
||||
require 'hobo/vm'
|
||||
|
||||
|
|
|
@ -61,21 +61,28 @@ module Hobo
|
|||
:protocol => protocol
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
def hd_location=(val)
|
||||
raise Exception.new "disk_storage must be set to a directory" unless File.directory?(val)
|
||||
@hd_location=val
|
||||
end
|
||||
end
|
||||
|
||||
class ChefConfig < Base
|
||||
attr_accessor :cookbooks_path
|
||||
attr_accessor :provisioning_path
|
||||
end
|
||||
|
||||
class Top < Base
|
||||
attr_accessor :dotfile_name
|
||||
attr_reader :ssh
|
||||
attr_reader :vm
|
||||
attr_reader :chef
|
||||
|
||||
def initialize
|
||||
@ssh = SSHConfig.new
|
||||
@vm = VMConfig.new
|
||||
@chef = ChefConfig.new
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
module Hobo
|
||||
class Provisioning
|
||||
include Hobo::Util
|
||||
|
||||
def initialize(vm)
|
||||
@vm = vm
|
||||
@vm.share_folder("hobo-provisioning", File.expand_path(Hobo.config.chef.cookbooks_path, Env.root_path), Hobo.config.chef.provisioning_path)
|
||||
end
|
||||
|
||||
def run
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -62,6 +62,11 @@ error
|
|||
def create
|
||||
share_folder("hobo-root", Env.root_path, Hobo.config.vm.project_directory)
|
||||
|
||||
# Create the provisioning object, prior to doing anything so it can
|
||||
# set any configuration on the VM object prior to creation
|
||||
provisioning = Provisioning.new(self)
|
||||
|
||||
# The path of righteousness
|
||||
import
|
||||
move_hd if Hobo.config[:vm][:hd_location]
|
||||
persist
|
||||
|
@ -70,6 +75,9 @@ error
|
|||
setup_shared_folders
|
||||
start
|
||||
mount_shared_folders
|
||||
|
||||
# Once we're started, run the provisioning
|
||||
provisioning.run
|
||||
end
|
||||
|
||||
def destroy
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
require File.join(File.dirname(__FILE__), '..', 'test_helper')
|
||||
|
||||
class ProvisioningTest < Test::Unit::TestCase
|
||||
context "initializing" do
|
||||
should "setup shared folder on VM" do
|
||||
File.expects(:expand_path).with(Hobo.config.chef.cookbooks_path, Hobo::Env.root_path).returns("foo")
|
||||
vm = mock("vm")
|
||||
vm.expects(:share_folder).with("hobo-provisioning", "foo", Hobo.config.chef.provisioning_path)
|
||||
Hobo::Provisioning.new(vm)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -73,7 +73,9 @@ class VMTest < Test::Unit::TestCase
|
|||
|
||||
context "creating" do
|
||||
should "create the VM in the proper order" do
|
||||
prov = mock("prov")
|
||||
create_seq = sequence("create_seq")
|
||||
Hobo::Provisioning.expects(:new).with(@vm).in_sequence(create_seq).returns(prov)
|
||||
@vm.expects(:import).in_sequence(create_seq)
|
||||
@vm.expects(:persist).in_sequence(create_seq)
|
||||
@vm.expects(:setup_mac_address).in_sequence(create_seq)
|
||||
|
@ -81,6 +83,7 @@ class VMTest < Test::Unit::TestCase
|
|||
@vm.expects(:setup_shared_folders).in_sequence(create_seq)
|
||||
@vm.expects(:start).in_sequence(create_seq)
|
||||
@vm.expects(:mount_shared_folders).in_sequence(create_seq)
|
||||
prov.expects(:run).in_sequence(create_seq)
|
||||
@vm.create
|
||||
end
|
||||
end
|
||||
|
|
|
@ -38,6 +38,9 @@ class Test::Unit::TestCase
|
|||
config.vm.base_mac = "42"
|
||||
config.vm.project_directory = "/hobo"
|
||||
config.vm.forward_port("ssh", 22, 2222)
|
||||
|
||||
config.chef.cookbooks_path = "cookbooks"
|
||||
config.chef.provisioning_path = "/tmp/hobo-chef"
|
||||
end
|
||||
|
||||
Hobo::Config.execute!
|
||||
|
|
Loading…
Reference in New Issue