vagrant-libvirt 0.0.40 → 0.0.41

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 (81) hide show
  1. checksums.yaml +4 -4
  2. metadata +13 -103
  3. data/.coveralls.yml +0 -1
  4. data/.github/issue_template.md +0 -37
  5. data/.gitignore +0 -21
  6. data/.travis.yml +0 -28
  7. data/CHANGELOG.md +0 -99
  8. data/Gemfile +0 -27
  9. data/LICENSE +0 -22
  10. data/README.md +0 -1311
  11. data/Rakefile +0 -8
  12. data/example_box/README.md +0 -29
  13. data/example_box/Vagrantfile +0 -60
  14. data/example_box/metadata.json +0 -5
  15. data/lib/vagrant-libvirt.rb +0 -29
  16. data/lib/vagrant-libvirt/action.rb +0 -362
  17. data/lib/vagrant-libvirt/action/create_domain.rb +0 -313
  18. data/lib/vagrant-libvirt/action/create_domain_volume.rb +0 -87
  19. data/lib/vagrant-libvirt/action/create_network_interfaces.rb +0 -294
  20. data/lib/vagrant-libvirt/action/create_networks.rb +0 -353
  21. data/lib/vagrant-libvirt/action/destroy_domain.rb +0 -83
  22. data/lib/vagrant-libvirt/action/destroy_networks.rb +0 -95
  23. data/lib/vagrant-libvirt/action/forward_ports.rb +0 -221
  24. data/lib/vagrant-libvirt/action/halt_domain.rb +0 -35
  25. data/lib/vagrant-libvirt/action/handle_box_image.rb +0 -156
  26. data/lib/vagrant-libvirt/action/handle_storage_pool.rb +0 -57
  27. data/lib/vagrant-libvirt/action/is_created.rb +0 -18
  28. data/lib/vagrant-libvirt/action/is_running.rb +0 -21
  29. data/lib/vagrant-libvirt/action/is_suspended.rb +0 -42
  30. data/lib/vagrant-libvirt/action/message_already_created.rb +0 -16
  31. data/lib/vagrant-libvirt/action/message_not_created.rb +0 -16
  32. data/lib/vagrant-libvirt/action/message_not_running.rb +0 -16
  33. data/lib/vagrant-libvirt/action/message_not_suspended.rb +0 -16
  34. data/lib/vagrant-libvirt/action/package_domain.rb +0 -105
  35. data/lib/vagrant-libvirt/action/prepare_nfs_settings.rb +0 -94
  36. data/lib/vagrant-libvirt/action/prepare_nfs_valid_ids.rb +0 -17
  37. data/lib/vagrant-libvirt/action/prune_nfs_exports.rb +0 -27
  38. data/lib/vagrant-libvirt/action/read_mac_addresses.rb +0 -40
  39. data/lib/vagrant-libvirt/action/remove_libvirt_image.rb +0 -20
  40. data/lib/vagrant-libvirt/action/remove_stale_volume.rb +0 -50
  41. data/lib/vagrant-libvirt/action/resume_domain.rb +0 -34
  42. data/lib/vagrant-libvirt/action/set_boot_order.rb +0 -109
  43. data/lib/vagrant-libvirt/action/set_name_of_domain.rb +0 -64
  44. data/lib/vagrant-libvirt/action/share_folders.rb +0 -71
  45. data/lib/vagrant-libvirt/action/start_domain.rb +0 -303
  46. data/lib/vagrant-libvirt/action/suspend_domain.rb +0 -40
  47. data/lib/vagrant-libvirt/action/wait_till_up.rb +0 -102
  48. data/lib/vagrant-libvirt/cap/mount_p9.rb +0 -42
  49. data/lib/vagrant-libvirt/cap/nic_mac_addresses.rb +0 -17
  50. data/lib/vagrant-libvirt/cap/synced_folder.rb +0 -113
  51. data/lib/vagrant-libvirt/config.rb +0 -698
  52. data/lib/vagrant-libvirt/driver.rb +0 -118
  53. data/lib/vagrant-libvirt/errors.rb +0 -149
  54. data/lib/vagrant-libvirt/plugin.rb +0 -92
  55. data/lib/vagrant-libvirt/provider.rb +0 -130
  56. data/lib/vagrant-libvirt/templates/default_storage_pool.xml.erb +0 -13
  57. data/lib/vagrant-libvirt/templates/domain.xml.erb +0 -229
  58. data/lib/vagrant-libvirt/templates/private_network.xml.erb +0 -34
  59. data/lib/vagrant-libvirt/templates/public_interface.xml.erb +0 -23
  60. data/lib/vagrant-libvirt/util.rb +0 -11
  61. data/lib/vagrant-libvirt/util/collection.rb +0 -19
  62. data/lib/vagrant-libvirt/util/erb_template.rb +0 -22
  63. data/lib/vagrant-libvirt/util/error_codes.rb +0 -100
  64. data/lib/vagrant-libvirt/util/network_util.rb +0 -138
  65. data/lib/vagrant-libvirt/util/timer.rb +0 -17
  66. data/lib/vagrant-libvirt/version.rb +0 -5
  67. data/locales/en.yml +0 -159
  68. data/spec/spec_helper.rb +0 -9
  69. data/spec/support/environment_helper.rb +0 -46
  70. data/spec/support/libvirt_context.rb +0 -30
  71. data/spec/support/sharedcontext.rb +0 -34
  72. data/spec/unit/action/destroy_domain_spec.rb +0 -97
  73. data/spec/unit/action/set_name_of_domain_spec.rb +0 -21
  74. data/spec/unit/action/wait_till_up_spec.rb +0 -127
  75. data/spec/unit/config_spec.rb +0 -106
  76. data/spec/unit/templates/domain_all_settings.xml +0 -133
  77. data/spec/unit/templates/domain_defaults.xml +0 -46
  78. data/spec/unit/templates/domain_spec.rb +0 -75
  79. data/tools/create_box.sh +0 -130
  80. data/tools/prepare_redhat_for_box.sh +0 -119
  81. data/vagrant-libvirt.gemspec +0 -28
