hobo-up persists the UUID of the VM
This commit is contained in:
parent
e948ce9663
commit
3631ff0078
|
@ -1,4 +1,5 @@
|
||||||
gembin/*
|
gembin/*
|
||||||
vendor/gems/*
|
vendor/gems/*
|
||||||
pkg/*
|
pkg/*
|
||||||
Hobofile
|
Hobofile
|
||||||
|
.hobo
|
|
@ -10,23 +10,23 @@ module Hobo
|
||||||
forward_ssh(vm)
|
forward_ssh(vm)
|
||||||
setup_shared_folder(vm)
|
setup_shared_folder(vm)
|
||||||
end
|
end
|
||||||
|
|
||||||
def import
|
def import
|
||||||
HOBO_LOGGER.info "Importing base VM (#{Hobo.config[:vm][:base]})..."
|
HOBO_LOGGER.info "Importing base VM (#{Hobo.config[:vm][:base]})..."
|
||||||
VirtualBox::VM.import(File.expand_path(Hobo.config[:vm][:base]))
|
VirtualBox::VM.import(File.expand_path(Hobo.config[:vm][:base]))
|
||||||
end
|
end
|
||||||
|
|
||||||
def persist_uuid(vm)
|
def persist_uuid(vm)
|
||||||
HOBO_LOGGER.info "Persisting the VM UUID (#{vm.uuid})..."
|
HOBO_LOGGER.info "Persisting the VM UUID (#{vm.uuid})..."
|
||||||
# TODO: persist it! dot file in the root (where Hobofile is)
|
Env.persist_uuid(vm.uuid)
|
||||||
end
|
end
|
||||||
|
|
||||||
def setup_mac_address(vm)
|
def setup_mac_address(vm)
|
||||||
HOBO_LOGGER.info "Matching MAC addresses..."
|
HOBO_LOGGER.info "Matching MAC addresses..."
|
||||||
vm.nics.first.macaddress = Hobo.config[:vm][:base_mac]
|
vm.nics.first.macaddress = Hobo.config[:vm][:base_mac]
|
||||||
vm.save(true)
|
vm.save(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
def forward_ssh(vm)
|
def forward_ssh(vm)
|
||||||
HOBO_LOGGER.info "Forwarding SSH ports..."
|
HOBO_LOGGER.info "Forwarding SSH ports..."
|
||||||
port = VirtualBox::ForwardedPort.new
|
port = VirtualBox::ForwardedPort.new
|
||||||
|
@ -36,7 +36,7 @@ module Hobo
|
||||||
vm.forwarded_ports << port
|
vm.forwarded_ports << port
|
||||||
vm.save(true)
|
vm.save(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: We need to get the host path.
|
# TODO: We need to get the host path.
|
||||||
def setup_shared_folder(vm)
|
def setup_shared_folder(vm)
|
||||||
HOBO_LOGGER.info "Creating shared folders..."
|
HOBO_LOGGER.info "Creating shared folders..."
|
||||||
|
|
|
@ -5,7 +5,7 @@ class VMTest < Test::Unit::TestCase
|
||||||
@vm = mock("vm")
|
@vm = mock("vm")
|
||||||
Hobo.config!(hobo_mock_config)
|
Hobo.config!(hobo_mock_config)
|
||||||
end
|
end
|
||||||
|
|
||||||
context "hobo up" do
|
context "hobo up" do
|
||||||
should "create the instance in the proper order" do
|
should "create the instance in the proper order" do
|
||||||
create_seq = sequence("create_seq")
|
create_seq = sequence("create_seq")
|
||||||
|
@ -17,35 +17,39 @@ class VMTest < Test::Unit::TestCase
|
||||||
Hobo::VM.up
|
Hobo::VM.up
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "importing" do
|
context "importing" do
|
||||||
should "call import on VirtualBox::VM with the proper base" do
|
should "call import on VirtualBox::VM with the proper base" do
|
||||||
VirtualBox::VM.expects(:import).once
|
VirtualBox::VM.expects(:import).once
|
||||||
Hobo::VM.import
|
Hobo::VM.import
|
||||||
end
|
end
|
||||||
|
|
||||||
should "return the VM object" do
|
should "return the VM object" do
|
||||||
VirtualBox::VM.expects(:import).returns(@vm).once
|
VirtualBox::VM.expects(:import).returns(@vm).once
|
||||||
assert_equal @vm, Hobo::VM.import
|
assert_equal @vm, Hobo::VM.import
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "persisting UUID" do
|
context "persisting UUID" do
|
||||||
# TODO, functionality doesn't exist yet
|
should "persist the UUID with Env" do
|
||||||
|
@vm.stubs(:uuid).returns("FOO")
|
||||||
|
Hobo::Env.expects(:persist_uuid).with(@vm.uuid).once
|
||||||
|
Hobo::VM.persist_uuid(@vm)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "setting up MAC address" do
|
context "setting up MAC address" do
|
||||||
should "match the mac address with the base" do
|
should "match the mac address with the base" do
|
||||||
nic = mock("nic")
|
nic = mock("nic")
|
||||||
nic.expects(:macaddress=).once
|
nic.expects(:macaddress=).once
|
||||||
|
|
||||||
@vm.expects(:nics).returns([nic]).once
|
@vm.expects(:nics).returns([nic]).once
|
||||||
@vm.expects(:save).with(true).once
|
@vm.expects(:save).with(true).once
|
||||||
|
|
||||||
Hobo::VM.setup_mac_address(@vm)
|
Hobo::VM.setup_mac_address(@vm)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "forwarding SSH" do
|
context "forwarding SSH" do
|
||||||
should "create a port forwarding for the VM" do
|
should "create a port forwarding for the VM" do
|
||||||
# TODO: Test the actual port value to make sure it has the
|
# TODO: Test the actual port value to make sure it has the
|
||||||
|
@ -57,7 +61,7 @@ class VMTest < Test::Unit::TestCase
|
||||||
Hobo::VM.forward_ssh(@vm)
|
Hobo::VM.forward_ssh(@vm)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "setting up the shared folder" do
|
context "setting up the shared folder" do
|
||||||
# TODO: Since the code actually doesn't do anything yet
|
# TODO: Since the code actually doesn't do anything yet
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue