vagrant-libvirt 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +9 -6
  3. data/lib/vagrant-libvirt/action/create_domain.rb +19 -91
  4. data/lib/vagrant-libvirt/action/destroy_domain.rb +20 -4
  5. data/lib/vagrant-libvirt/action/destroy_networks.rb +1 -1
  6. data/lib/vagrant-libvirt/action/handle_box_image.rb +2 -0
  7. data/lib/vagrant-libvirt/action/resolve_disk_settings.rb +174 -0
  8. data/lib/vagrant-libvirt/action/start_domain.rb +41 -1
  9. data/lib/vagrant-libvirt/action.rb +14 -6
  10. data/lib/vagrant-libvirt/config.rb +12 -4
  11. data/lib/vagrant-libvirt/templates/domain.xml.erb +13 -8
  12. data/lib/vagrant-libvirt/util/domain_flags.rb +15 -0
  13. data/lib/vagrant-libvirt/util.rb +1 -0
  14. data/lib/vagrant-libvirt/version +1 -1
  15. data/locales/en.yml +4 -2
  16. data/spec/support/libvirt_context.rb +4 -0
  17. data/spec/unit/action/cleanup_on_failure_spec.rb +0 -2
  18. data/spec/unit/action/create_domain_spec.rb +113 -147
  19. data/spec/unit/action/create_domain_volume_spec.rb +0 -3
  20. data/spec/unit/action/destroy_domain_spec.rb +43 -10
  21. data/spec/unit/action/handle_box_image_spec.rb +13 -13
  22. data/spec/unit/action/package_domain_spec.rb +0 -5
  23. data/spec/unit/action/resolve_disk_settings_spec/default_domain.xml +43 -0
  24. data/spec/unit/action/resolve_disk_settings_spec/default_no_aliases.xml +42 -0
  25. data/spec/unit/action/{create_domain_spec → resolve_disk_settings_spec}/default_system_storage_pool.xml +0 -0
  26. data/spec/unit/action/resolve_disk_settings_spec/multi_volume_box.xml +55 -0
  27. data/spec/unit/action/resolve_disk_settings_spec/multi_volume_box_additional_and_custom_no_aliases.xml +67 -0
  28. data/spec/unit/action/resolve_disk_settings_spec/multi_volume_box_additional_storage.xml +67 -0
  29. data/spec/unit/action/resolve_disk_settings_spec.rb +361 -0
  30. data/spec/unit/action/start_domain_spec/existing_added_nvram.xml +62 -0
  31. data/spec/unit/action/start_domain_spec/nvram_domain.xml +64 -0
  32. data/spec/unit/action/start_domain_spec/nvram_domain_other_setting.xml +64 -0
  33. data/spec/unit/action/start_domain_spec/nvram_domain_removed.xml +64 -0
  34. data/spec/unit/action/start_domain_spec.rb +64 -6
  35. data/spec/unit/action/wait_till_up_spec.rb +0 -2
  36. data/spec/unit/action_spec.rb +0 -3
  37. data/spec/unit/config_spec.rb +18 -0
  38. data/spec/unit/driver_spec.rb +2 -0
  39. data/spec/unit/templates/domain_all_settings.xml +8 -2
  40. data/spec/unit/templates/domain_spec.rb +3 -2
  41. metadata +38 -16
@@ -15,7 +15,6 @@ describe VagrantPlugins::ProviderLibvirt::Action::HandleBoxImage do
15
15
  include_context 'unit'
16
16
  include_context 'libvirt'
17
17
 
18
- let(:libvirt_client) { double('libvirt_client') }
19
18
  let(:volumes) { double('volumes') }
20
19
  let(:all) { double('all') }
21
20
  let(:box_volume) { double('box_volume') }
@@ -54,17 +53,13 @@ describe VagrantPlugins::ProviderLibvirt::Action::HandleBoxImage do
54
53
  byte_number_20G = ByteNumber.new(21474836480)
55
54
 
56
55
 
57
-
58
-
59
56
  describe '#call' do
60
57
  before do
