vagrant-kvm 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +2 -0
  3. data/.rspec +1 -0
  4. data/.travis.yml +14 -0
  5. data/CHANGELOG.md +29 -0
  6. data/DEVELOPMENT.md +87 -0
  7. data/Gemfile +1 -0
  8. data/INSTALL.md +229 -0
  9. data/LICENSE +2 -1
  10. data/README.md +154 -63
  11. data/Rakefile +24 -1
  12. data/example_box/README.md +8 -8
  13. data/lib/vagrant-kvm/action.rb +47 -5
  14. data/lib/vagrant-kvm/action/boot.rb +0 -4
  15. data/lib/vagrant-kvm/action/clear_forwarded_ports.rb +53 -0
  16. data/lib/vagrant-kvm/action/forward_ports.rb +104 -0
  17. data/lib/vagrant-kvm/action/import.rb +97 -18
  18. data/lib/vagrant-kvm/action/init_storage_pool.rb +3 -1
  19. data/lib/vagrant-kvm/action/message_not_running.rb +16 -0
  20. data/lib/vagrant-kvm/action/network.rb +12 -13
  21. data/lib/vagrant-kvm/action/package_vagrantfile.rb +3 -1
  22. data/lib/vagrant-kvm/action/prepare_gui.rb +20 -0
  23. data/lib/vagrant-kvm/action/prepare_nfs_settings.rb +8 -16
  24. data/lib/vagrant-kvm/action/prepare_nfs_valid_ids.rb +17 -0
  25. data/lib/vagrant-kvm/action/reset_image_permission.rb +23 -0
  26. data/lib/vagrant-kvm/action/resume_network.rb +28 -0
  27. data/lib/vagrant-kvm/action/share_folders.rb +6 -5
  28. data/lib/vagrant-kvm/action/suspend.rb +8 -1
  29. data/lib/vagrant-kvm/config.rb +103 -2
  30. data/lib/vagrant-kvm/driver/driver.rb +321 -99
  31. data/lib/vagrant-kvm/errors.rb +18 -0
  32. data/lib/vagrant-kvm/provider.rb +4 -1
  33. data/lib/vagrant-kvm/util.rb +3 -0
  34. data/lib/vagrant-kvm/util/commands.rb +23 -0
  35. data/lib/vagrant-kvm/util/definition_attributes.rb +33 -0
  36. data/lib/vagrant-kvm/util/disk_info.rb +48 -0
  37. data/lib/vagrant-kvm/util/network_definition.rb +44 -84
  38. data/lib/vagrant-kvm/util/vm_definition.rb +91 -103
  39. data/lib/vagrant-kvm/version.rb +1 -1
  40. data/locales/en.yml +8 -0
  41. data/locales/ja.yml +14 -0
  42. data/spec/acceptance/vagrant-kvm_spec.rb +80 -0
  43. data/spec/fedora/10.virt.rules +10 -0
  44. data/spec/fedora/50-vagrant-libvirt-access.pkla +6 -0
  45. data/spec/spec_helper.rb +30 -0
  46. data/spec/support/libvirt_helper.rb +37 -0
  47. data/spec/support/vagrant_kvm_helper.rb +39 -0
  48. data/spec/test_files/box.xml +74 -0
  49. data/spec/vagrant-kvm/config_spec.rb +56 -0
  50. data/spec/vagrant-kvm/driver/driver_spec.rb +36 -0
  51. data/spec/vagrant-kvm/errors_spec.rb +25 -0
  52. data/spec/vagrant-kvm/util/network_definition_spec.rb +60 -0
  53. data/spec/vagrant-kvm/util/vm_definition_spec.rb +76 -0
  54. data/templates/libvirt_domain.erb +34 -12
  55. data/templates/libvirt_network.erb +13 -0
  56. data/templates/package_Vagrantfile.erb +11 -0
  57. data/vagrant-kvm.gemspec +1 -2
  58. metadata +41 -42
