From 7fd4ee0160ca76268ff5e340ad5da1537d430362 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 6 Feb 2010 00:01:47 -0800 Subject: [PATCH] Shared folder is now properly mounted on hobo-up --- config/default.rb | 1 + lib/hobo/config.rb | 1 + lib/hobo/vm.rb | 9 +++++++++ test/hobo/vm_test.rb | 12 ++++++++++++ test/test_helper.rb | 1 + 5 files changed, 24 insertions(+) diff --git a/config/default.rb b/config/default.rb index 3d4c6a2d4..5aebe5891 100644 --- a/config/default.rb +++ b/config/default.rb @@ -10,5 +10,6 @@ Hobo::Config.run do |config| config.vm.base = "~/.hobo/base/base.ovf" config.vm.base_mac = "0800279C2E41" + config.vm.project_directory = "/hobo" config.vm.forward_port("ssh", 22, 2222) end \ No newline at end of file diff --git a/lib/hobo/config.rb b/lib/hobo/config.rb index 55760fab8..db94a290f 100644 --- a/lib/hobo/config.rb +++ b/lib/hobo/config.rb @@ -46,6 +46,7 @@ module Hobo class VMConfig < Base attr_accessor :base attr_accessor :base_mac + attr_accessor :project_directory attr_reader :forwarded_ports def initialize diff --git a/lib/hobo/vm.rb b/lib/hobo/vm.rb index 35c52d9b3..40129eb0a 100644 --- a/lib/hobo/vm.rb +++ b/lib/hobo/vm.rb @@ -64,6 +64,7 @@ error forward_ports setup_shared_folder start + mount_shared_folder end def destroy @@ -116,6 +117,14 @@ error @vm.save(true) end + def mount_shared_folder + HOBO_LOGGER.info "Mounting shared folders..." + Hobo::SSH.execute do |ssh| + ssh.exec!("sudo mkdir -p #{Hobo.config.vm.project_directory}") + ssh.exec!("sudo mount -t vboxsf hobo-root-path #{Hobo.config.vm.project_directory}") + end + end + def start HOBO_LOGGER.info "Booting VM..." @vm.start(:headless, true) diff --git a/test/hobo/vm_test.rb b/test/hobo/vm_test.rb index 2955eb7bd..84e25a298 100644 --- a/test/hobo/vm_test.rb +++ b/test/hobo/vm_test.rb @@ -80,6 +80,7 @@ class VMTest < Test::Unit::TestCase @vm.expects(:forward_ports).in_sequence(create_seq) @vm.expects(:setup_shared_folder).in_sequence(create_seq) @vm.expects(:start).in_sequence(create_seq) + @vm.expects(:mount_shared_folder).in_sequence(create_seq) @vm.create end end @@ -183,6 +184,17 @@ class VMTest < Test::Unit::TestCase end end + context "mounting the shared folders" do + should "create the directory then mount the shared folder" do + mount_seq = sequence("mount_seq") + ssh = mock("ssh") + ssh.expects(:exec!).with("sudo mkdir -p #{Hobo.config.vm.project_directory}").in_sequence(mount_seq) + ssh.expects(:exec!).with("sudo mount -t vboxsf hobo-root-path #{Hobo.config.vm.project_directory}").in_sequence(mount_seq) + Hobo::SSH.expects(:execute).yields(ssh) + @vm.mount_shared_folder + end + end + context "suspending and resuming a vm" do should "put the vm in a suspended state" do saved_state_expectation(false) diff --git a/test/test_helper.rb b/test/test_helper.rb index 1874d8da1..1088b6b71 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -36,6 +36,7 @@ class Test::Unit::TestCase config.vm.base = "foo" config.vm.base_mac = "42" + config.vm.project_directory = "/hobo" config.vm.forward_port("ssh", 22, 2222) end