virtual_box 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +9 -0
- data/.document +5 -0
- data/.project +12 -0
- data/.rspec +1 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +44 -0
- data/LICENSE.txt +20 -0
- data/README.markdown +67 -0
- data/Rakefile +35 -22
- data/VERSION +1 -0
- data/lib/virtual_box/board.rb +287 -0
- data/lib/virtual_box/cli.rb +20 -0
- data/lib/virtual_box/dhcp.rb +149 -0
- data/lib/virtual_box/disk.rb +138 -0
- data/lib/virtual_box/io_bus.rb +261 -0
- data/lib/virtual_box/net.rb +144 -0
- data/lib/virtual_box/nic.rb +213 -0
- data/lib/virtual_box/version.rb +37 -24
- data/lib/virtual_box/vm.rb +289 -24
- data/lib/virtual_box.rb +14 -9
- data/test/helper.rb +24 -0
- data/test/tasks/tinycore.rake +378 -0
- data/test/virtual_box/board_test.rb +39 -0
- data/test/virtual_box/cli_test.rb +33 -0
- data/test/virtual_box/dhcp_test.rb +52 -0
- data/test/virtual_box/disk_test.rb +116 -0
- data/test/virtual_box/integration_test.rb +53 -0
- data/test/virtual_box/io_bus_test.rb +54 -0
- data/test/virtual_box/net_test.rb +80 -0
- data/test/virtual_box/nic_test.rb +50 -0
- data/test/virtual_box/version_test.rb +71 -0
- data/test/virtual_box/vm_test.rb +55 -0
- data/virtual_box.gemspec +81 -22
- metadata +208 -89
- data/CHANGELOG +0 -1
- data/LICENSE +0 -21
- data/Manifest +0 -17
- data/README.textile +0 -19
- data/lib/virtual_box/command_line.rb +0 -27
- data/lib/virtual_box/vm/general_settings.rb +0 -136
- data/lib/virtual_box/vm/identity.rb +0 -43
- data/lib/virtual_box/vm/lifecycle.rb +0 -42
- data/test/command_line_test.rb +0 -19
- data/test/general_settings_test.rb +0 -20
- data/test/lifecycle_test.rb +0 -64
- data/test/version_test.rb +0 -56
- data/testdata/golden_general_params.txt +0 -1
@@ -0,0 +1,54 @@
|
|
1
|
+
require File.expand_path('../helper.rb', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe VirtualBox::IoBus do
|
4
|
+
describe 'IDE' do
|
5
|
+
it 'should default to the PIIX4 chipset' do
|
6
|
+
VirtualBox::IoBus.new(:bus => :ide).chip.must_equal :piix4
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should recognize the PIIX4 chipset' do
|
10
|
+
VirtualBox::IoBus.new(:chip => :piix4).bus.must_equal :ide
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should be named IDE Controller by default' do
|
14
|
+
VirtualBox::IoBus.new(:bus => :ide).name.must_equal 'IDE Controller'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe 'SATA' do
|
19
|
+
it 'should default to the AHCI chipset' do
|
20
|
+
VirtualBox::IoBus.new(:bus => :sata).chip.must_equal :ahci
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should recognize the PIIX4 chipset' do
|
24
|
+
VirtualBox::IoBus.new(:chip => :ahci).bus.must_equal :sata
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should be named SATA Controller by default' do
|
28
|
+
VirtualBox::IoBus.new(:bus => :sata).name.must_equal 'SATA Controller'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe 'VM with all bunch of buses' do
|
33
|
+
before do
|
34
|
+
@vm = VirtualBox::Vm.new :io_buses => [
|
35
|
+
{ :bus => :ide, :name => 'Weird Name', :chip => :piix3 },
|
36
|
+
{ :bus => :sata },
|
37
|
+
{ :bus => :scsi, :chip => :lsi_logic },
|
38
|
+
{ :bus => :floppy },
|
39
|
+
]
|
40
|
+
@vm.register
|
41
|
+
end
|
42
|
+
|
43
|
+
after do
|
44
|
+
@vm.unregister
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should push/pull specs correctly' do
|
48
|
+
vm = VirtualBox::Vm.new :uid => @vm.uid
|
49
|
+
vm.pull_config
|
50
|
+
vm.io_buses.map { |io_bus| io_bus.to_hash }.
|
51
|
+
must_equal @vm.io_buses.map { |io_bus| io_bus.to_hash }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require File.expand_path('../helper.rb', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe VirtualBox::Net do
|
4
|
+
describe 'with no arguments' do
|
5
|
+
before { @net = VirtualBox::Net.new }
|
6
|
+
|
7
|
+
it 'is not live' do
|
8
|
+
@net.wont_be :live?
|
9
|
+
end
|
10
|
+
|
11
|
+
describe 'after adding to VirtualBox' do
|
12
|
+
before { @net.add }
|
13
|
+
after { @net.remove }
|
14
|
+
|
15
|
+
it 'is live' do
|
16
|
+
@net.must_be :live?
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'has an IP' do
|
20
|
+
@net.ip.wont_be_nil
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'has a netmask' do
|
24
|
+
@net.netmask.wont_be_nil
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'has an interface name that shows up in the ifconfig output' do
|
28
|
+
@net.if_name.wont_be_nil
|
29
|
+
`ifconfig`.must_include @net.if_name
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'has a name' do
|
33
|
+
@net.name.wont_be_nil
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'has a MAC address' do
|
37
|
+
@net.mac.wont_be_nil
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe 'with a set ip and netmask' do
|
43
|
+
before do
|
44
|
+
@net = VirtualBox::Net.new :ip => '192.168.166.66',
|
45
|
+
:netmask => '255.255.252.0'
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'is not live' do
|
49
|
+
@net.wont_be :live?
|
50
|
+
end
|
51
|
+
|
52
|
+
describe 'after adding to VirtualBox' do
|
53
|
+
before { @net.add }
|
54
|
+
after { @net.remove }
|
55
|
+
|
56
|
+
it 'is live' do
|
57
|
+
@net.must_be :live?
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'has the same IP' do
|
61
|
+
@net.ip.must_equal '192.168.166.66'
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'has the same netmask' do
|
65
|
+
@net.netmask.must_equal '255.255.252.0'
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'has an interface name that shows up in the ifconfig output' do
|
69
|
+
@net.if_name.wont_be_nil
|
70
|
+
`ifconfig`.must_include @net.if_name
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'shows up on the list of live networks' do
|
74
|
+
networks = VirtualBox::Net.all
|
75
|
+
network = networks.find { |n| n.if_name == @net.if_name }
|
76
|
+
network.to_hash.must_equal @net.to_hash
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require File.expand_path('../helper.rb', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe VirtualBox::Nic do
|
4
|
+
describe 'host_nics' do
|
5
|
+
let(:nics) { VirtualBox::Nic.host_nics }
|
6
|
+
|
7
|
+
it 'should have at least 1 card' do
|
8
|
+
nics.length.must_be :>=, 1
|
9
|
+
end
|
10
|
+
|
11
|
+
describe 'first card' do
|
12
|
+
let(:card) { nics.first }
|
13
|
+
|
14
|
+
it 'should have an interface ID' do
|
15
|
+
card[:id].wont_be_nil
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should have a MAC' do
|
19
|
+
card[:mac].wont_be_nil
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe 'NAT card and virtual card' do
|
25
|
+
before do
|
26
|
+
@vm = VirtualBox::Vm.new :nics => [
|
27
|
+
{ :mode => :bridged, :chip => :amd,
|
28
|
+
:net_name => VirtualBox::Nic.host_nics.first[:id],
|
29
|
+
:mac => 'aabbccddeeff' },
|
30
|
+
{ :port => 2, :mode => :virtual, :chip => :virtual,
|
31
|
+
:net_name => 'rbx00' }
|
32
|
+
]
|
33
|
+
@vm.register
|
34
|
+
end
|
35
|
+
|
36
|
+
after do
|
37
|
+
@vm.unregister
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should skip NIC 1' do
|
41
|
+
@vm.nics[1].must_be_nil
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should push/pull specs correctly' do
|
45
|
+
vm = VirtualBox::Vm.new :uid => @vm.uid
|
46
|
+
vm.pull_config
|
47
|
+
vm.to_hash[:nics].must_equal @vm.to_hash[:nics]
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require File.expand_path('../helper.rb', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe 'Version' do
|
4
|
+
describe 'on 3.0.4 personal edition' do
|
5
|
+
before do
|
6
|
+
VirtualBox.reset_version_info!
|
7
|
+
VirtualBox.expects(:run_command).once.
|
8
|
+
returns(Hashie::Mash.new(:status => 0, :output => "3.0.4r50677\n"))
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should report release' do
|
12
|
+
VirtualBox.version.release.must_equal '3.0.4'
|
13
|
+
end
|
14
|
+
it 'should report revision' do
|
15
|
+
VirtualBox.version.svn.must_equal 50677
|
16
|
+
end
|
17
|
+
it 'should report personal edition' do
|
18
|
+
VirtualBox.ose?.must_equal false
|
19
|
+
end
|
20
|
+
it 'should cache version info' do
|
21
|
+
VirtualBox.version.release.must_equal '3.0.4'
|
22
|
+
VirtualBox.version.svn.must_equal 50677
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe 'on 3.2.8 open-source edition' do
|
27
|
+
before do
|
28
|
+
VirtualBox.reset_version_info!
|
29
|
+
VirtualBox.expects(:run_command).once.
|
30
|
+
returns(Hashie::Mash.new(:status => 0, :output => "3.2.8_OSEr64453\n"))
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should report release' do
|
34
|
+
VirtualBox.version.release.must_equal '3.2.8'
|
35
|
+
end
|
36
|
+
it 'should report revision' do
|
37
|
+
VirtualBox.version.svn.must_equal 64453
|
38
|
+
end
|
39
|
+
it 'should report open-source edition' do
|
40
|
+
VirtualBox.ose?.must_equal true
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe 'on machine without VirtualBox' do
|
45
|
+
before do
|
46
|
+
VirtualBox.reset_version_info!
|
47
|
+
VirtualBox.expects(:run_command).once.
|
48
|
+
returns(Hashie::Mash.new(:status => 127))
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should not report a release' do
|
52
|
+
VirtualBox.version.release.must_equal nil
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should raise an exception on ose' do
|
56
|
+
lambda {
|
57
|
+
VirtualBox.ose?
|
58
|
+
}.must_raise(RuntimeError)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe 'live' do
|
63
|
+
before do
|
64
|
+
VirtualBox.reset_version_info!
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'should report some version' do
|
68
|
+
VirtualBox.version.release.wont_be :empty?
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require File.expand_path('../helper.rb', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe VirtualBox::Vm do
|
4
|
+
describe 'anonymous' do
|
5
|
+
before do
|
6
|
+
@vm = VirtualBox::Vm.new
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should receive a name' do
|
10
|
+
@vm.name.wont_be_nil
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should receive an UID' do
|
14
|
+
@vm.uid.wont_be_nil
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should be unregistered' do
|
18
|
+
@vm.wont_be :registered?
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'registered' do
|
22
|
+
before do
|
23
|
+
@vm.register
|
24
|
+
end
|
25
|
+
|
26
|
+
after do
|
27
|
+
@vm.unregister
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should know it is registered' do
|
31
|
+
@vm.must_be :registered?
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should show up on the list of registered VM UIDs' do
|
35
|
+
uids = VirtualBox::Vm.registered_uids
|
36
|
+
uids.must_include @vm.uid
|
37
|
+
end
|
38
|
+
|
39
|
+
describe 'started' do
|
40
|
+
before do
|
41
|
+
@vm.start
|
42
|
+
end
|
43
|
+
after do
|
44
|
+
@vm.stop
|
45
|
+
sleep 0.5 # VirtualBox will barf if we unregister the VM right away.
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should show up on the list of started VM UIDs' do
|
49
|
+
uids = VirtualBox::Vm.started_uids
|
50
|
+
uids.must_include @vm.uid
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/virtual_box.gemspec
CHANGED
@@ -1,37 +1,96 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
1
4
|
# -*- encoding: utf-8 -*-
|
2
5
|
|
3
6
|
Gem::Specification.new do |s|
|
4
|
-
s.name =
|
5
|
-
s.version = "0.0
|
7
|
+
s.name = "virtual_box"
|
8
|
+
s.version = "0.1.0"
|
6
9
|
|
7
|
-
s.required_rubygems_version = Gem::Requirement.new(">=
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
11
|
s.authors = ["Victor Costan"]
|
9
|
-
s.date =
|
10
|
-
s.description =
|
11
|
-
s.email =
|
12
|
-
s.extra_rdoc_files = [
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
s.date = "2012-05-01"
|
13
|
+
s.description = "Drives the VirtualBox command-line to manage VMs"
|
14
|
+
s.email = "victor@costan.us"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.markdown"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".autotest",
|
21
|
+
".document",
|
22
|
+
".project",
|
23
|
+
".rspec",
|
24
|
+
"Gemfile",
|
25
|
+
"Gemfile.lock",
|
26
|
+
"LICENSE.txt",
|
27
|
+
"README.markdown",
|
28
|
+
"Rakefile",
|
29
|
+
"VERSION",
|
30
|
+
"lib/virtual_box.rb",
|
31
|
+
"lib/virtual_box/board.rb",
|
32
|
+
"lib/virtual_box/cli.rb",
|
33
|
+
"lib/virtual_box/dhcp.rb",
|
34
|
+
"lib/virtual_box/disk.rb",
|
35
|
+
"lib/virtual_box/io_bus.rb",
|
36
|
+
"lib/virtual_box/net.rb",
|
37
|
+
"lib/virtual_box/nic.rb",
|
38
|
+
"lib/virtual_box/version.rb",
|
39
|
+
"lib/virtual_box/vm.rb",
|
40
|
+
"test/helper.rb",
|
41
|
+
"test/tasks/tinycore.rake",
|
42
|
+
"test/virtual_box/board_test.rb",
|
43
|
+
"test/virtual_box/cli_test.rb",
|
44
|
+
"test/virtual_box/dhcp_test.rb",
|
45
|
+
"test/virtual_box/disk_test.rb",
|
46
|
+
"test/virtual_box/integration_test.rb",
|
47
|
+
"test/virtual_box/io_bus_test.rb",
|
48
|
+
"test/virtual_box/net_test.rb",
|
49
|
+
"test/virtual_box/nic_test.rb",
|
50
|
+
"test/virtual_box/version_test.rb",
|
51
|
+
"test/virtual_box/vm_test.rb",
|
52
|
+
"virtual_box.gemspec"
|
53
|
+
]
|
54
|
+
s.homepage = "http://github.com/csail/police"
|
55
|
+
s.licenses = ["MIT"]
|
16
56
|
s.require_paths = ["lib"]
|
17
|
-
s.
|
18
|
-
s.
|
19
|
-
s.summary = %q{Ruby API for VirtualBox (Sun's OSS virtualization software).}
|
20
|
-
s.test_files = ["test/command_line_test.rb", "test/general_settings_test.rb", "test/lifecycle_test.rb", "test/version_test.rb"]
|
57
|
+
s.rubygems_version = "1.8.23"
|
58
|
+
s.summary = "VirtualBox driver"
|
21
59
|
|
22
60
|
if s.respond_to? :specification_version then
|
23
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
24
61
|
s.specification_version = 3
|
25
62
|
|
26
|
-
if Gem::Version.new(Gem::
|
27
|
-
s.
|
28
|
-
s.
|
63
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
64
|
+
s.add_runtime_dependency(%q<hashie>, [">= 0.4.0"])
|
65
|
+
s.add_runtime_dependency(%q<uuid>, [">= 2.3.5"])
|
66
|
+
s.add_development_dependency(%q<bundler>, [">= 1.1.3"])
|
67
|
+
s.add_development_dependency(%q<jeweler>, [">= 1.8.3"])
|
68
|
+
s.add_development_dependency(%q<minitest>, [">= 2.12.1"])
|
69
|
+
s.add_development_dependency(%q<mocha>, [">= 0.11.0"])
|
70
|
+
s.add_development_dependency(%q<net-ssh>, [">= 2.3.0"])
|
71
|
+
s.add_development_dependency(%q<simplecov>, [">= 0.6.1"])
|
72
|
+
s.add_development_dependency(%q<yard>, [">= 0.7.5"])
|
29
73
|
else
|
30
|
-
s.add_dependency(%q<
|
31
|
-
s.add_dependency(%q<
|
74
|
+
s.add_dependency(%q<hashie>, [">= 0.4.0"])
|
75
|
+
s.add_dependency(%q<uuid>, [">= 2.3.5"])
|
76
|
+
s.add_dependency(%q<bundler>, [">= 1.1.3"])
|
77
|
+
s.add_dependency(%q<jeweler>, [">= 1.8.3"])
|
78
|
+
s.add_dependency(%q<minitest>, [">= 2.12.1"])
|
79
|
+
s.add_dependency(%q<mocha>, [">= 0.11.0"])
|
80
|
+
s.add_dependency(%q<net-ssh>, [">= 2.3.0"])
|
81
|
+
s.add_dependency(%q<simplecov>, [">= 0.6.1"])
|
82
|
+
s.add_dependency(%q<yard>, [">= 0.7.5"])
|
32
83
|
end
|
33
84
|
else
|
34
|
-
s.add_dependency(%q<
|
35
|
-
s.add_dependency(%q<
|
85
|
+
s.add_dependency(%q<hashie>, [">= 0.4.0"])
|
86
|
+
s.add_dependency(%q<uuid>, [">= 2.3.5"])
|
87
|
+
s.add_dependency(%q<bundler>, [">= 1.1.3"])
|
88
|
+
s.add_dependency(%q<jeweler>, [">= 1.8.3"])
|
89
|
+
s.add_dependency(%q<minitest>, [">= 2.12.1"])
|
90
|
+
s.add_dependency(%q<mocha>, [">= 0.11.0"])
|
91
|
+
s.add_dependency(%q<net-ssh>, [">= 2.3.0"])
|
92
|
+
s.add_dependency(%q<simplecov>, [">= 0.6.1"])
|
93
|
+
s.add_dependency(%q<yard>, [">= 0.7.5"])
|
36
94
|
end
|
37
95
|
end
|
96
|
+
|