@@ -0,0 +1,76 @@
1
+ require 'spec_helper'
2
+
3
+ describe VagrantPlugins::ProviderKvm::Util::VmDefinition do
4
+ let(:definition) { described_class.new(File.read(path)) }
5
+ subject { definition }
6
+
7
+ context "with an simple definition" do
8
+ let(:path) { test_file("box.xml") }
9
+
10
+ describe "#as_xml" do
11
+ subject { definition.as_xml }
12
+
13
+ it "sets the CPU count properly" do
14
+ subject.should include("<vcpu placement='static'>1</vcpu>")
15
+ end
16
+
17
+ it "sets the VNC port and autoport" do
18
+ definition.update gui: true,
19
+ vnc_port: 1234,
20
+ vnc_autoport: false,
21
+ vnc_password: 'abc123'
22
+
23
+ subject.should include("<graphics type='vnc' port='1234' autoport='false'")
24
+
25
+ new_definition = VagrantPlugins::ProviderKvm::Util::VmDefinition.new(subject)
26
+ new_definition.get(:gui).should be_true
27
+ new_definition.get(:vnc_port).should == 1234
28
+ new_definition.get(:vnc_autoport).should be_false
29
+ new_definition.get(:vnc_password).should == 'abc123'
30
+ end
31
+
32
+ it "should set and load the GUI settings" do
33
+ should_set(:gui, true) do |xml|
34
+ xml.should include("<graphics type='vnc'")
35
+ end
36
+ end
37
+
38
+ it "sets machine type" do
39
+ should_default(:machine_type, "pc-1.2")
40
+ should_set(:machine_type, "pc-i440fx-1.4")
41
+ end
42
+
43
+ it "sets the network driver type" do
44
+ should_default(:network_model, "virtio")
45
+ should_set(:network_model, "ne2k_pci")
46
+ end
47
+
48
+ it "doesn't set the network driver if network_mode=:default" do
49
+ should_set(:network_model, :default) do |xml|
50
+ doc = REXML::Document.new(xml)
51
+ doc.elements["//devices/interface/model"].should be_nil
52
+ end
53
+ end
54
+
55
+ it "sets the video type" do
56
+ should_default(:video_model, "cirrus")
57
+ should_set(:video_model, "vga")
58
+ end
59
+ end
60
+ end
61
+
62
+ private
63
+ def should_set(key, value)
64
+ definition.update(key => value)
65
+ definition.get(key).should == value
66
+ yield subject if block_given?
67
+
68
+ # Validates that it's symetrical
69
+ new_definition = described_class.new(subject)
70
+ new_definition.get(key).should == value
71
+ end
72
+
73
+ def should_default(key, value)
74
+ definition.get(key).should == value
75
+ end
76
+ end
@@ -1,13 +1,13 @@
1
1
  <domain type='kvm'>
2
- <name><%= name %></name>
3
- <% if uuid %>
4
- <uuid><%= uuid %></uuid>
5
- <% end %>
6
- <memory unit='KiB'><%= memory %></memory>
7
- <currentMemory unit='KiB'><%= memory%></currentMemory>
8
- <vcpu placement='static'><%= cpus %></vcpu>
2
+ <name><%= name %></name>
3
+ <% if uuid %>
4
+ <uuid><%= uuid %></uuid>
5
+ <% end %>
6
+ <memory unit='<%= memory_unit %>'><%= memory_size %></memory>
7
+ <currentMemory unit='<%= memory_unit %>'><%= memory_size %></currentMemory>
8
+ <vcpu placement='static'><%= cpus %></vcpu>
9
9
  <os>
10
- <type arch='<%= arch %>' machine='pc-1.2'>hvm</type>
10
+ <type arch='<%= arch %>' machine='<%= machine_type %>'>hvm</type>
11
11
  <boot dev='hd'/>
12
12
  </os>
13
13
  <features>
@@ -24,19 +24,38 @@
24
24
  <disk type='file' device='disk'>
25
25
  <driver name='qemu' type='<%= image_type %>'/>
26
26
  <source file='<%= disk %>'/>
27
- <target dev='vda' bus='virtio'/>
27
+ <target dev='vda' bus='<%= disk_bus %>'/>
28
+ <% if disk_bus == 'virtio' %>
28
29
  <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
30
+ <% else %>
31
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
32
+ <% end %>
29
33
  </disk>
34
+ <controller type='ide' index='0'>
35
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
36
+ </controller>
30
37
  <controller type='usb' index='0'>
31
38
  <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
32
39
  </controller>
40
+ <% if disk_bus == 'sata' %>
41
+ <controller type='sata' index='0'>
42
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
43
+ </controller>
44
+ <% end %>
45
+ <% if disk_bus == 'scsi' %>
46
+ <controller type='scsi' index='0'>
47
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
48
+ </controller>
49
+ <% end %>
33
50
  <controller type='virtio-serial' index='0'>
