fog-libvirt 0.7.0 → 0.8.0
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/lib/fog/libvirt/compute.rb +1 -0
- data/lib/fog/libvirt/models/compute/README.md +3 -0
- data/lib/fog/libvirt/models/compute/server.rb +11 -3
- data/lib/fog/libvirt/models/compute/templates/server.xml.erb +17 -1
- data/lib/fog/libvirt/requests/compute/list_networks.rb +9 -1
- data/lib/fog/libvirt/requests/compute/list_volumes.rb +14 -6
- data/lib/fog/libvirt/requests/compute/update_autostart.rb +18 -0
- data/lib/fog/libvirt/version.rb +1 -1
- data/tests/libvirt/compute_tests.rb +2 -1
- data/tests/libvirt/models/compute/server_tests.rb +2 -0
- data/tests/libvirt/models/compute/volumes_tests.rb +1 -0
- data/tests/libvirt/requests/compute/update_autostart_tests.rb +12 -0
- metadata +9 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3f3d3db14311de4008b43186334103d78f393b03f30282fc6276c1c5f3a7bd3
|
4
|
+
data.tar.gz: acdeffc9be9ca8fa2d2fe5065616b9c7a14c4415b03359437500cfd7c47f63f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0cb8dbd4c13fd8aa4540e8da830d5853b4507c87795edb3aeb03f644d68d895405e7ed804795b70cf0921fb3a54586f6c912ee67eb52abb4e8e7ee07212bfa6
|
7
|
+
data.tar.gz: 8e0f16895181fc4becbf81a3a08d215b39be6d77414425fd2238b696b313c9fd9931f23ce38af538f109d403e50aa4430fa674266050c3698f703331762cdec5
|
data/lib/fog/libvirt/compute.rb
CHANGED
@@ -35,10 +35,13 @@ port=6789
|
|
35
35
|
libvirt_ceph_pool=rbd_pool_name
|
36
36
|
auth_username=libvirt
|
37
37
|
auth_uuid=uuid_of_libvirt_secret
|
38
|
+
bus_type=virtio
|
38
39
|
```
|
39
40
|
For more recent versions of libvirt which support using the secret by name (`usage` attribute in the `secret` tag),
|
40
41
|
you can also drop `auth_uuid` and specify `auth_usage` instead. If both are specified, `auth_uuid` will be preferred for maximum compatibility.
|
41
42
|
|
43
|
+
The `bus_type` can be set to `virtio` or `scsi`. If it is ommited, the default is `scsi`.
|
44
|
+
|
42
45
|
## Configuration
|
43
46
|
|
44
47
|
The URI can be configured in two ways:
|
@@ -30,6 +30,7 @@ module Fog
|
|
30
30
|
attribute :cpu
|
31
31
|
attribute :hugepages
|
32
32
|
attribute :guest_agent
|
33
|
+
attribute :virtio_rng
|
33
34
|
|
34
35
|
attribute :state
|
35
36
|
|
@@ -77,6 +78,10 @@ module Fog
|
|
77
78
|
action_status
|
78
79
|
end
|
79
80
|
|
81
|
+
def update_autostart(value)
|
82
|
+
service.update_autostart(uuid, value)
|
83
|
+
end
|
84
|
+
|
80
85
|
def mac
|
81
86
|
nics.first.mac if nics && nics.first
|
82
87
|
end
|
@@ -131,9 +136,10 @@ module Fog
|
|
131
136
|
end
|
132
137
|
|
133
138
|
#alias methods
|
134
|
-
alias_method :halt,
|
135
|
-
alias_method :stop,
|
136
|
-
alias_method :active?,
|
139
|
+
alias_method :halt, :poweroff
|
140
|
+
alias_method :stop, :shutdown
|
141
|
+
alias_method :active?, :active
|
142
|
+
alias_method :autostart?, :autostart
|
137
143
|
|
138
144
|
def volumes
|
139
145
|
# lazy loading of volumes
|
@@ -473,6 +479,7 @@ module Fog
|
|
473
479
|
:os_type => "hvm",
|
474
480
|
:arch => "x86_64",
|
475
481
|
:domain_type => "kvm",
|
482
|
+
:autostart => false,
|
476
483
|
:iso_dir => default_iso_dir,
|
477
484
|
:network_interface_type => "network",
|
478
485
|
:network_nat_network => "default",
|
@@ -482,6 +489,7 @@ module Fog
|
|
482
489
|
:cpu => {},
|
483
490
|
:hugepages => false,
|
484
491
|
:guest_agent => true,
|
492
|
+
:virtio_rng => {},
|
485
493
|
}
|
486
494
|
end
|
487
495
|
|
@@ -52,9 +52,11 @@
|
|
52
52
|
<disk type='network' device='disk'>
|
53
53
|
<driver name='qemu' type='<%= vol.format_type %>' cache='writeback' discard='unmap'/>
|
54
54
|
<source protocol='rbd' name='<%= vol.path %>'>
|
55
|
+
<% if args.key?("monitor") -%>
|
55
56
|
<% args["monitor"].split(",").each do |mon| %>
|
56
57
|
<host name='<%= mon %>' port='<%= args["port"] %>'/>
|
57
58
|
<% end %>
|
59
|
+
<% end %>
|
58
60
|
</source>
|
59
61
|
<auth username='<%= args["auth_username"] %>'>
|
60
62
|
<% if args.key?("auth_uuid") -%>
|
@@ -63,7 +65,11 @@
|
|
63
65
|
<secret type='ceph' usage='<%= args["auth_usage"] %>'/>
|
64
66
|
<% end -%>
|
65
67
|
</auth>
|
66
|
-
|
68
|
+
<% if args['bus_type'] == 'virtio' %>
|
69
|
+
<target dev='vd<%= ('a'..'z').to_a[volumes.index(vol)] %>' bus='virtio'/>
|
70
|
+
<% else %>
|
71
|
+
<target dev='sd<%= ('a'..'z').to_a[volumes.index(vol)] %>' bus='scsi'/>
|
72
|
+
<% end %>
|
67
73
|
</disk>
|
68
74
|
<% else %>
|
69
75
|
<disk type='file' device='disk'>
|
@@ -94,6 +100,16 @@
|
|
94
100
|
<target type='virtio' name='org.qemu.guest_agent.0'/>
|
95
101
|
</channel>
|
96
102
|
<% end -%>
|
103
|
+
<rng model='virtio'>
|
104
|
+
<%
|
105
|
+
rng_backend_model = virtio_rng[:backend_model] ? virtio_rng[:backend_model] : 'random'
|
106
|
+
-%>
|
107
|
+
<% if virtio_rng[:backend_path] -%>
|
108
|
+
<backend model='<%= rng_backend_model %>'><%= virtio_rng[:backend_path] %></backend>
|
109
|
+
<% else -%>
|
110
|
+
<backend model='<%= rng_backend_model %>'/>
|
111
|
+
<% end -%>
|
112
|
+
</rng>
|
97
113
|
<serial type='pty'>
|
98
114
|
<target port='0'/>
|
99
115
|
</serial>
|
@@ -25,12 +25,20 @@ module Fog
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
+
# bridge name may not be defined in some networks, we should skip that in such case
|
28
29
|
def network_to_attributes(net)
|
29
30
|
return if net.nil?
|
31
|
+
|
32
|
+
begin
|
33
|
+
bridge_name = net.bridge_name
|
34
|
+
rescue Libvirt::Error
|
35
|
+
bridge_name = ''
|
36
|
+
end
|
37
|
+
|
30
38
|
{
|
31
39
|
:uuid => net.uuid,
|
32
40
|
:name => net.name,
|
33
|
-
:bridge_name =>
|
41
|
+
:bridge_name => bridge_name
|
34
42
|
}
|
35
43
|
end
|
36
44
|
end
|
@@ -17,7 +17,7 @@ module Fog
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
else
|
20
|
-
|
20
|
+
data << get_volume(filter)
|
21
21
|
end
|
22
22
|
data.compact
|
23
23
|
end
|
@@ -69,7 +69,8 @@ module Fog
|
|
69
69
|
return raw ? vol : volume_to_attributes(vol)
|
70
70
|
end
|
71
71
|
end
|
72
|
-
|
72
|
+
|
73
|
+
nil
|
73
74
|
end
|
74
75
|
end
|
75
76
|
|
@@ -77,15 +78,22 @@ module Fog
|
|
77
78
|
def list_volumes(filters={ })
|
78
79
|
vol1 = mock_volume 'vol1'
|
79
80
|
vol2 = mock_volume 'vol2'
|
80
|
-
[vol1, vol2]
|
81
|
+
vols = [vol1, vol2]
|
82
|
+
|
83
|
+
if filters.keys.empty?
|
84
|
+
return vols
|
85
|
+
end
|
86
|
+
|
87
|
+
key = filters.keys.first
|
88
|
+
vols.select { |v| v[key] == filters[key] }
|
81
89
|
end
|
82
90
|
|
83
91
|
def mock_volume name
|
84
92
|
{
|
85
93
|
:pool_name => 'vol.pool.name',
|
86
|
-
:key =>
|
87
|
-
:id =>
|
88
|
-
:path =>
|
94
|
+
:key => "vol.#{name}", # needs to match id
|
95
|
+
:id => "vol.#{name}",
|
96
|
+
:path => "path/to/disk", # used by in mock_files/domain.xml
|
89
97
|
:name => name,
|
90
98
|
:format_type => 'raw',
|
91
99
|
:allocation => 123,
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Fog
|
2
|
+
module Libvirt
|
3
|
+
class Compute
|
4
|
+
class Real
|
5
|
+
def update_autostart(uuid, value)
|
6
|
+
domain = client.lookup_domain_by_uuid(uuid)
|
7
|
+
domain.autostart = value
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class Mock
|
12
|
+
def update_autostart(uuid, value)
|
13
|
+
value
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/fog/libvirt/version.rb
CHANGED
@@ -9,7 +9,8 @@ Shindo.tests('Fog::Compute[:libvirt]', ['libvirt']) do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
tests("Compute requests") do
|
12
|
-
%w{ create_domain create_volume define_domain define_pool destroy_interface destroy_network get_node_info
|
12
|
+
%w{ create_domain create_volume define_domain define_pool destroy_interface destroy_network get_node_info
|
13
|
+
update_autostart list_domains
|
13
14
|
list_interfaces list_networks list_pools list_pool_volumes list_volumes pool_action vm_action volume_action
|
14
15
|
dhcp_leases }.each do |request|
|
15
16
|
test("it should respond to #{request}") { compute.respond_to? request }
|
@@ -5,6 +5,8 @@ Shindo.tests('Fog::Compute[:libvirt] | server model', ['libvirt']) do
|
|
5
5
|
|
6
6
|
tests('The server model should') do
|
7
7
|
tests('have the action') do
|
8
|
+
test('autostart') { server.respond_to? 'autostart' }
|
9
|
+
test('update_autostart') { server.respond_to? 'update_autostart' }
|
8
10
|
test('reload') { server.respond_to? 'reload' }
|
9
11
|
%w{ start stop destroy reboot suspend }.each do |action|
|
10
12
|
test(action) { server.respond_to? action }
|
@@ -9,6 +9,7 @@ Shindo.tests('Fog::Compute[:libvirt] | volumes collection', ['libvirt']) do
|
|
9
9
|
tests('should be able to get a model') do
|
10
10
|
tests('by instance uuid').succeeds { volumes.get volumes.first.id }
|
11
11
|
end
|
12
|
+
test('filtered should be empty') { volumes.all(:name => "does-not-exist").empty? }
|
12
13
|
end
|
13
14
|
|
14
15
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Shindo.tests('Fog::Compute[:libvirt] | update_autostart request', ['libvirt']) do
|
2
|
+
|
3
|
+
servers = Fog::Compute[:libvirt].servers
|
4
|
+
|
5
|
+
tests('The response should') do
|
6
|
+
test('should not be empty') { not servers.empty? }
|
7
|
+
server = servers.first
|
8
|
+
tests('should be false').succeeds { server.autostart == false }
|
9
|
+
server.update_autostart(true)
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fog-libvirt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- geemus (Wesley Beary)
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fog-core
|
@@ -276,6 +276,7 @@ files:
|
|
276
276
|
- lib/fog/libvirt/requests/compute/list_volumes.rb
|
277
277
|
- lib/fog/libvirt/requests/compute/mock_files/domain.xml
|
278
278
|
- lib/fog/libvirt/requests/compute/pool_action.rb
|
279
|
+
- lib/fog/libvirt/requests/compute/update_autostart.rb
|
279
280
|
- lib/fog/libvirt/requests/compute/update_display.rb
|
280
281
|
- lib/fog/libvirt/requests/compute/upload_volume.rb
|
281
282
|
- lib/fog/libvirt/requests/compute/vm_action.rb
|
@@ -305,12 +306,13 @@ files:
|
|
305
306
|
- tests/libvirt/requests/compute/create_domain_tests.rb
|
306
307
|
- tests/libvirt/requests/compute/define_domain_tests.rb
|
307
308
|
- tests/libvirt/requests/compute/dhcp_leases_tests.rb
|
309
|
+
- tests/libvirt/requests/compute/update_autostart_tests.rb
|
308
310
|
- tests/libvirt/requests/compute/update_display.rb
|
309
311
|
homepage: http://github.com/fog/fog-libvirt
|
310
312
|
licenses:
|
311
313
|
- MIT
|
312
314
|
metadata: {}
|
313
|
-
post_install_message:
|
315
|
+
post_install_message:
|
314
316
|
rdoc_options:
|
315
317
|
- "--charset=UTF-8"
|
316
318
|
require_paths:
|
@@ -326,8 +328,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
326
328
|
- !ruby/object:Gem::Version
|
327
329
|
version: '0'
|
328
330
|
requirements: []
|
329
|
-
rubygems_version: 3.
|
330
|
-
signing_key:
|
331
|
+
rubygems_version: 3.1.4
|
332
|
+
signing_key:
|
331
333
|
specification_version: 2
|
332
334
|
summary: Module for the 'fog' gem to support libvirt
|
333
335
|
test_files:
|
@@ -352,4 +354,5 @@ test_files:
|
|
352
354
|
- tests/libvirt/requests/compute/create_domain_tests.rb
|
353
355
|
- tests/libvirt/requests/compute/define_domain_tests.rb
|
354
356
|
- tests/libvirt/requests/compute/dhcp_leases_tests.rb
|
357
|
+
- tests/libvirt/requests/compute/update_autostart_tests.rb
|
355
358
|
- tests/libvirt/requests/compute/update_display.rb
|