vbox-ng 0.1.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -2
- data/Gemfile.lock +7 -1
- data/README.md +7 -8
- data/Rakefile +15 -5
- data/VERSION +1 -1
- data/lib/vbox-ng.rb +14 -2
- data/lib/vbox.rb +14 -2
- data/lib/vbox/cli.rb +208 -75
- data/lib/vbox/cmdlineapi.rb +136 -90
- data/lib/vbox/vm.rb +111 -11
- data/spec/cmdlineapi_spec.rb +52 -0
- data/spec/spec_helper.rb +46 -1
- data/spec/support/vboxmanage_simulator.rb +136 -0
- data/spec/support/vboxmanage_simulator.yml +1171 -0
- data/spec/vm_spec.rb +101 -5
- data/vbox-ng.gemspec +11 -5
- metadata +24 -5
data/spec/vm_spec.rb
CHANGED
@@ -1,6 +1,26 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
|
+
TEST_VM_NAME = "vbox-ng-test-vm"
|
4
|
+
TEST_VM_UUID = 'ae340307-f472-4d63-80e7-855fca6808cb'
|
5
|
+
|
6
|
+
TEST_VM_NAME2 = "vbox-ng-test-vm2"
|
7
|
+
TEST_VM_UUID2 = 'ae340307-f472-4d63-80e7-855fca6808cc'
|
8
|
+
|
9
|
+
# tests with VBoxManage invocation
|
3
10
|
describe "VBOX::VM" do
|
11
|
+
before :all do
|
12
|
+
vm = VBOX::VM.find TEST_VM_NAME
|
13
|
+
vm.destroy!.should(be_true) if vm
|
14
|
+
|
15
|
+
vm = VBOX::VM.create! :name => TEST_VM_NAME, :uuid => TEST_VM_UUID
|
16
|
+
vm.should be_instance_of(VBOX::VM)
|
17
|
+
end
|
18
|
+
|
19
|
+
after :all do
|
20
|
+
vm = VBOX::VM.find TEST_VM_NAME
|
21
|
+
vm.destroy!.should(be_true) if vm
|
22
|
+
end
|
23
|
+
|
4
24
|
describe "all()" do
|
5
25
|
it "returns array" do
|
6
26
|
VBOX::VM.all.should be_instance_of(Array)
|
@@ -17,9 +37,6 @@ describe "VBOX::VM" do
|
|
17
37
|
end
|
18
38
|
end
|
19
39
|
|
20
|
-
TEST_VM_NAME = "d0"
|
21
|
-
TEST_VM_UUID = 'ae340207-f472-4d63-80e7-855fca6808cb'
|
22
|
-
|
23
40
|
[:find, :[]].each do |method|
|
24
41
|
describe method do
|
25
42
|
it "finds VM by name" do
|
@@ -38,14 +55,16 @@ describe "VBOX::VM" do
|
|
38
55
|
end
|
39
56
|
|
40
57
|
it "finds nothing" do
|
41
|
-
vm = VBOX::VM.send(method, "blah-blah-blah-unexistant-vm
|
58
|
+
vm = VBOX::VM.send(method, "blah-blah-blah-unexistant-vm-139487098347510")
|
42
59
|
vm.should be_nil
|
43
60
|
end
|
44
61
|
end
|
45
62
|
end
|
46
63
|
|
47
64
|
describe :dir_size do
|
48
|
-
|
65
|
+
it "should be > 0" do
|
66
|
+
VBOX::VM.first.dir_size.should > 0
|
67
|
+
end
|
49
68
|
end
|
50
69
|
|
51
70
|
%w'start pause resume reset poweroff savestate acpipowerbutton acpisleepbutton destroy clone'.each do |action|
|
@@ -56,4 +75,81 @@ describe "VBOX::VM" do
|
|
56
75
|
end
|
57
76
|
end
|
58
77
|
end
|
78
|
+
|
79
|
+
describe :create do
|
80
|
+
before(:all) do
|
81
|
+
vm = VBOX::VM.find TEST_VM_NAME2
|
82
|
+
vm.destroy!.should(be_true) if vm
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should create VM" do
|
86
|
+
vm = VBOX::VM.new :name => TEST_VM_NAME2
|
87
|
+
Array(vm.metadata).should be_empty
|
88
|
+
vm = vm.create!
|
89
|
+
vm.should be_instance_of(VBOX::VM)
|
90
|
+
vm.metadata.size.should > 10
|
91
|
+
vm.reload_metadata
|
92
|
+
vm.name.should == TEST_VM_NAME2
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe :set_var do
|
97
|
+
it "should set vars" do
|
98
|
+
vm = VBOX::VM.find TEST_VM_NAME
|
99
|
+
h = { 'acpi' => 'on', 'cpus' => 4, 'memory' => 1024, 'vram' => 16 }
|
100
|
+
h.each{ |k,v| vm.set_var k,v }
|
101
|
+
vm.save
|
102
|
+
vm.reload_metadata
|
103
|
+
h.each{ |k,v| vm.metadata[k].to_s.should == v.to_s }
|
104
|
+
|
105
|
+
h = { 'acpi' => 'off', 'cpus' => 2, 'memory' => 512, 'vram' => 8 }
|
106
|
+
h.each{ |k,v| vm.set_var k,v }
|
107
|
+
vm.save
|
108
|
+
vm.reload_metadata
|
109
|
+
h.each{ |k,v| vm.metadata[k].to_s.should == v.to_s }
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
describe :set_vars do
|
114
|
+
it "should set vars" do
|
115
|
+
vm = VBOX::VM.find TEST_VM_NAME
|
116
|
+
h = { 'acpi' => 'on', 'cpus' => 4, 'memory' => 1024, 'vram' => 16 }
|
117
|
+
vm.set_vars h
|
118
|
+
vm.save
|
119
|
+
vm.reload_metadata
|
120
|
+
h.each{ |k,v| vm.metadata[k].to_s.should == v.to_s }
|
121
|
+
|
122
|
+
h = { 'acpi' => 'off', 'cpus' => 2, 'memory' => 512, 'vram' => 8 }
|
123
|
+
vm.set_vars h
|
124
|
+
vm.save
|
125
|
+
vm.reload_metadata
|
126
|
+
h.each{ |k,v| vm.metadata[k].to_s.should == v.to_s }
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
# tests w/o VBoxManage invocation
|
132
|
+
describe "VBOX::VM" do
|
133
|
+
|
134
|
+
describe :expand_glob do
|
135
|
+
def _glob2arr glob
|
136
|
+
r = []
|
137
|
+
VBOX::VM.expand_glob(glob){ |x| r << x }
|
138
|
+
r
|
139
|
+
end
|
140
|
+
|
141
|
+
{
|
142
|
+
'xxx' => ['xxx'],
|
143
|
+
'xx*' => ['xx*'],
|
144
|
+
'a{1-2}' => ['a1', 'a2'],
|
145
|
+
'{0-11}b' => (0..11).map{ |x| "#{x}b" },
|
146
|
+
'a{0-999}b' => (0..999).map{ |x| "a#{x}b" },
|
147
|
+
'{1-10}.{1-10}.{1-10}' => (0..999).map{ |x| ("%03i" % x).split('').join('.').gsub('0','10') }
|
148
|
+
}.each do |k,v|
|
149
|
+
it "should expand #{k.inspect}" do
|
150
|
+
_glob2arr(k).sort.should == v.sort
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
59
155
|
end
|
data/vbox-ng.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "vbox-ng"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "1.0.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Andrey \"Zed\" Zaikin"]
|
12
|
-
s.date = "2012-12-
|
12
|
+
s.date = "2012-12-08"
|
13
13
|
s.description = "Create/start/stop/reboot/modify dozens of VirtualBox VMS with one short command."
|
14
14
|
s.email = "zed.0xff@gmail.com"
|
15
15
|
s.executables = ["vbox"]
|
@@ -33,7 +33,10 @@ Gem::Specification.new do |s|
|
|
33
33
|
"lib/vbox/cli.rb",
|
34
34
|
"lib/vbox/cmdlineapi.rb",
|
35
35
|
"lib/vbox/vm.rb",
|
36
|
+
"spec/cmdlineapi_spec.rb",
|
36
37
|
"spec/spec_helper.rb",
|
38
|
+
"spec/support/vboxmanage_simulator.rb",
|
39
|
+
"spec/support/vboxmanage_simulator.yml",
|
37
40
|
"spec/vm_spec.rb",
|
38
41
|
"vbox-ng.gemspec"
|
39
42
|
]
|
@@ -49,19 +52,22 @@ Gem::Specification.new do |s|
|
|
49
52
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
50
53
|
s.add_runtime_dependency(%q<awesome_print>, ["~> 1.1.0"])
|
51
54
|
s.add_development_dependency(%q<rspec>, ["~> 2.12.0"])
|
52
|
-
s.add_development_dependency(%q<bundler>, ["
|
55
|
+
s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
|
53
56
|
s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
|
57
|
+
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
54
58
|
else
|
55
59
|
s.add_dependency(%q<awesome_print>, ["~> 1.1.0"])
|
56
60
|
s.add_dependency(%q<rspec>, ["~> 2.12.0"])
|
57
|
-
s.add_dependency(%q<bundler>, ["
|
61
|
+
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
58
62
|
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
63
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
59
64
|
end
|
60
65
|
else
|
61
66
|
s.add_dependency(%q<awesome_print>, ["~> 1.1.0"])
|
62
67
|
s.add_dependency(%q<rspec>, ["~> 2.12.0"])
|
63
|
-
s.add_dependency(%q<bundler>, ["
|
68
|
+
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
64
69
|
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
70
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
65
71
|
end
|
66
72
|
end
|
67
73
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vbox-ng
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: awesome_print
|
@@ -48,7 +48,7 @@ dependencies:
|
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
49
49
|
none: false
|
50
50
|
requirements:
|
51
|
-
- -
|
51
|
+
- - ! '>='
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: 1.0.0
|
54
54
|
type: :development
|
@@ -56,7 +56,7 @@ dependencies:
|
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
none: false
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 1.0.0
|
62
62
|
- !ruby/object:Gem::Dependency
|
@@ -75,6 +75,22 @@ dependencies:
|
|
75
75
|
- - ~>
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: 1.8.4
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: simplecov
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
78
94
|
description: Create/start/stop/reboot/modify dozens of VirtualBox VMS with one short
|
79
95
|
command.
|
80
96
|
email: zed.0xff@gmail.com
|
@@ -100,7 +116,10 @@ files:
|
|
100
116
|
- lib/vbox/cli.rb
|
101
117
|
- lib/vbox/cmdlineapi.rb
|
102
118
|
- lib/vbox/vm.rb
|
119
|
+
- spec/cmdlineapi_spec.rb
|
103
120
|
- spec/spec_helper.rb
|
121
|
+
- spec/support/vboxmanage_simulator.rb
|
122
|
+
- spec/support/vboxmanage_simulator.yml
|
104
123
|
- spec/vm_spec.rb
|
105
124
|
- vbox-ng.gemspec
|
106
125
|
homepage: http://github.com/zed-0xff/vbox-ng
|
@@ -118,7 +137,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
118
137
|
version: '0'
|
119
138
|
segments:
|
120
139
|
- 0
|
121
|
-
hash: -
|
140
|
+
hash: -2700200473455994359
|
122
141
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
142
|
none: false
|
124
143
|
requirements:
|