34
51
  <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
35
52
  </controller>
36
53
  <interface type='network'>
37
54
  <mac address='<%= mac %>'/>
38
55
  <source network='vagrant'/>
39
- <model type='virtio'/>
56
+ <% unless network_model == :default %>
57
+ <model type='<%= network_model %>'/>
58
+ <% end %>
40
59
  </interface>
41
60
  <serial type='pty'>
42
61
  <target port='0'/>
@@ -45,14 +64,17 @@
45
64
  <target type='serial' port='0'/>
46
65
  </console>
47
66
  <input type='mouse' bus='ps2'/>
67
+ <input type='tablet' bus='usb'/>
48
68
  <sound model='ich6'>
49
69
  <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
50
70
  </sound>
51
71
  <% if gui %>
52
- <%= "<graphics type='vnc' port='-1' autoport='yes'/>" %>
72
+ <graphics type='vnc' port='<%= vnc_port || -1 %>' autoport='<%= vnc_autoport %>' listen='0.0.0.0' passwd='<%= vnc_password %>'>
73
+ <listen type='address' address='0.0.0.0'/>
74
+ </graphics>
53
75
  <% end %>
54
76
  <video>
55
- <model type='cirrus' vram='9216' heads='1'/>
77
+ <model type='<%= video_model %>' vram='9216' heads='1'/>
56
78
  <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
57
79
  </video>
58
80
  <memballoon model='virtio'>
@@ -0,0 +1,13 @@
1
+ <network>
2
+ <name><%= name %></name>
3
+ <forward mode='<%= forward %>'/>
4
+ <domain name='<%= domain_name %>'/>
5
+ <ip address='<%= base_ip %>' netmask='<%= netmask %>'>
6
+ <dhcp>
7
+ <range start='<%= range[:start] %>' end='<%= range[:end] %>' />
8
+ <% for host in hosts %>
9
+ <host mac='<%= host[:mac] %>' name='<%= host[:name] %>' ip='<%= host[:ip] %>' />
10
+ <% end %>
11
+ </dhcp>
12
+ </ip>
13
+ </network>
@@ -0,0 +1,11 @@
1
+ Vagrant::Config.run do |config|
2
+ # This Vagrantfile is auto-generated by `vagrant package` to contain
3
+ # the MAC address of the box. Custom configuration should be placed in
4
+ # the actual `Vagrantfile` in this box.
5
+ config.vm.base_mac = "<%= base_mac %>"
6
+ end
7
+
8
+ # Load include vagrant file if it exists after the auto-generated
9
+ # so it can override any of the settings
10
+ include_vagrantfile = File.expand_path("../include/_Vagrantfile", __FILE__)
11
+ load include_vagrantfile if File.exist?(include_vagrantfile)
@@ -13,9 +13,8 @@ Gem::Specification.new do |s|
13
13
  s.license = 'MIT'
14
14
 
15
15
  s.required_rubygems_version = ">= 1.3.6"
16
- s.requirements << 'KVM/QEMU, v1.2.0 or greater'
16
+ s.requirements << 'KVM/QEMU, v1.1.0 or greater'
17
17
 
18
- s.add_runtime_dependency "nokogiri", "~> 1.5.6"
19
18
  s.add_runtime_dependency "ruby-libvirt", "~> 0.4.0"
20
19
 
21
20
  s.add_development_dependency "pry"
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-kvm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
5
- prerelease:
4
+ version: 0.1.5
6
5
  platform: ruby
7
6
  authors:
8
7
  - Alex Drahon
@@ -10,28 +9,11 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2013-08-24 00:00:00.000000000 Z
12
+ date: 2014-03-22 00:00:00.000000000 Z
14
13
  dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: nokogiri
17
- requirement: !ruby/object:Gem::Requirement
18
- none: false
19
- requirements:
20
- - - ~>
21
- - !ruby/object:Gem::Version
22
- version: 1.5.6
23
- type: :runtime
24
- prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
- requirements:
28
- - - ~>
29
- - !ruby/object:Gem::Version
30
- version: 1.5.6
31
14
  - !ruby/object:Gem::Dependency
32
15
  name: ruby-libvirt
33
16
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
17
  requirements:
36
18
  - - ~>
37
19
  - !ruby/object:Gem::Version
@@ -39,7 +21,6 @@ dependencies:
39
21
  type: :runtime