61
- allow_any_instance_of(VagrantPlugins::ProviderLibvirt::Driver)
62
- .to receive(:connection).and_return(connection)
63
- allow(connection).to receive(:client).and_return(libvirt_client)
64
58
  allow(connection).to receive(:volumes).and_return(volumes)
65
59
  allow(volumes).to receive(:all).and_return(all)
66
60
  allow(env[:ui]).to receive(:clear_line)
67
61
 
62
+ env[:machine].provider_config.disk_device = 'vda'
68
63
  end
69
64
 
70
65
  context 'when one disk in metadata.json' do
@@ -92,7 +87,8 @@ describe VagrantPlugins::ProviderLibvirt::Action::HandleBoxImage do
92
87
  :path=>"/test/box.img",
93
88
  :name=>"test_vagrant_box_image_1.1.1_box.img",
94
89
  :virtual_size=>byte_number_5G,
95
- :format=>"qcow2"
90
+ :format=>"qcow2",
91
+ :device=>'vda',
96
92
  }
97
93
  ]
98
94
  )
@@ -121,7 +117,8 @@ describe VagrantPlugins::ProviderLibvirt::Action::HandleBoxImage do
121
117
  :path=>"/test/box.img",
122
118
  :name=>"test_vagrant_box_image_0_#{box_mtime.to_i}_box.img",
123
119
  :virtual_size=>byte_number_5G,
124
- :format=>"qcow2"
120
+ :format=>"qcow2",
121
+ :device=>'vda',
125
122
  }
126
123
  ]
127
124
  )
@@ -130,7 +127,7 @@ describe VagrantPlugins::ProviderLibvirt::Action::HandleBoxImage do
130
127
 
131
128
  context 'When config.machine_virtual_size is set and smaller than box_virtual_size' do
132
129
  before do
133
- allow(env[:machine]).to receive_message_chain("provider_config.machine_virtual_size").and_return(1)
130
+ env[:machine].provider_config.machine_virtual_size = 1
134
131
  end
135
132
  it 'should warning must be raise' do
136
133
  expect(ui).to receive(:warn).with("Ignoring requested virtual disk size of '1' as it is below\nthe minimum box image size of '5'.")
@@ -141,7 +138,8 @@ describe VagrantPlugins::ProviderLibvirt::Action::HandleBoxImage do
141
138
  :path=>"/test/box.img",
142
139
  :name=>"test_vagrant_box_image_1.1.1_box.img",
143
140
  :virtual_size=>byte_number_5G,
144
- :format=>"qcow2"
141
+ :format=>"qcow2",
142
+ :device=>'vda',
145
143
  }
146
144
  ]
147
145
  )
@@ -150,7 +148,7 @@ describe VagrantPlugins::ProviderLibvirt::Action::HandleBoxImage do
150
148
 
151
149
  context 'When config.machine_virtual_size is set and higher than box_virtual_size' do
152
150
  before do
153
- allow(env[:machine]).to receive_message_chain("provider_config.machine_virtual_size").and_return(20)
151
+ env[:machine].provider_config.machine_virtual_size = 20
154
152
  end
155
153
  it 'should be use' do
156
154
  expect(ui).to receive(:info).with("Created volume larger than box defaults, will require manual resizing of\nfilesystems to utilize.")
@@ -161,7 +159,8 @@ describe VagrantPlugins::ProviderLibvirt::Action::HandleBoxImage do
161
159
  :path=>"/test/box.img",
162
160
  :name=>"test_vagrant_box_image_1.1.1_box.img",
163
161
  :virtual_size=>byte_number_20G,
164
- :format=>"qcow2"
162
+ :format=>"qcow2",
163
+ :device=>'vda',
165
164
  }
166
165
  ]
167
166
  )
@@ -252,7 +251,8 @@ describe VagrantPlugins::ProviderLibvirt::Action::HandleBoxImage do
252
251
  :path=>"/test/box.img",
253
252
  :name=>"test_vagrant_box_image_1.1.1_send_box_name.img",
254
253
  :virtual_size=>byte_number_5G,
255
- :format=>"qcow2"
254
+ :format=>"qcow2",
255
+ :device=>'vda',
256
256
  },
