vagrant-libvirt 0.0.41 → 0.0.42
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.
- checksums.yaml +4 -4
- data/.coveralls.yml +1 -0
- data/.github/issue_template.md +37 -0
- data/.gitignore +21 -0
- data/.travis.yml +24 -0
- data/Gemfile +26 -0
- data/LICENSE +22 -0
- data/README.md +1380 -0
- data/Rakefile +8 -0
- data/example_box/README.md +29 -0
- data/example_box/Vagrantfile +60 -0
- data/example_box/metadata.json +5 -0
- data/lib/vagrant-libvirt.rb +29 -0
- data/lib/vagrant-libvirt/action.rb +370 -0
- data/lib/vagrant-libvirt/action/create_domain.rb +322 -0
- data/lib/vagrant-libvirt/action/create_domain_volume.rb +87 -0
- data/lib/vagrant-libvirt/action/create_network_interfaces.rb +302 -0
- data/lib/vagrant-libvirt/action/create_networks.rb +361 -0
- data/lib/vagrant-libvirt/action/destroy_domain.rb +83 -0
- data/lib/vagrant-libvirt/action/destroy_networks.rb +95 -0
- data/lib/vagrant-libvirt/action/forward_ports.rb +227 -0
- data/lib/vagrant-libvirt/action/halt_domain.rb +41 -0
- data/lib/vagrant-libvirt/action/handle_box_image.rb +156 -0
- data/lib/vagrant-libvirt/action/handle_storage_pool.rb +57 -0
- data/lib/vagrant-libvirt/action/is_created.rb +18 -0
- data/lib/vagrant-libvirt/action/is_running.rb +21 -0
- data/lib/vagrant-libvirt/action/is_suspended.rb +42 -0
- data/lib/vagrant-libvirt/action/message_already_created.rb +16 -0
- data/lib/vagrant-libvirt/action/message_not_created.rb +16 -0
- data/lib/vagrant-libvirt/action/message_not_running.rb +16 -0
- data/lib/vagrant-libvirt/action/message_not_suspended.rb +16 -0
- data/lib/vagrant-libvirt/action/message_will_not_destroy.rb +17 -0
- data/lib/vagrant-libvirt/action/package_domain.rb +105 -0
- data/lib/vagrant-libvirt/action/prepare_nfs_settings.rb +94 -0
- data/lib/vagrant-libvirt/action/prepare_nfs_valid_ids.rb +17 -0
- data/lib/vagrant-libvirt/action/prune_nfs_exports.rb +27 -0
- data/lib/vagrant-libvirt/action/read_mac_addresses.rb +40 -0
- data/lib/vagrant-libvirt/action/remove_libvirt_image.rb +20 -0
- data/lib/vagrant-libvirt/action/remove_stale_volume.rb +50 -0
- data/lib/vagrant-libvirt/action/resume_domain.rb +34 -0
- data/lib/vagrant-libvirt/action/set_boot_order.rb +109 -0
- data/lib/vagrant-libvirt/action/set_name_of_domain.rb +64 -0
- data/lib/vagrant-libvirt/action/share_folders.rb +71 -0
- data/lib/vagrant-libvirt/action/start_domain.rb +307 -0
- data/lib/vagrant-libvirt/action/suspend_domain.rb +40 -0
- data/lib/vagrant-libvirt/action/wait_till_up.rb +109 -0
- data/lib/vagrant-libvirt/cap/mount_p9.rb +42 -0
- data/lib/vagrant-libvirt/cap/nic_mac_addresses.rb +17 -0
- data/lib/vagrant-libvirt/cap/synced_folder.rb +113 -0
- data/lib/vagrant-libvirt/config.rb +746 -0
- data/lib/vagrant-libvirt/driver.rb +118 -0
- data/lib/vagrant-libvirt/errors.rb +153 -0
- data/lib/vagrant-libvirt/plugin.rb +92 -0
- data/lib/vagrant-libvirt/provider.rb +130 -0
- data/lib/vagrant-libvirt/templates/default_storage_pool.xml.erb +13 -0
- data/lib/vagrant-libvirt/templates/domain.xml.erb +244 -0
- data/lib/vagrant-libvirt/templates/private_network.xml.erb +42 -0
- data/lib/vagrant-libvirt/templates/public_interface.xml.erb +26 -0
- data/lib/vagrant-libvirt/util.rb +11 -0
- data/lib/vagrant-libvirt/util/collection.rb +19 -0
- data/lib/vagrant-libvirt/util/erb_template.rb +22 -0
- data/lib/vagrant-libvirt/util/error_codes.rb +100 -0
- data/lib/vagrant-libvirt/util/network_util.rb +151 -0
- data/lib/vagrant-libvirt/util/timer.rb +17 -0
- data/lib/vagrant-libvirt/version.rb +5 -0
- data/locales/en.yml +162 -0
- data/spec/spec_helper.rb +9 -0
- data/spec/support/environment_helper.rb +46 -0
- data/spec/support/libvirt_context.rb +30 -0
- data/spec/support/sharedcontext.rb +34 -0
- data/spec/unit/action/destroy_domain_spec.rb +97 -0
- data/spec/unit/action/set_name_of_domain_spec.rb +21 -0
- data/spec/unit/action/wait_till_up_spec.rb +127 -0
- data/spec/unit/config_spec.rb +113 -0
- data/spec/unit/templates/domain_all_settings.xml +137 -0
- data/spec/unit/templates/domain_defaults.xml +46 -0
- data/spec/unit/templates/domain_spec.rb +84 -0
- data/tools/create_box.sh +130 -0
- data/tools/prepare_redhat_for_box.sh +119 -0
- data/vagrant-libvirt.gemspec +54 -0
- metadata +93 -3
@@ -0,0 +1,244 @@
|
|
1
|
+
<domain type='<%= @domain_type %>' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
|
2
|
+
<name><%= @name %></name>
|
3
|
+
<uuid><%= @uuid %></uuid>
|
4
|
+
<memory><%= @memory_size %></memory>
|
5
|
+
<vcpu><%= @cpus %></vcpu>
|
6
|
+
|
7
|
+
|
8
|
+
<cpu mode='<%= @cpu_mode %>'>
|
9
|
+
<% if @cpu_mode != 'host-passthrough' %>
|
10
|
+
<model fallback='<%= @cpu_fallback %>'><% if @cpu_mode == 'custom' %><%= @cpu_model %><% end %></model>
|
11
|
+
<% if @nested %>
|
12
|
+
<feature policy='optional' name='vmx'/>
|
13
|
+
<feature policy='optional' name='svm'/>
|
14
|
+
<% end %>
|
15
|
+
<% @cpu_features.each do |cpu_feature| %>
|
16
|
+
<feature name='<%= cpu_feature[:name] %>' policy='<%= cpu_feature[:policy] %>'/>
|
17
|
+
<% end %>
|
18
|
+
<% unless @cpu_topology.empty? %>
|
19
|
+
<%# CPU topology -%>
|
20
|
+
<topology sockets='<%= @cpu_topology[:sockets] %>' cores='<%= @cpu_topology[:cores] %>' threads='<%= @cpu_topology[:threads] %>'/>
|
21
|
+
<% end %>
|
22
|
+
<% end %>
|
23
|
+
<% if @numa_nodes %>
|
24
|
+
<numa>
|
25
|
+
<% @numa_nodes.each_with_index do |node, index| %>
|
26
|
+
<cell id='<%= index %>' cpus='<%= node[:cpus] %>' memory='<%= node[:memory] %>'/>
|
27
|
+
<% end %>
|
28
|
+
</numa>
|
29
|
+
<% end %>
|
30
|
+
</cpu>
|
31
|
+
|
32
|
+
<% unless @memory_backing.empty? %>
|
33
|
+
<memoryBacking>
|
34
|
+
<% @memory_backing.each do |backing| %>
|
35
|
+
<<%= backing[:name] %> <%= backing[:config].map { |k,v| "#{k}='#{v}'"}.join(' ') %>/>
|
36
|
+
<% end %>
|
37
|
+
</memoryBacking>
|
38
|
+
<% end%>
|
39
|
+
|
40
|
+
<os>
|
41
|
+
<% if @machine_type %>
|
42
|
+
<% if @machine_arch %>
|
43
|
+
<type arch='<%= @machine_arch %>' machine='<%= @machine_type %>'>hvm</type>
|
44
|
+
<% else %>
|
45
|
+
<type machine='<%= @machine_type %>'>hvm</type>
|
46
|
+
<% end %>
|
47
|
+
<% else %>
|
48
|
+
<% if @machine_arch %>
|
49
|
+
<type arch='<%= @machine_arch %>'>hvm</type>
|
50
|
+
<% else %>
|
51
|
+
<type>hvm</type>
|
52
|
+
<% end %>
|
53
|
+
<% end %>
|
54
|
+
<% if @loader %>
|
55
|
+
<loader readonly='yes' type='rom'><%= @loader %></loader>
|
56
|
+
<% end %>
|
57
|
+
<% if @boot_order.count >= 1 %>
|
58
|
+
<bootmenu enable='yes'/>
|
59
|
+
<% end %>
|
60
|
+
<kernel><%= @kernel %></kernel>
|
61
|
+
<initrd><%= @initrd %></initrd>
|
62
|
+
<cmdline><%= @cmd_line %></cmdline>
|
63
|
+
<% if @dtb %>
|
64
|
+
<dtb><%= @dtb %></dtb>
|
65
|
+
<% end %>
|
66
|
+
</os>
|
67
|
+
<features>
|
68
|
+
<% @features.each do |feature| %>
|
69
|
+
<<%= feature %>/>
|
70
|
+
<% end %>
|
71
|
+
<% if @kvm_hidden %>
|
72
|
+
<kvm>
|
73
|
+
<hidden state='on'/>
|
74
|
+
</kvm>
|
75
|
+
<% end %>
|
76
|
+
</features>
|
77
|
+
<clock offset='utc'/>
|
78
|
+
<devices>
|
79
|
+
<% if @emulator_path %>
|
80
|
+
<emulator><%= @emulator_path %></emulator>
|
81
|
+
<% end %>
|
82
|
+
<% if @domain_volume_path %>
|
83
|
+
<disk type='file' device='disk'>
|
84
|
+
<driver name='qemu' type='qcow2' cache='<%= @domain_volume_cache %>'/>
|
85
|
+
<source file='<%= @domain_volume_path %>'/>
|
86
|
+
<%# we need to ensure a unique target dev -%>
|
87
|
+
<target dev='<%= @disk_device %>' bus='<%= @disk_bus %>'/>
|
88
|
+
</disk>
|
89
|
+
<% end %>
|
90
|
+
<%# additional disks -%>
|
91
|
+
<% @disks.each do |d| -%>
|
92
|
+
<disk type='file' device='disk'>
|
93
|
+
<driver name='qemu' type='<%= d[:type] %>' cache='<%= d[:cache] %>'/>
|
94
|
+
<source file='<%= d[:absolute_path] %>'/>
|
95
|
+
<target dev='<%= d[:device] %>' bus='<%= d[:bus] %>'/>
|
96
|
+
<% if d[:shareable] %>
|
97
|
+
<shareable/>
|
98
|
+
<% end %>
|
99
|
+
<% if d[:serial] %>
|
100
|
+
<serial><%= d[:serial] %></serial>
|
101
|
+
<% end %>
|
102
|
+
<%# this will get auto generated by libvirt
|
103
|
+
<address type='pci' domain='0x0000' bus='0x00' slot='???' function='0x0'/>
|
104
|
+
-%>
|
105
|
+
</disk>
|
106
|
+
<% end -%>
|
107
|
+
|
108
|
+
<% @cdroms.each do |c| %>
|
109
|
+
<disk type='file' device='cdrom'>
|
110
|
+
<source file='<%= c[:path] %>'/>
|
111
|
+
<target dev='<%= c[:dev] %>' bus='<%= c[:bus] %>'/>
|
112
|
+
<readonly/>
|
113
|
+
</disk>
|
114
|
+
<% end %>
|
115
|
+
|
116
|
+
<serial type='pty'>
|
117
|
+
<target port='0'/>
|
118
|
+
</serial>
|
119
|
+
<console type='pty'>
|
120
|
+
<target port='0'/>
|
121
|
+
</console>
|
122
|
+
|
123
|
+
<% @channels.each do |channel| %>
|
124
|
+
<channel type='<%= channel[:type] %>' >
|
125
|
+
<%if channel[:source_mode] or channel[:source_path] %>
|
126
|
+
<source
|
127
|
+
<% if channel[:source_mode] %>
|
128
|
+
mode='<%= channel[:source_mode] %>'
|
129
|
+
<% end %>
|
130
|
+
<% if channel[:source_path] %>
|
131
|
+
path="<%= channel[:source_path] %>"
|
132
|
+
<% end %>
|
133
|
+
/>
|
134
|
+
<% end %>
|
135
|
+
<target type='<%= channel[:target_type] %>'
|
136
|
+
<% if channel[:target_name] %>
|
137
|
+
name="<%= channel[:target_name] %>"
|
138
|
+
<% end %>
|
139
|
+
<% if channel[:target_address] %>
|
140
|
+
address="<%= channel[:target_address] %>"
|
141
|
+
<% end %>
|
142
|
+
<% if channel[:target_port] %>
|
143
|
+
port="<%= channel[:target_port] %>"
|
144
|
+
<% end %>
|
145
|
+
/>
|
146
|
+
</channel>
|
147
|
+
<% end %>
|
148
|
+
|
149
|
+
<% @inputs.each do |input| %>
|
150
|
+
<input type='<%= input[:type] %>' bus='<%= input[:bus] %>'/>
|
151
|
+
<% end %>
|
152
|
+
|
153
|
+
<% if !@sound_type.nil? %>
|
154
|
+
<%# Sound device-%>
|
155
|
+
<sound model='<%= @sound_type %>'>
|
156
|
+
</sound>
|
157
|
+
<%# End Sound%>
|
158
|
+
<% end %>
|
159
|
+
<% if @graphics_type != 'none' %>
|
160
|
+
<%# Video device -%>
|
161
|
+
<graphics type='<%= @graphics_type %>' port='<%= @graphics_port %>' autoport='<%= @graphics_autoport %>' listen='<%= @graphics_ip %>' keymap='<%= @keymap %>' <%= @graphics_passwd%> />
|
162
|
+
<video>
|
163
|
+
<model type='<%= @video_type %>' vram='<%= @video_vram %>' heads='1'/>
|
164
|
+
</video>
|
165
|
+
<%#End Video -%>
|
166
|
+
<% end %>
|
167
|
+
<% if @rng[:model] == "random"%>
|
168
|
+
<rng model='virtio'>
|
169
|
+
<backend model='random'>/dev/random</backend>
|
170
|
+
</rng>
|
171
|
+
<% end %>
|
172
|
+
<% @pcis.each do |pci| %>
|
173
|
+
<hostdev mode='subsystem' type='pci' managed='yes'>
|
174
|
+
<source>
|
175
|
+
<address domain='0x0000'
|
176
|
+
bus='<%= pci[:bus] %>'
|
177
|
+
slot='<%= pci[:slot] %>'
|
178
|
+
function='<%= pci[:function] %>'/>
|
179
|
+
</source>
|
180
|
+
</hostdev>
|
181
|
+
<% end %>
|
182
|
+
<% @usbs.each do |usb| %>
|
183
|
+
<hostdev mode='subsystem' type='usb'>
|
184
|
+
<source startupPolicy='<%= usb[:startupPolicy] || "mandatory" %>'>
|
185
|
+
<% if usb[:vendor] %>
|
186
|
+
<vendor id='<%= usb[:vendor] %>'/>
|
187
|
+
<% end %>
|
188
|
+
<% if usb[:product] %>
|
189
|
+
<product id='<%= usb[:product] %>'/>
|
190
|
+
<% end %>
|
191
|
+
<% if usb[:bus] && usb[:device] %>
|
192
|
+
<address bus='<%= usb[:bus] %>' device='<%= usb[:device] %>'/>
|
193
|
+
<% end %>
|
194
|
+
</source>
|
195
|
+
</hostdev>
|
196
|
+
<% end %>
|
197
|
+
<% unless @redirdevs.empty? %>
|
198
|
+
<% @redirdevs.each do |redirdev| %>
|
199
|
+
<redirdev bus='usb' type='<%= redirdev[:type] %>'>
|
200
|
+
</redirdev>
|
201
|
+
<% end %>
|
202
|
+
<% unless @redirfilters.empty? %>
|
203
|
+
<redirfilter>
|
204
|
+
<% @redirfilters.each do |usbdev| %>
|
205
|
+
<usbdev class='<%= usbdev[:class] %>' vendor='<%= usbdev[:vendor] %>' product='<%= usbdev[:product] %>' version='<%= usbdev[:version] %>' allow='<%= usbdev[:allow] %>'/>
|
206
|
+
<% end %>
|
207
|
+
</redirfilter>
|
208
|
+
<% end %>
|
209
|
+
<% end %>
|
210
|
+
<% unless @watchdog_dev.empty? %>
|
211
|
+
<%# Watchdog Device -%>
|
212
|
+
<watchdog model='<%= @watchdog_dev[:model] %>' action='<%= @watchdog_dev[:action] %>'/>
|
213
|
+
<% end %>
|
214
|
+
|
215
|
+
<% unless @smartcard_dev.empty? -%>
|
216
|
+
<% if @smartcard_dev[:mode] == 'passthrough' %>
|
217
|
+
<% if @smartcard_dev[:type] == 'tcp' %>
|
218
|
+
<smartcard mode='<%= @smartcard_dev[:mode] %>' type='<%= @smartcard_dev[:type] %>'>
|
219
|
+
<source mode='<%= @smartcard_dev[:source_mode] %>' host='<%= @smartcard_dev[:source_host] %>' service='<%= @smartcard_dev[:source_service] %>'/>
|
220
|
+
</smartcard>
|
221
|
+
<% else %>
|
222
|
+
<smartcard mode='<%= @smartcard_dev[:mode] %>' type='<%= @smartcard_dev[:type] %>'/>
|
223
|
+
<% end %>
|
224
|
+
<% end %>
|
225
|
+
<% end -%>
|
226
|
+
|
227
|
+
<% if @tpm_path -%>
|
228
|
+
<%# TPM Device -%>
|
229
|
+
<tpm model='<%= @tpm_model %>'>
|
230
|
+
<backend type='<%= @tpm_type %>'>
|
231
|
+
<device path='<%= @tpm_path %>'/>
|
232
|
+
</backend>
|
233
|
+
</tpm>
|
234
|
+
<% end -%>
|
235
|
+
</devices>
|
236
|
+
|
237
|
+
<% unless @qargs.empty? %>
|
238
|
+
<qemu:commandline>
|
239
|
+
<% @qargs.each do |arg| %>
|
240
|
+
<qemu:arg value='<%= arg[:value] %>'/>
|
241
|
+
<% end %>
|
242
|
+
</qemu:commandline>
|
243
|
+
<% end %>
|
244
|
+
</domain>
|
@@ -0,0 +1,42 @@
|
|
1
|
+
<network ipv6='<%= @guest_ipv6 %>'>
|
2
|
+
<name><%= @network_name %></name>
|
3
|
+
<bridge name="<%= @network_bridge_name %>" />
|
4
|
+
|
5
|
+
<% if @network_domain_name %>
|
6
|
+
<domain name="<%= @network_domain_name %>" localOnly="yes" />
|
7
|
+
<% end %>
|
8
|
+
|
9
|
+
<% if @network_mtu %>
|
10
|
+
<mtu size="<%= @network_mtu %>" />
|
11
|
+
<% end %>
|
12
|
+
|
13
|
+
<% if (@network_forward_mode != 'none' && @network_forward_mode != 'veryisolated') %>
|
14
|
+
<% if @network_forward_device %>
|
15
|
+
<forward mode="<%= @network_forward_mode %>" dev="<%= @network_forward_device %>" />
|
16
|
+
<% else %>
|
17
|
+
<forward mode="<%= @network_forward_mode %>" />
|
18
|
+
<% end %>
|
19
|
+
<% end %>
|
20
|
+
|
21
|
+
<% if @network_forward_mode != 'veryisolated' %>
|
22
|
+
<ip address="<%= @network_address %>" netmask="<%= @network_netmask %>">
|
23
|
+
<% if @network_dhcp_enabled %>
|
24
|
+
<dhcp>
|
25
|
+
<range start="<%= @network_range_start %>" end="<%= @network_range_stop %>" />
|
26
|
+
<% if @network_dhcp_bootp_file %>
|
27
|
+
<% if @network_dhcp_bootp_server %>
|
28
|
+
<bootp file="<%= @network_dhcp_bootp_file %>" server="<%= @network_dhcp_bootp_server %>" />
|
29
|
+
<% else %>
|
30
|
+
<bootp file="<%= @network_dhcp_bootp_file %>" />
|
31
|
+
<% end %>
|
32
|
+
<% end %>
|
33
|
+
</dhcp>
|
34
|
+
<% end %>
|
35
|
+
</ip>
|
36
|
+
<% end %>
|
37
|
+
|
38
|
+
<% if !@network_ipv6_address.nil? && !@network_ipv6_prefix.nil? %>
|
39
|
+
<ip family='ipv6' address="<%= @network_ipv6_address %>" prefix="<%= @network_ipv6_prefix %>"></ip>
|
40
|
+
<% end %>
|
41
|
+
|
42
|
+
</network>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<interface type='<%= @type %>'<% if @trust_guest_rx_filters %> trustGuestRxFilters='yes'<% end %>>
|
2
|
+
<% if @mac %>
|
3
|
+
<mac address='<%= @mac %>'/>
|
4
|
+
<% end %>
|
5
|
+
<%if @type == 'direct'%>
|
6
|
+
<source dev='<%= @device %>' mode='<%= @mode %>'/>
|
7
|
+
<% elsif !@portgroup.nil? %>
|
8
|
+
<source network='<%=@network_name%>' portgroup='<%=@portgroup%>'/>
|
9
|
+
<% else %>
|
10
|
+
<source bridge='<%=@device%>'/>
|
11
|
+
<% end %>
|
12
|
+
<model type='<%=@model_type%>'/>
|
13
|
+
<% if @driver_name and @driver_queues %>
|
14
|
+
<driver name='<%=@driver_name%>' queues='<%=@driver_queues%>'/>
|
15
|
+
<% elsif @driver_queues %>
|
16
|
+
<driver queues='<%=@driver_queues%>'/>
|
17
|
+
<% elsif @driver_name %>
|
18
|
+
<driver name='<%=@driver_name%>'/>
|
19
|
+
<% end %>
|
20
|
+
<% if @ovs %>
|
21
|
+
<virtualport type='openvswitch'/>
|
22
|
+
<% end %>
|
23
|
+
<% if @pci_bus and @pci_slot %>
|
24
|
+
<address type='pci' bus='<%=@pci_bus%>' slot='<%=@pci_slot%>' />
|
25
|
+
<% end %>
|
26
|
+
</interface>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module ProviderLibvirt
|
3
|
+
module Util
|
4
|
+
autoload :ErbTemplate, 'vagrant-libvirt/util/erb_template'
|
5
|
+
autoload :Collection, 'vagrant-libvirt/util/collection'
|
6
|
+
autoload :Timer, 'vagrant-libvirt/util/timer'
|
7
|
+
autoload :NetworkUtil, 'vagrant-libvirt/util/network_util'
|
8
|
+
autoload :ErrorCodes, 'vagrant-libvirt/util/error_codes'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module ProviderLibvirt
|
3
|
+
module Util
|
4
|
+
module Collection
|
5
|
+
# This method finds a matching _thing_ in a collection of
|
6
|
+
# _things_. This works matching if the ID or NAME equals to
|
7
|
+
# `name`. Or, if `name` is a regexp, a partial match is chosen
|
8
|
+
# as well.
|
9
|
+
def self.find_matching(collection, name)
|
10
|
+
collection.each do |single|
|
11
|
+
return single if single.name == name
|
12
|
+
end
|
13
|
+
|
14
|
+
nil
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'erubis'
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module ProviderLibvirt
|
5
|
+
module Util
|
6
|
+
module ErbTemplate
|
7
|
+
# TODO: remove and use nokogiri builder
|
8
|
+
# TODO: might be a chance to use vagrant template system according to https://github.com/mitchellh/vagrant/issues/3231
|
9
|
+
def to_xml(template_name = nil, data = binding)
|
10
|
+
erb = template_name || self.class.to_s.split('::').last.downcase
|
11
|
+
path = File.join(File.dirname(__FILE__), '..', 'templates',
|
12
|
+
"#{erb}.xml.erb")
|
13
|
+
template = File.read(path)
|
14
|
+
|
15
|
+
# TODO: according to erubis documentation, we should rather use evaluate and forget about
|
16
|
+
# binding since the template may then change variables values
|
17
|
+
Erubis::Eruby.new(template, trim: true).result(data)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
# Ripped from http://libvirt.org/html/libvirt-virterror.html#virErrorNumber.
|
2
|
+
module VagrantPlugins
|
3
|
+
module ProviderLibvirt
|
4
|
+
module Util
|
5
|
+
module ErrorCodes
|
6
|
+
VIR_ERR_OK = 0
|
7
|
+
VIR_ERR_INTERNAL_ERROR = 1 # internal error
|
8
|
+
VIR_ERR_NO_MEMORY = 2 # memory allocation failure
|
9
|
+
VIR_ERR_NO_SUPPORT = 3 # no support for this function
|
10
|
+
VIR_ERR_UNKNOWN_HOST = 4 # could not resolve hostname
|
11
|
+
VIR_ERR_NO_CONNECT = 5 # can't connect to hypervisor
|
12
|
+
VIR_ERR_INVALID_CONN = 6 # invalid connection object
|
13
|
+
VIR_ERR_INVALID_DOMAIN = 7 # invalid domain object
|
14
|
+
VIR_ERR_INVALID_ARG = 8 # invalid function argument
|
15
|
+
VIR_ERR_OPERATION_FAILED = 9 # a command to hypervisor failed
|
16
|
+
VIR_ERR_GET_FAILED = 10 # a HTTP GET command to failed
|
17
|
+
VIR_ERR_POST_FAILED = 11 # a HTTP POST command to failed
|
18
|
+
VIR_ERR_HTTP_ERROR = 12 # unexpected HTTP error code
|
19
|
+
VIR_ERR_SEXPR_SERIAL = 13 # failure to serialize an S-Expr
|
20
|
+
VIR_ERR_NO_XEN = 14 # could not open Xen hypervisor control
|
21
|
+
VIR_ERR_XEN_CALL = 15 # failure doing an hypervisor call
|
22
|
+
VIR_ERR_OS_TYPE = 16 # unknown OS type
|
23
|
+
VIR_ERR_NO_KERNEL = 17 # missing kernel information
|
24
|
+
VIR_ERR_NO_ROOT = 18 # missing root device information
|
25
|
+
VIR_ERR_NO_SOURCE = 19 # missing source device information
|
26
|
+
VIR_ERR_NO_TARGET = 20 # missing target device information
|
27
|
+
VIR_ERR_NO_NAME = 21 # missing domain name information
|
28
|
+
VIR_ERR_NO_OS = 22 # missing domain OS information
|
29
|
+
VIR_ERR_NO_DEVICE = 23 # missing domain devices information
|
30
|
+
VIR_ERR_NO_XENSTORE = 24 # could not open Xen Store control
|
31
|
+
VIR_ERR_DRIVER_FULL = 25 # too many drivers registered
|
32
|
+
VIR_ERR_CALL_FAILED = 26 # not supported by the drivers (DEPRECATED)
|
33
|
+
VIR_ERR_XML_ERROR = 27 # an XML description is not well formed or broken
|
34
|
+
VIR_ERR_DOM_EXIST = 28 # the domain already exist
|
35
|
+
VIR_ERR_OPERATION_DENIED = 29 # operation forbidden on read-only connections
|
36
|
+
VIR_ERR_OPEN_FAILED = 30 # failed to open a conf file
|
37
|
+
VIR_ERR_READ_FAILED = 31 # failed to read a conf file
|
38
|
+
VIR_ERR_PARSE_FAILED = 32 # failed to parse a conf file
|
39
|
+
VIR_ERR_CONF_SYNTAX = 33 # failed to parse the syntax of a conf file
|
40
|
+
VIR_ERR_WRITE_FAILED = 34 # failed to write a conf file
|
41
|
+
VIR_ERR_XML_DETAIL = 35 # detail of an XML error
|
42
|
+
VIR_ERR_INVALID_NETWORK = 36 # invalid network object
|
43
|
+
VIR_ERR_NETWORK_EXIST = 37 # the network already exist
|
44
|
+
VIR_ERR_SYSTEM_ERROR = 38 # general system call failure
|
45
|
+
VIR_ERR_RPC = 39 # some sort of RPC error
|
46
|
+
VIR_ERR_GNUTLS_ERROR = 40 # error from a GNUTLS call
|
47
|
+
VIR_WAR_NO_NETWORK = 41 # failed to start network
|
48
|
+
VIR_ERR_NO_DOMAIN = 42 # domain not found or unexpectedly disappeared
|
49
|
+
VIR_ERR_NO_NETWORK = 43 # network not found
|
50
|
+
VIR_ERR_INVALID_MAC = 44 # invalid MAC address
|
51
|
+
VIR_ERR_AUTH_FAILED = 45 # authentication failed
|
52
|
+
VIR_ERR_INVALID_STORAGE_POOL = 46 # invalid storage pool object
|
53
|
+
VIR_ERR_INVALID_STORAGE_VOL = 47 # invalid storage vol object
|
54
|
+
VIR_WAR_NO_STORAGE = 48 # failed to start storage
|
55
|
+
VIR_ERR_NO_STORAGE_POOL = 49 # storage pool not found
|
56
|
+
VIR_ERR_NO_STORAGE_VOL = 50 # storage volume not found
|
57
|
+
VIR_WAR_NO_NODE = 51 # failed to start node driver
|
58
|
+
VIR_ERR_INVALID_NODE_DEVICE = 52 # invalid node device object
|
59
|
+
VIR_ERR_NO_NODE_DEVICE = 53 # node device not found
|
60
|
+
VIR_ERR_NO_SECURITY_MODEL = 54 # security model not found
|
61
|
+
VIR_ERR_OPERATION_INVALID = 55 # operation is not applicable at this time
|
62
|
+
VIR_WAR_NO_INTERFACE = 56 # failed to start interface driver
|
63
|
+
VIR_ERR_NO_INTERFACE = 57 # interface driver not running
|
64
|
+
VIR_ERR_INVALID_INTERFACE = 58 # invalid interface object
|
65
|
+
VIR_ERR_MULTIPLE_INTERFACES = 59 # more than one matching interface found
|
66
|
+
VIR_WAR_NO_NWFILTER = 60 # failed to start nwfilter driver
|
67
|
+
VIR_ERR_INVALID_NWFILTER = 61 # invalid nwfilter object
|
68
|
+
VIR_ERR_NO_NWFILTER = 62 # nw filter pool not found
|
69
|
+
VIR_ERR_BUILD_FIREWALL = 63 # nw filter pool not found
|
70
|
+
VIR_WAR_NO_SECRET = 64 # failed to start secret storage
|
71
|
+
VIR_ERR_INVALID_SECRET = 65 # invalid secret
|
72
|
+
VIR_ERR_NO_SECRET = 66 # secret not found
|
73
|
+
VIR_ERR_CONFIG_UNSUPPORTED = 67 # unsupported configuration construct
|
74
|
+
VIR_ERR_OPERATION_TIMEOUT = 68 # timeout occurred during operation
|
75
|
+
VIR_ERR_MIGRATE_PERSIST_FAILED = 69 # a migration worked, but making the VM persist on the dest host failed
|
76
|
+
VIR_ERR_HOOK_SCRIPT_FAILED = 70 # a synchronous hook script failed
|
77
|
+
VIR_ERR_INVALID_DOMAIN_SNAPSHOT = 71 # invalid domain snapshot
|
78
|
+
VIR_ERR_NO_DOMAIN_SNAPSHOT = 72 # domain snapshot not found
|
79
|
+
VIR_ERR_INVALID_STREAM = 73 # stream pointer not valid
|
80
|
+
VIR_ERR_ARGUMENT_UNSUPPORTED = 74 # valid API use but unsupported by the given driver
|
81
|
+
VIR_ERR_STORAGE_PROBE_FAILED = 75 # storage pool probe failed
|
82
|
+
VIR_ERR_STORAGE_POOL_BUILT = 76 # storage pool already built
|
83
|
+
VIR_ERR_SNAPSHOT_REVERT_RISKY = 77 # force was not requested for a risky domain snapshot revert
|
84
|
+
VIR_ERR_OPERATION_ABORTED = 78 # operation on a domain was canceled/aborted by user
|
85
|
+
VIR_ERR_AUTH_CANCELLED = 79 # authentication cancelled
|
86
|
+
VIR_ERR_NO_DOMAIN_METADATA = 80 # The metadata is not present
|
87
|
+
VIR_ERR_MIGRATE_UNSAFE = 81 # Migration is not safe
|
88
|
+
VIR_ERR_OVERFLOW = 82 # integer overflow
|
89
|
+
VIR_ERR_BLOCK_COPY_ACTIVE = 83 # action prevented by block copy job
|
90
|
+
VIR_ERR_OPERATION_UNSUPPORTED = 84 # The requested operation is not supported
|
91
|
+
VIR_ERR_SSH = 85 # error in ssh transport driver
|
92
|
+
VIR_ERR_AGENT_UNRESPONSIVE = 86 # guest agent is unresponsive, not running or not usable
|
93
|
+
VIR_ERR_RESOURCE_BUSY = 87 # resource is already in use
|
94
|
+
VIR_ERR_ACCESS_DENIED = 88 # operation on the object/resource was denied
|
95
|
+
VIR_ERR_DBUS_SERVICE = 89 # error from a dbus service
|
96
|
+
VIR_ERR_STORAGE_VOL_EXIST = 90 # the storage vol already exists
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|