40
22
  prerelease: false
41
23
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
24
  requirements:
44
25
  - - ~>
45
26
  - !ruby/object:Gem::Version
@@ -47,39 +28,34 @@ dependencies:
47
28
  - !ruby/object:Gem::Dependency
48
29
  name: pry
49
30
  requirement: !ruby/object:Gem::Requirement
50
- none: false
51
31
  requirements:
52
- - - ! '>='
32
+ - - '>='
53
33
  - !ruby/object:Gem::Version
54
34
  version: '0'
55
35
  type: :development
56
36
  prerelease: false
57
37
  version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
38
  requirements:
60
- - - ! '>='
39
+ - - '>='
61
40
  - !ruby/object:Gem::Version
62
41
  version: '0'
63
42
  - !ruby/object:Gem::Dependency
64
43
  name: rake
65
44
  requirement: !ruby/object:Gem::Requirement
66
- none: false
67
45
  requirements:
68
- - - ! '>='
46
+ - - '>='
69
47
  - !ruby/object:Gem::Version
70
48
  version: '0'
71
49
  type: :development
72
50
  prerelease: false
73
51
  version_requirements: !ruby/object:Gem::Requirement
74
- none: false
75
52
  requirements:
76
- - - ! '>='
53
+ - - '>='
77
54
  - !ruby/object:Gem::Version
78
55
  version: '0'
79
56
  - !ruby/object:Gem::Dependency
80
57
  name: rspec-core
81
58
  requirement: !ruby/object:Gem::Requirement
82
- none: false
83
59
  requirements:
84
60
  - - ~>
85
61
  - !ruby/object:Gem::Version
@@ -87,7 +63,6 @@ dependencies:
87
63
  type: :development
88
64
  prerelease: false
89
65
  version_requirements: !ruby/object:Gem::Requirement
90
- none: false
91
66
  requirements:
92
67
  - - ~>
93
68
  - !ruby/object:Gem::Version
@@ -95,7 +70,6 @@ dependencies:
95
70
  - !ruby/object:Gem::Dependency
96
71
  name: rspec-expectations
97
72
  requirement: !ruby/object:Gem::Requirement
98
- none: false
99
73
  requirements:
100
74
  - - ~>
101
75
  - !ruby/object:Gem::Version
@@ -103,7 +77,6 @@ dependencies:
103
77
  type: :development
104
78
  prerelease: false
105
79
  version_requirements: !ruby/object:Gem::Requirement
106
- none: false
107
80
  requirements:
108
81
  - - ~>
109
82
  - !ruby/object:Gem::Version
@@ -111,7 +84,6 @@ dependencies:
111
84
  - !ruby/object:Gem::Dependency
112
85
  name: rspec-mocks
113
86
  requirement: !ruby/object:Gem::Requirement
114
- none: false
115
87
  requirements:
116
88
  - - ~>
117
89
  - !ruby/object:Gem::Version
@@ -119,7 +91,6 @@ dependencies:
119
91
  type: :development
120
92
  prerelease: false
121
93
  version_requirements: !ruby/object:Gem::Requirement
122
- none: false
123
94
  requirements:
124
95
  - - ~>
125
96
  - !ruby/object:Gem::Version
@@ -130,21 +101,44 @@ executables: []
130
101
  extensions: []
131
102
  extra_rdoc_files: []
132
103
  files:
104
+ - INSTALL.md
133
105
  - vagrant-kvm.gemspec
106
+ - spec/acceptance/vagrant-kvm_spec.rb
107
+ - spec/test_files/box.xml
108
+ - spec/fedora/50-vagrant-libvirt-access.pkla
109
+ - spec/fedora/10.virt.rules
110
+ - spec/vagrant-kvm/errors_spec.rb
111
+ - spec/vagrant-kvm/util/vm_definition_spec.rb
112
+ - spec/vagrant-kvm/util/network_definition_spec.rb
113
+ - spec/vagrant-kvm/config_spec.rb
114
+ - spec/vagrant-kvm/driver/driver_spec.rb
115
+ - spec/spec_helper.rb
116
+ - spec/support/libvirt_helper.rb
117
+ - spec/support/vagrant_kvm_helper.rb
118
+ - DEVELOPMENT.md
134
119
  - Gemfile
120
+ - templates/libvirt_network.erb
121
+ - templates/package_Vagrantfile.erb
135
122
  - templates/libvirt_domain.erb