257
257
  {
258
258
  :path=>"/test/disk.qcow2",
@@ -12,8 +12,6 @@ describe VagrantPlugins::ProviderLibvirt::Action::PackageDomain do
12
12
  include_context 'libvirt'
13
13
  include_context 'temporary_dir'
14
14
 
15
- let(:libvirt_client) { double('libvirt_client') }
16
- let(:libvirt_domain) { double('libvirt_domain') }
17
15
  let(:servers) { double('servers') }
18
16
  let(:volumes) { double('volumes') }
19
17
  let(:metadata_file) { double('file') }
@@ -21,9 +19,6 @@ describe VagrantPlugins::ProviderLibvirt::Action::PackageDomain do
21
19
 
22
20
  describe '#call' do
23
21
  before do
24
- allow_any_instance_of(VagrantPlugins::ProviderLibvirt::Driver)
25
- .to receive(:connection).and_return(connection)
26
- allow(connection).to receive(:client).and_return(libvirt_client)
27
22
  allow(libvirt_client).to receive(:lookup_domain_by_uuid).and_return(libvirt_domain)
28
23
 
29
24
  allow(connection).to receive(:servers).and_return(servers)
@@ -0,0 +1,43 @@
1
+ <domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
2
+ <name>vagrant-test_default</name>
3
+ <title></title>
4
+ <description>Source: /rootpath/Vagrantfile</description>
5
+ <uuid></uuid>
6
+ <memory>524288</memory>
7
+ <vcpu>1</vcpu>
8
+ <cpu mode='host-model'>
9
+ <model fallback='allow'></model>
10
+ </cpu>
11
+ <os>
12
+ <type>hvm</type>
13
+ <kernel></kernel>
14
+ <initrd></initrd>
15
+ <cmdline></cmdline>
16
+ </os>
17
+ <features>
18
+ <acpi/>
19
+ <apic/>
20
+ <pae/>
21
+ </features>
22
+ <clock offset='utc'>
23
+ </clock>
24
+ <devices>
25
+ <disk type='file' device='disk'>
26
+ <alias name='ua-box-volume-0'/>
27
+ <driver name='qemu' type='qcow2' cache='default'/>
28
+ <source file='/var/lib/libvirt/images/vagrant-test_default.img'/>
29
+ <target dev='vda' bus='virtio'/>
30
+ </disk>
31
+ <serial type='pty'>
32
+ <target port='0'/>
33
+ </serial>
34
+ <console type='pty'>
35
+ <target port='0'/>
36
+ </console>
37
+ <input type='mouse' bus='ps2'/>
38
+ <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' keymap='en-us'/>
39
+ <video>
40
+ <model type='cirrus' vram='16384' heads='1'/>
41
+ </video>
42
+ </devices>
43
+ </domain>
@@ -0,0 +1,42 @@
1
+ <domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
2
+ <name>vagrant-test_default</name>
3
+ <title></title>
4
+ <description>Source: /rootpath/Vagrantfile</description>
5
+ <uuid></uuid>
6
+ <memory>524288</memory>
7
+ <vcpu>1</vcpu>
8
+ <cpu mode='host-model'>
9
+ <model fallback='allow'></model>
10
+ </cpu>
11
+ <os>
12
+ <type>hvm</type>
13
+ <kernel></kernel>
14
+ <initrd></initrd>
15
+ <cmdline></cmdline>
16
+ </os>
17
+ <features>
18
+ <acpi/>
19
+ <apic/>
20
+ <pae/>
21
+ </features>
22
+ <clock offset='utc'>
23
+ </clock>
24
+ <devices>
25
+ <disk type='file' device='disk'>
26
+ <driver name='qemu' type='qcow2' cache='default'/>
27
+ <source file='/var/lib/libvirt/images/vagrant-test_default.img'/>
28
+ <target dev='vda' bus='virtio'/>
29
+ </disk>
30
+ <serial type='pty'>
31
+ <target port='0'/>
32
+ </serial>
33
+ <console type='pty'>
34
+ <target port='0'/>
35
+ </console>
36
+ <input type='mouse' bus='ps2'/>
37
+ <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' keymap='en-us'/>
38
+ <video>
39
+ <model type='cirrus' vram='16384' heads='1'/>
40
+ </video>
41
+ </devices>
42
+ </domain>
@@ -0,0 +1,55 @@
1
+ <domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
2
+ <name>vagrant-test_default</name>
3
+ <title></title>
4
+ <description>Source: /rootpath/Vagrantfile</description>
5
+ <uuid></uuid>
6
+ <memory>524288</memory>
7
+ <vcpu>1</vcpu>
8
+ <cpu mode='host-model'>
9
+ <model fallback='allow'></model>
10
+ </cpu>
11
+ <os>
12
+ <type>hvm</type>
13
+ <kernel></kernel>
14
+ <initrd></initrd>
15
+ <cmdline></cmdline>
16
+ </os>
17
+ <features>
18
+ <acpi/>
19
+ <apic/>
20
+ <pae/>
21
+ </features>
22
+ <clock offset='utc'>
23
+ </clock>
24
+ <devices>
25
+ <disk type='file' device='disk'>
26
+ <alias name='ua-box-volume-0'/>
27
+ <driver name='qemu' type='qcow2' cache='default'/>
28
+ <source file='/var/lib/libvirt/images/vagrant-test_default.img'/>
29
+ <target dev='vda' bus='virtio'/>
30
+ </disk>
31
+ <disk type='file' device='disk'>
32
+ <alias name='ua-box-volume-1'/>
33
+ <driver name='qemu' type='qcow2' cache='default'/>
34
+ <source file='/var/lib/libvirt/images/vagrant-test_default_1.img'/>
35
+ <target dev='vdb' bus='virtio'/>
36
+ </disk>
37
+ <disk type='file' device='disk'>
38
+ <alias name='ua-box-volume-2'/>
39
+ <driver name='qemu' type='qcow2' cache='default'/>
40
+ <source file='/var/lib/libvirt/images/vagrant-test_default_2.img'/>
41
+ <target dev='vdc' bus='virtio'/>
42
+ </disk>
43
+ <serial type='pty'>
44
+ <target port='0'/>
45
+ </serial>
46
+ <console type='pty'>
47
+ <target port='0'/>
48
+ </console>
49
+ <input type='mouse' bus='ps2'/>
50
+ <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' keymap='en-us'/>
51
+ <video>
52
+ <model type='cirrus' vram='16384' heads='1'/>
53
+ </video>
54
+ </devices>
55
+ </domain>
@@ -0,0 +1,67 @@
1
+ <domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
2
+ <name>vagrant-test_default</name>
3
+ <title></title>
4
+ <description>Source: /rootpath/Vagrantfile</description>
5
+ <uuid></uuid>
6
+ <memory>524288</memory>
7
+ <vcpu>1</vcpu>
8
+ <cpu mode='host-model'>
9
+ <model fallback='allow'></model>
10
+ </cpu>
11
+ <os>
12
+ <type>hvm</type>
13
+ <kernel></kernel>
14
+ <initrd></initrd>
15
+ <cmdline></cmdline>
16
+ </os>
17
+ <features>
18
+ <acpi/>
19
+ <apic/>
20
+ <pae/>
21
+ </features>
22
+ <clock offset='utc'>
23
+ </clock>
24
+ <devices>
25
+ <disk type='file' device='disk'>
26
+ <driver name='qemu' type='qcow2' cache='default'/>
27
+ <source file='/var/lib/libvirt/images/vagrant-test_default.img'/>
28
+ <target dev='vda' bus='virtio'/>
29
+ </disk>
30
+ <disk type='file' device='disk'>
31
+ <driver name='qemu' type='qcow2' cache='default'/>
32
+ <source file='/var/lib/libvirt/images/vagrant-test_default_1.img'/>
33
+ <target dev='vdb' bus='virtio'/>
34
+ </disk>
35
+ <disk type='file' device='disk'>
36
+ <driver name='qemu' type='qcow2' cache='default'/>
37
+ <source file='/var/lib/libvirt/images/vagrant-test_default_2.img'/>
38
+ <target dev='vdc' 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/vagrant-test_default-vdd.qcow2'/>
43
+ <target dev='vdd' bus='virtio'/>
44
+ </disk>
45
+ <disk type='file' device='disk'>
46
+ <driver name='qemu' type='qcow2' cache='default'/>
47
+ <source file='/var/lib/libvirt/images/vagrant-test_default-vde.qcow2'/>
48
+ <target dev='vde' bus='virtio'/>
49
+ </disk>
50
+ <disk type='file' device='disk'>
51
+ <driver name='qemu' type='qcow2' cache='default'/>
52
+ <source file='/var/lib/libvirt/images/vagrant-test_default-vdf.qcow2'/>
53
+ <target dev='vdf' bus='virtio'/>
54
+ </disk>
55
+ <serial type='pty'>
56
+ <target port='0'/>
57
+ </serial>
58
+ <console type='pty'>
59
+ <target port='0'/>
60
+ </console>
61
+ <input type='mouse' bus='ps2'/>
62
+ <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' keymap='en-us'/>
63
+ <video>
64
+ <model type='cirrus' vram='16384' heads='1'/>
65
+ </video>
66
+ </devices>
67
+ </domain>
@@ -0,0 +1,67 @@
1
+ <domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
2
+ <name>vagrant-test_default</name>
3
+ <title></title>
4
+ <description>Source: /rootpath/Vagrantfile</description>
5
+ <uuid></uuid>
6
+ <memory>524288</memory>
7
+ <vcpu>1</vcpu>
8
+ <cpu mode='host-model'>
9
+ <model fallback='allow'></model>
10
+ </cpu>
11
+ <os>
12
+ <type>hvm</type>
13
+ <kernel></kernel>
14
+ <initrd></initrd>
15
+ <cmdline></cmdline>
16
+ </os>
17
+ <features>
18
+ <acpi/>
19
+ <apic/>
20
+ <pae/>
21
+ </features>
22
+ <clock offset='utc'>
23
+ </clock>
24
+ <devices>
25
+ <disk type='file' device='disk'>
26
+ <alias name='ua-box-volume-0'/>
27
+ <driver name='qemu' type='qcow2' cache='default'/>
28
+ <source file='/var/lib/libvirt/images/vagrant-test_default.img'/>
29
+ <target dev='vda' bus='virtio'/>
30
+ </disk>
31
+ <disk type='file' device='disk'>
32
+ <alias name='ua-box-volume-1'/>
33
+ <driver name='qemu' type='qcow2' cache='default'/>
34
+ <source file='/var/lib/libvirt/images/vagrant-test_default_1.img'/>
35
+ <target dev='vdb' bus='virtio'/>
36
+ </disk>
37
+ <disk type='file' device='disk'>
38
+ <alias name='ua-box-volume-2'/>
39
+ <driver name='qemu' type='qcow2' cache='default'/>
40
+ <source file='/var/lib/libvirt/images/vagrant-test_default_2.img'/>
41
+ <target dev='vdc' bus='virtio'/>
42
+ </disk>
43
+ <disk type='file' device='disk'>
44
+ <alias name='ua-disk-volume-0'/>
45
+ <driver name='qemu' type='qcow2' cache='default'/>
46
+ <source file='/var/lib/libvirt/images/vagrant-test_default-vdd.qcow2'/>
47
+ <target dev='vdd' bus='virtio'/>
48
+ </disk>
49
+ <disk type='file' device='disk'>
50
+ <alias name='ua-disk-volume-1'/>
51
+ <driver name='qemu' type='qcow2' cache='default'/>
52
+ <source file='/var/lib/libvirt/images/vagrant-test_default-vde.qcow2'/>
53
+ <target dev='vde' bus='virtio'/>
54
+ </disk>
55
+ <serial type='pty'>
56
+ <target port='0'/>
57
+ </serial>
58
+ <console type='pty'>
59
+ <target port='0'/>
60
+ </console>
61
+ <input type='mouse' bus='ps2'/>
62
+ <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' keymap='en-us'/>
63
+ <video>
64
+ <model type='cirrus' vram='16384' heads='1'/>
65
+ </video>
66
+ </devices>
67
+ </domain>