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.base_mac = "0800279C2E41"
|
||||||
config.vm.project_directory = "/hobo"
|
config.vm.project_directory = "/hobo"
|
||||||
config.vm.forward_port("ssh", 22, 2222)
|
config.vm.forward_port("ssh", 22, 2222)
|
||||||
|
|
||||||
|
config.chef.cookbooks_path = "cookbooks"
|
||||||
|
config.chef.provisioning_path = "/tmp/hobo-chef"
|
||||||
end
|
end
|
|
@ -12,6 +12,7 @@ require 'hobo/busy'
|
||||||
require 'hobo/util'
|
require 'hobo/util'
|
||||||
require 'hobo/config'
|
require 'hobo/config'
|
||||||
require 'hobo/env'
|
require 'hobo/env'
|
||||||
|
require 'hobo/provisioning'
|
||||||
require 'hobo/ssh'
|
require 'hobo/ssh'
|
||||||
require 'hobo/vm'
|
require 'hobo/vm'
|
||||||
|
|
||||||
|
|
|
@ -68,14 +68,21 @@ module Hobo
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class ChefConfig < Base
|
||||||
|
attr_accessor :cookbooks_path
|
||||||
|
attr_accessor :provisioning_path
|
||||||
|
end
|
||||||
|
|
||||||
class Top < Base
|
class Top < Base
|
||||||
attr_accessor :dotfile_name
|
attr_accessor :dotfile_name
|
||||||
attr_reader :ssh
|
attr_reader :ssh
|
||||||
attr_reader :vm
|
attr_reader :vm
|
||||||
|
attr_reader :chef
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@ssh = SSHConfig.new
|
@ssh = SSHConfig.new
|
||||||
@vm = VMConfig.new
|
@vm = VMConfig.new
|
||||||
|
@chef = ChefConfig.new
|
||||||
end
|
end
|
||||||
end
|
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
|
def create
|
||||||
share_folder("hobo-root", Env.root_path, Hobo.config.vm.project_directory)
|
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
|
import
|
||||||
move_hd if Hobo.config[:vm][:hd_location]
|
move_hd if Hobo.config[:vm][:hd_location]
|
||||||
persist
|
persist
|
||||||
|
@ -70,6 +75,9 @@ error
|
||||||
setup_shared_folders
|
setup_shared_folders
|
||||||
start
|
start
|
||||||
mount_shared_folders
|
mount_shared_folders
|
||||||
|
|
||||||
|
# Once we're started, run the provisioning
|
||||||
|
provisioning.run
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
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
|
context "creating" do
|
||||||
should "create the VM in the proper order" do
|
should "create the VM in the proper order" do
|
||||||
|
prov = mock("prov")
|
||||||
create_seq = sequence("create_seq")
|
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(:import).in_sequence(create_seq)
|
||||||
@vm.expects(:persist).in_sequence(create_seq)
|
@vm.expects(:persist).in_sequence(create_seq)
|
||||||
@vm.expects(:setup_mac_address).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(:setup_shared_folders).in_sequence(create_seq)
|
||||||
@vm.expects(:start).in_sequence(create_seq)
|
@vm.expects(:start).in_sequence(create_seq)
|
||||||
@vm.expects(:mount_shared_folders).in_sequence(create_seq)
|
@vm.expects(:mount_shared_folders).in_sequence(create_seq)
|
||||||
|
prov.expects(:run).in_sequence(create_seq)
|
||||||
@vm.create
|
@vm.create
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -38,6 +38,9 @@ class Test::Unit::TestCase
|
||||||
config.vm.base_mac = "42"
|
config.vm.base_mac = "42"
|
||||||
config.vm.project_directory = "/hobo"
|
config.vm.project_directory = "/hobo"
|
||||||
config.vm.forward_port("ssh", 22, 2222)
|
config.vm.forward_port("ssh", 22, 2222)
|
||||||
|
|
||||||
|
config.chef.cookbooks_path = "cookbooks"
|
||||||
|
config.chef.provisioning_path = "/tmp/hobo-chef"
|
||||||
end
|
end
|
||||||
|
|
||||||
Hobo::Config.execute!
|
Hobo::Config.execute!
|
||||||
|
|
Loading…
Reference in New Issue