136
123
  - example_box/metadata.json
137
124
  - example_box/box.xml
138
125
  - example_box/README.md
139
126
  - CHANGELOG.md
140
127
  - locales/en.yml
128
+ - locales/ja.yml
141
129
  - lib/vagrant-kvm/version.rb
130
+ - lib/vagrant-kvm/util/disk_info.rb
131
+ - lib/vagrant-kvm/util/commands.rb
132
+ - lib/vagrant-kvm/util/definition_attributes.rb
142
133
  - lib/vagrant-kvm/util/kvm_template_renderer.rb
143
134
  - lib/vagrant-kvm/util/vm_definition.rb
144
135
  - lib/vagrant-kvm/util/network_definition.rb
145
136
  - lib/vagrant-kvm/plugin.rb
146
137
  - lib/vagrant-kvm/action.rb
138
+ - lib/vagrant-kvm/action/resume_network.rb
139
+ - lib/vagrant-kvm/action/prepare_gui.rb
147
140
  - lib/vagrant-kvm/action/package.rb
141
+ - lib/vagrant-kvm/action/prepare_nfs_valid_ids.rb
148
142
  - lib/vagrant-kvm/action/match_mac_address.rb
149
143
  - lib/vagrant-kvm/action/check_box.rb
150
144
  - lib/vagrant-kvm/action/prepare_nfs_settings.rb
@@ -152,9 +146,11 @@ files:
152
146
  - lib/vagrant-kvm/action/resume.rb
153
147
  - lib/vagrant-kvm/action/forced_halt.rb
154
148
  - lib/vagrant-kvm/action/suspend.rb
149
+ - lib/vagrant-kvm/action/clear_forwarded_ports.rb
155
150
  - lib/vagrant-kvm/action/check_created.rb
156
151
  - lib/vagrant-kvm/action/share_folders.rb
157
152
  - lib/vagrant-kvm/action/init_storage_pool.rb
153
+ - lib/vagrant-kvm/action/message_not_running.rb
158
154
  - lib/vagrant-kvm/action/is_paused.rb
159
155
  - lib/vagrant-kvm/action/prune_nfs_exports.rb
160
156
  - lib/vagrant-kvm/action/created.rb
@@ -164,8 +160,10 @@ files:
164
160
  - lib/vagrant-kvm/action/destroy.rb
165
161
  - lib/vagrant-kvm/action/import.rb
166
162
  - lib/vagrant-kvm/action/set_name.rb
163
+ - lib/vagrant-kvm/action/reset_image_permission.rb
167
164
  - lib/vagrant-kvm/action/export.rb
168
165
  - lib/vagrant-kvm/action/destroy_confirm.rb
166
+ - lib/vagrant-kvm/action/forward_ports.rb
169
167
  - lib/vagrant-kvm/action/check_running.rb
170
168
  - lib/vagrant-kvm/action/check_kvm.rb
171
169
  - lib/vagrant-kvm/action/is_saved.rb
@@ -181,31 +179,32 @@ files:
181
179
  - LICENSE
182
180
  - Rakefile
183
181
  - README.md
182
+ - .travis.yml
183
+ - .rspec
184
184
  - .gitignore
185
185
  homepage: http://www.vagrantup.com
186
186
  licenses:
187
187
  - MIT
188
+ metadata: {}
188
189
  post_install_message:
189
190
  rdoc_options: []
190
191
  require_paths:
191
192
  - lib
192
193
  required_ruby_version: !ruby/object:Gem::Requirement
193
- none: false
194
194
  requirements:
195
- - - ! '>='
195
+ - - '>='
196
196
  - !ruby/object:Gem::Version
197
197
  version: '0'
198
198
  required_rubygems_version: !ruby/object:Gem::Requirement
199
- none: false
200
199
  requirements:
201
- - - ! '>='
200
+ - - '>='
202
201
  - !ruby/object:Gem::Version
203
202
  version: 1.3.6
204
203
  requirements:
205
- - KVM/QEMU, v1.2.0 or greater
204
+ - KVM/QEMU, v1.1.0 or greater
206
205
  rubyforge_project:
207
- rubygems_version: 1.8.25
206
+ rubygems_version: 2.1.11
208
207
  signing_key:
209
- specification_version: 3
208
+ specification_version: 4
210
209
  summary: Enables Vagrant to use KVM instead of VirtualBox.
211
210
  test_files: []