@@ -1,97 +0,0 @@
1
- require 'spec_helper'
2
- require 'support/sharedcontext'
3
- require 'support/libvirt_context'
4
-
5
- require 'vagrant-libvirt/action/destroy_domain'
6
-
7
- describe VagrantPlugins::ProviderLibvirt::Action::DestroyDomain do
8
- subject { described_class.new(app, env) }
9
-
10
- include_context 'unit'
11
- include_context 'libvirt'
12
-
13
- let(:libvirt_domain) { double('libvirt_domain') }
14
- let(:libvirt_client) { double('libvirt_client') }
15
- let(:servers) { double('servers') }
16
-
17
- describe '#call' do
18
- before do
19
- allow_any_instance_of(VagrantPlugins::ProviderLibvirt::Driver)
20
- .to receive(:connection).and_return(connection)
21
- allow(connection).to receive(:client).and_return(libvirt_client)
22
- allow(libvirt_client).to receive(:lookup_domain_by_uuid)
23
- .and_return(libvirt_domain)
24
- allow(connection).to receive(:servers).and_return(servers)
25
- allow(servers).to receive(:get).and_return(domain)
26
- # always see this at the start of #call
27
- expect(ui).to receive(:info).with('Removing domain...')
28
- end
29
-
30
- context 'when no snapshots' do
31
- let(:root_disk) { double('libvirt_root_disk') }
32
-
33
- before do
34
- allow(libvirt_domain).to receive(:list_snapshots).and_return([])
35
- allow(libvirt_domain).to receive(:has_managed_save?).and_return(nil)
36
- root_disk.stub(name: 'test.img')
37
- end
38
-
39
- context 'when only has root disk' do
40
- it 'calls fog to destroy volumes' do
41
- expect(domain).to receive(:destroy).with(destroy_volumes: true)
42
- expect(subject.call(env)).to be_nil
43
- end
44
- end
45
-
46
- context 'when has additional disks' do
47
- let(:vagrantfile) do
48
- <<-EOF
49
- Vagrant.configure('2') do |config|
50
- config.vm.define :test
51
- config.vm.provider :libvirt do |libvirt|
52
- libvirt.storage :file
53
- end
54
- end
55
- EOF
56
- end
57
-
58
- let(:extra_disk) { double('libvirt_extra_disk') }
59
- before do
60
- extra_disk.stub(name: 'test-vdb.qcow2')
61
- end
62
-
63
- it 'destroys disks individually' do
64
- allow(libvirt_domain).to receive(:name).and_return('test')
65
- allow(domain).to receive(:volumes).and_return([extra_disk], [root_disk])
66
-
67
- expect(domain).to receive(:destroy).with(destroy_volumes: false)
68
- expect(extra_disk).to receive(:destroy) # extra disk remove
69
- expect(root_disk).to receive(:destroy) # root disk remove
70
- expect(subject.call(env)).to be_nil
71
- end
72
- end
73
-
74
- context 'when has CDROMs attached' do
75
- let(:vagrantfile) do
76
- <<-EOF
77
- Vagrant.configure('2') do |config|
78
- config.vm.define :test
79
- config.vm.provider :libvirt do |libvirt|
80
- libvirt.storage :file, :device => :cdrom
81
- end
82
- end
83
- EOF
84
- end
85
-
86
- it 'uses explicit removal of disks' do
87
- allow(libvirt_domain).to receive(:name).and_return('test')
88
- allow(domain).to receive(:volumes).and_return([root_disk])
89
-
90
- expect(domain).to_not receive(:destroy).with(destroy_volumes: true)
91
- expect(root_disk).to receive(:destroy) # root disk remove
92
- expect(subject.call(env)).to be_nil
93
- end
94
- end
95
- end
96
- end
97
- end
@@ -1,21 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe VagrantPlugins::ProviderLibvirt::Action::SetNameOfDomain do
4
- before :each do
5
- @env = EnvironmentHelper.new
6
- end
7
-
8
- it 'builds unique domain name' do
9
- @env.random_hostname = true
10
- dmn = VagrantPlugins::ProviderLibvirt::Action::SetNameOfDomain.new(Object.new, @env)
11
- first = dmn.build_domain_name(@env)
12
- second = dmn.build_domain_name(@env)
13
- first.should_not eq(second)
14
- end
15
-
16
- it 'builds simple domain name' do
17
- @env.default_prefix = 'pre'
18
- dmn = VagrantPlugins::ProviderLibvirt::Action::SetNameOfDomain.new(Object.new, @env)
19
- dmn.build_domain_name(@env).should eq('pre_')
20
- end
21
- end
@@ -1,127 +0,0 @@
1
- require 'vagrant-libvirt/action/wait_till_up'
2
- require 'vagrant-libvirt/errors'
3
-
4
- require 'spec_helper'
5
- require 'support/sharedcontext'
6
- require 'support/libvirt_context'
7
-
8
- describe VagrantPlugins::ProviderLibvirt::Action::WaitTillUp do
9
- subject { described_class.new(app, env) }
10
-
11
- include_context 'vagrant-unit'
12
- include_context 'libvirt'
13
- include_context 'unit'
14
-
15
- describe '#call' do
16
- before do
17
- allow_any_instance_of(VagrantPlugins::ProviderLibvirt::Driver)
18
- .to receive(:get_domain).and_return(domain)
19
- allow_any_instance_of(VagrantPlugins::ProviderLibvirt::Driver).to receive(:state)
20
- .and_return(:running)
21
- end
22
-
23
- context 'when machine does not exist' do
24
- before do
25
- allow_any_instance_of(VagrantPlugins::ProviderLibvirt::Driver)
26
- .to receive(:get_domain).and_return(nil)
27
- end
28
-
29
- it 'raises exception' do
30
- expect(app).to_not receive(:call)
31
- expect { subject.call(env) }.to raise_error(::VagrantPlugins::ProviderLibvirt::Errors::NoDomainError,
32
- /No domain found. Domain dummy-vagrant_dummy not found/)
33
- end
34
- end
35
-
36
- context 'when machine is booting' do
37
- context 'if interrupted looking for IP' do
38
- before do
39
- env[:interrupted] = true
40
- end
41
- it 'should exit' do
42
- expect(app).to_not receive(:call)
43
- expect(ui).to receive(:info).with('Waiting for domain to get an IP address...')
44
- expect(subject.call(env)).to be_nil
45
- end
46
- end
47
-
48
- context 'if interrupted waiting for SSH' do
49
- before do
50
- allow(domain).to receive(:wait_for).and_return(true)
51
- allow(env).to receive(:[]).and_call_original
52
- allow(env).to receive(:[]).with(:interrupted).and_return(false, true, true)
53
- allow(env).to receive(:[]).with(:ip_address).and_return('192.168.121.2')
54
- end
55
- it 'should exit after getting IP' do
56
- expect(app).to_not receive(:call)
57
- expect(ui).to receive(:info).with('Waiting for domain to get an IP address...')
58
- expect(ui).to receive(:info).with('Waiting for SSH to become available...')
59
- logger = subject.instance_variable_get(:@logger)
60
- expect(logger).to receive(:debug).with(/Searching for IP for MAC address: .*/)
61
- expect(logger).to receive(:info).with('Got IP address 192.168.121.2')
62
- expect(logger).to receive(:info).with(/Time for getting IP: .*/)
63
- expect(env[:machine].communicate).to_not receive(:ready?)
64
- expect(subject.call(env)).to be_nil
65
- end
66
- end
67
- end
68
-
69
- context 'when machine boots and ssh available' do
70
- before do
71
- allow(domain).to receive(:wait_for).and_return(true)
72
- allow(env).to receive(:[]).and_call_original
73
- allow(env).to receive(:[]).with(:interrupted).and_return(false)
74
- allow(env).to receive(:[]).with(:ip_address).and_return('192.168.121.2')
75
- end
76
- it 'should call the next hook' do
77
- expect(app).to receive(:call)
78
- expect(ui).to receive(:info).with('Waiting for domain to get an IP address...')
79
- expect(ui).to receive(:info).with('Waiting for SSH to become available...')
80
- expect(env[:machine].communicate).to receive(:ready?).and_return(true)
81
- expect(subject.call(env)).to be_nil
82
- end
83
- end
84
- end
85
-
86
- describe '#recover' do
87
- before do
88
- allow_any_instance_of(VagrantPlugins::ProviderLibvirt::Driver).to receive(:get_domain).and_return(machine)
89
- allow_any_instance_of(VagrantPlugins::ProviderLibvirt::Driver).to receive(:state)
90
- .and_return(:not_created)
91
- allow(env).to receive(:[]).and_call_original
92
- end
93
-
94
- it 'should do nothing by default' do
95
- expect(env).to_not receive(:[]).with(:action_runner) # cleanup
96
- expect(subject.recover(env)).to be_nil
97
- end
98
-
99
- context 'with machine coming up' do
100
- before do
101
- allow_any_instance_of(VagrantPlugins::ProviderLibvirt::Driver).to receive(:state)
102
- .and_return(:running)
103
- env[:destroy_on_error] = true
104
- end
105
-
106
- context 'and user has disabled destroy on failure' do
107
- before do
108
- env[:destroy_on_error] = false
109
- end
110
-
111
- it 'skips terminate on failure' do
112
- expect(env).to_not receive(:[]).with(:action_runner) # cleanup
113
- expect(subject.recover(env)).to be_nil
114
- end
115
- end
116
-
117
- context 'and using default settings' do
118
- let(:runner) { double('runner') }
119
- it 'deletes VM on failure' do
120
- expect(env).to receive(:[]).with(:action_runner).and_return(runner) # cleanup
121
- expect(runner).to receive(:run)
122
- expect(subject.recover(env)).to be_nil
123
- end
124
- end
125
- end
126
- end
127
- end
@@ -1,106 +0,0 @@
1
- require 'spec_helper'
2
- require 'support/sharedcontext'
3
-
4
- require 'vagrant-libvirt/config'
5
-
6
- describe VagrantPlugins::ProviderLibvirt::Config do
7
- include_context 'unit'
8
-
9
- def assert_invalid
10
- errors = subject.validate(machine)
11
- raise "No errors: #{errors.inspect}" if errors.values.any? { |v| !v.empty? }
12
- end
13
-
14
- def assert_valid
15
- errors = subject.validate(machine)
16
- raise "Errors: #{errors.inspect}" unless errors.values.all?(&:empty?)
17
- end
18
-
19
- describe '#validate' do
20
- it 'is valid with defaults' do
21
- assert_valid
22
- end
23
-
24
- it 'is valid if relative path used for disk' do
25
- subject.storage :file, path: '../path/to/file.qcow2'
26
- assert_valid
27
- end
28
-
29
- it 'should be invalid if absolute path used for disk' do
30
- subject.storage :file, path: '/absolute/path/to/file.qcow2'
31
- assert_invalid
32
- end
33
-
34
- context 'with mac defined' do
35
- let (:vm) { double('vm') }
36
- let (:networks) { double('networks') }
37
- before do
38
- allow(vm).to receive(:networks).and_return(networks)
39
- allow(machine.config).to receive(:vm).and_return(vm)
40
- end
41
-
42
- it 'is valid with valid mac' do
43
- allow(networks).to receive(:each).and_return([:public, { mac: 'aa:bb:cc:dd:ee:ff' }])
44
- assert_valid
45
- end
46
-
47
- it 'should be invalid if MAC not formatted correctly' do
48
- allow(networks).to receive(:each).and_return([:public, { mac: 'aabbccddeeff' }])
49
- assert_invalid
50
- end
51
- end
52
- end
53
-
54
- describe '#merge' do
55
- let(:one) { described_class.new }
56
- let(:two) { described_class.new }
57
-
58
- subject { one.merge(two) }
59
-
60
- context 'storage' do
61
- context 'with disks' do
62
- context 'assigned specific devices' do
63
- it 'should merge disks with specific devices' do
64
- one.storage(:file, device: 'vdb')
65
- two.storage(:file, device: 'vdc')
66
- subject.finalize!
67
- expect(subject.disks).to include(include(device: 'vdb'),
68
- include(device: 'vdc'))
69
- end
70
- end
71
-
72
- context 'without devices given' do
73
- it 'should merge disks with different devices assigned automatically' do
74
- one.storage(:file)
75
- two.storage(:file)
76
- subject.finalize!
77
- expect(subject.disks).to include(include(device: 'vdb'),
78
- include(device: 'vdc'))
79
- end
80
- end
81
- end
82
-
83
- context 'with cdroms only' do
84
- context 'assigned specific devs' do
85
- it 'should merge disks with specific devices' do
86
- one.storage(:file, device: :cdrom, dev: 'hda')
87
- two.storage(:file, device: :cdrom, dev: 'hdb')
88
- subject.finalize!
89
- expect(subject.cdroms).to include(include(dev: 'hda'),
90
- include(dev: 'hdb'))
91
- end
92
- end
93
-
94
- context 'without devs given' do
95
- it 'should merge cdroms with different devs assigned automatically' do
96
- one.storage(:file, device: :cdrom)
97
- two.storage(:file, device: :cdrom)
98
- subject.finalize!
99
- expect(subject.cdroms).to include(include(dev: 'hda'),
100
- include(dev: 'hdb'))
101
- end
102
- end
103
- end
104
- end
105
- end
106
- end
@@ -1,133 +0,0 @@
1
- <domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
2
- <name></name>
3
- <uuid></uuid>
4
- <memory></memory>
5
- <vcpu>1</vcpu>
6
-
7
-
8
- <cpu mode='custom'>
9
- <model fallback='allow'>qemu64</model>
10
- <feature name='AAA' policy='required'/>
11
- </cpu>
12
-
13
-
14
- <os>
15
- <type arch='x86_64' machine='pc-compatible'>hvm</type>
16
- <loader readonly='yes' type='rom'>/efi/loader</loader>
17
- <bootmenu enable='yes'/>
18
- <kernel></kernel>
19
- <initrd></initrd>
20
- <cmdline></cmdline>
21
- </os>
22
- <features>
23
- <acpi/>
24
- <apic/>
25
- <pae/>
26
- </features>
27
- <clock offset='utc'/>
28
- <devices>
29
- <emulator>/usr/bin/kvm-spice</emulator>
30
- <disk type='file' device='disk'>
31
- <driver name='qemu' type='qcow2' cache='unsafe'/>
32
- <source file='/var/lib/libvirt/images/test.qcow2'/>
33
- <target dev='vda' bus='ide'/>
34
- </disk>
35
- <disk type='file' device='disk'>
36
- <driver name='qemu' type='qcow2' cache='default'/>
37
- <source file='/var/lib/libvirt/images/test-disk1.qcow2'/>
38
- <target dev='vdb' bus='virtio'/>
39
- </disk>
40
- <disk type='file' device='disk'>
41
- <driver name='qemu' type='qcow2' cache='default'/>
42
- <source file='/var/lib/libvirt/images/test-disk2.qcow2'/>
43
- <target dev='vdc' bus='virtio'/>
44
- </disk>
45
-
46
- <disk type='file' device='cdrom'>
47
- <source file=''/>
48
- <target dev='hda' bus='ide'/>
49
- <readonly/>
50
- </disk>
51
- <disk type='file' device='cdrom'>
52
- <source file=''/>
53
- <target dev='hdb' bus='ide'/>
54
- <readonly/>
55
- </disk>
56
-
57
- <serial type='pty'>
58
- <target port='0'/>
59
- </serial>
60
- <console type='pty'>
61
- <target port='0'/>
62
- </console>
63
-
64
- <channel type='unix' >
65
- <source mode=''
66
- />
67
- <target type='virtio'
68
- name="org.qemu.guest_agent.0"
69
- />
70
- </channel>
71
- <channel type='unix' >
72
- <source mode=''
73
- path="/tmp/foo"
74
- />
75
- <target type='guestfwd'
76
- address="192.0.2.42"
77
- port="4242"
78
- />
79
- </channel>
80
-
81
- <input type='mouse' bus='ps2'/>
82
-
83
- <graphics type='vnc' port='5900' autoport='yes' listen='127.0.0.1' keymap='en-us' />
84
- <video>
85
- <model type='cirrus' vram='9216' heads='1'/>
86
- </video>
87
- <rng model='virtio'>
88
- <backend model='random'>/dev/random</backend>
89
- </rng>
90
- <hostdev mode='subsystem' type='pci' managed='yes'>
91
- <source>
92
- <address domain='0x0000'
93
- bus='0x06'
94
- slot='0x12'
95
- function='0x5'/>
96
- </source>
97
- </hostdev>
98
- <hostdev mode='subsystem' type='pci' managed='yes'>
99
- <source>
100
- <address domain='0x0000'
101
- bus='0x03'
102
- slot='0x00'
103
- function='0x0'/>
104
- </source>
105
- </hostdev>
106
- <hostdev mode='subsystem' type='usb'>
107
- <source startupPolicy='mandatory'>
108
- <vendor id='0x1234'/>
109
- <product id='0xabcd'/>
110
- <address bus='1' device='2'/>
111
- </source>
112
- </hostdev>
113
- <redirdev bus='usb' type='tcp'>
114
- </redirdev>
115
- <redirfilter>
116
- <usbdev class='0x0b' vendor='0x0b' product='0x0b' version='0x0b' allow='yes'/>
117
- </redirfilter>
118
- <watchdog model='i6300esb' action='reset'/>
119
-
120
- <smartcard mode='passthrough' type='spicevmc'/>
121
-
122
- <tpm model='tpm-tis'>
123
- <backend type='passthrough'>
124
- <device path='/dev/tpm0'/>
125
- </backend>
126
- </tpm>
127
- </devices>
128
-
129
- <qemu:commandline>
130
- <qemu:arg value='-device'/>
131
- <qemu:arg value='dummy-device'/>
132
- </qemu:commandline>
133
- </domain>