fog-libvirt 0.5.0 → 0.9.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 +5 -5
- data/README.md +1 -1
- data/fog-libvirt.gemspec +3 -3
- data/lib/fog/bin/libvirt.rb +1 -1
- data/lib/fog/libvirt.rb +1 -3
- data/lib/fog/libvirt/compute.rb +12 -11
- data/lib/fog/libvirt/models/compute/README.md +16 -0
- data/lib/fog/libvirt/models/compute/interface.rb +2 -2
- data/lib/fog/libvirt/models/compute/interfaces.rb +3 -3
- data/lib/fog/libvirt/models/compute/network.rb +3 -3
- data/lib/fog/libvirt/models/compute/networks.rb +3 -3
- data/lib/fog/libvirt/models/compute/nic.rb +2 -2
- data/lib/fog/libvirt/models/compute/nics.rb +3 -3
- data/lib/fog/libvirt/models/compute/node.rb +2 -2
- data/lib/fog/libvirt/models/compute/nodes.rb +3 -3
- data/lib/fog/libvirt/models/compute/pool.rb +2 -2
- data/lib/fog/libvirt/models/compute/pools.rb +3 -3
- data/lib/fog/libvirt/models/compute/server.rb +23 -8
- data/lib/fog/libvirt/models/compute/servers.rb +3 -3
- data/lib/fog/libvirt/models/compute/templates/server.xml.erb +65 -0
- data/lib/fog/libvirt/models/compute/templates/volume.xml.erb +8 -4
- data/lib/fog/libvirt/models/compute/util/uri.rb +2 -2
- data/lib/fog/libvirt/models/compute/util/util.rb +2 -2
- data/lib/fog/libvirt/models/compute/volume.rb +11 -9
- data/lib/fog/libvirt/models/compute/volumes.rb +3 -3
- data/lib/fog/libvirt/requests/compute/clone_volume.rb +3 -3
- data/lib/fog/libvirt/requests/compute/create_domain.rb +2 -2
- data/lib/fog/libvirt/requests/compute/create_volume.rb +2 -2
- data/lib/fog/libvirt/requests/compute/define_domain.rb +2 -2
- data/lib/fog/libvirt/requests/compute/define_pool.rb +2 -2
- data/lib/fog/libvirt/requests/compute/destroy_interface.rb +2 -2
- data/lib/fog/libvirt/requests/compute/destroy_network.rb +2 -2
- data/lib/fog/libvirt/requests/compute/dhcp_leases.rb +2 -2
- data/lib/fog/libvirt/requests/compute/get_node_info.rb +2 -2
- data/lib/fog/libvirt/requests/compute/libversion.rb +2 -2
- data/lib/fog/libvirt/requests/compute/list_domains.rb +9 -3
- data/lib/fog/libvirt/requests/compute/list_interfaces.rb +2 -2
- data/lib/fog/libvirt/requests/compute/list_networks.rb +11 -3
- data/lib/fog/libvirt/requests/compute/list_pool_volumes.rb +2 -2
- data/lib/fog/libvirt/requests/compute/list_pools.rb +2 -2
- data/lib/fog/libvirt/requests/compute/list_volumes.rb +16 -8
- data/lib/fog/libvirt/requests/compute/pool_action.rb +2 -2
- data/lib/fog/libvirt/requests/compute/update_autostart.rb +18 -0
- data/lib/fog/libvirt/requests/compute/update_display.rb +2 -2
- data/lib/fog/libvirt/requests/compute/upload_volume.rb +2 -2
- data/lib/fog/libvirt/requests/compute/vm_action.rb +2 -2
- data/lib/fog/libvirt/requests/compute/volume_action.rb +2 -2
- data/lib/fog/libvirt/version.rb +1 -1
- data/minitests/server/server_test.rb +1 -1
- data/minitests/server/user_data_iso_test.rb +8 -11
- data/minitests/test_helper.rb +1 -1
- data/tests/helper.rb +1 -1
- data/tests/helpers/formats_helper.rb +58 -56
- data/tests/helpers/formats_helper_tests.rb +22 -25
- data/tests/helpers/mock_helper.rb +1 -1
- data/tests/helpers/succeeds_helper.rb +2 -2
- data/tests/libvirt/compute_tests.rb +2 -1
- data/tests/libvirt/models/compute/interface_tests.rb +1 -1
- data/tests/libvirt/models/compute/interfaces_tests.rb +1 -1
- data/tests/libvirt/models/compute/network_tests.rb +1 -1
- data/tests/libvirt/models/compute/networks_tests.rb +1 -1
- data/tests/libvirt/models/compute/nic_tests.rb +1 -1
- data/tests/libvirt/models/compute/pool_tests.rb +1 -1
- data/tests/libvirt/models/compute/pools_tests.rb +1 -1
- data/tests/libvirt/models/compute/server_tests.rb +4 -1
- data/tests/libvirt/models/compute/servers_tests.rb +1 -1
- data/tests/libvirt/models/compute/volume_tests.rb +1 -1
- data/tests/libvirt/models/compute/volumes_tests.rb +2 -1
- data/tests/libvirt/requests/compute/update_autostart_tests.rb +12 -0
- metadata +12 -16
@@ -5,8 +5,12 @@
|
|
5
5
|
<target>
|
6
6
|
<format type="<%= format_type %>"/>
|
7
7
|
<permissions>
|
8
|
-
|
9
|
-
<
|
8
|
+
<% if owner -%>
|
9
|
+
<owner><%= owner %></owner>
|
10
|
+
<% end -%>
|
11
|
+
<% if group -%>
|
12
|
+
<group><%= group %></group>
|
13
|
+
<% end -%>
|
10
14
|
<mode>0744</mode>
|
11
15
|
<label>virt_image_t</label>
|
12
16
|
</permissions>
|
@@ -16,8 +20,8 @@
|
|
16
20
|
<path><%= backing_volume.path %></path>
|
17
21
|
<format type="<%= backing_volume.format_type %>"/>
|
18
22
|
<permissions>
|
19
|
-
<owner
|
20
|
-
<group
|
23
|
+
<owner><%= owner %></owner>
|
24
|
+
<group><%= group %></group>
|
21
25
|
<mode>0744</mode>
|
22
26
|
<label>virt_image_t</label>
|
23
27
|
</permissions>
|
@@ -4,8 +4,8 @@ require 'ostruct'
|
|
4
4
|
require 'securerandom'
|
5
5
|
|
6
6
|
module Fog
|
7
|
-
module
|
8
|
-
module
|
7
|
+
module Libvirt
|
8
|
+
module Util
|
9
9
|
def xml_element(xml, path, attribute=nil)
|
10
10
|
xml = Nokogiri::XML(xml)
|
11
11
|
attribute.nil? ? (xml/path).first.text : (xml/path).first[attribute.to_sym]
|
@@ -2,11 +2,11 @@ require 'fog/core/model'
|
|
2
2
|
require 'fog/libvirt/models/compute/util/util'
|
3
3
|
|
4
4
|
module Fog
|
5
|
-
module
|
6
|
-
class
|
5
|
+
module Libvirt
|
6
|
+
class Compute
|
7
7
|
class Volume < Fog::Model
|
8
8
|
attr_reader :xml
|
9
|
-
include Fog::
|
9
|
+
include Fog::Libvirt::Util
|
10
10
|
|
11
11
|
identity :id, :aliases => 'key'
|
12
12
|
|
@@ -16,6 +16,8 @@ module Fog
|
|
16
16
|
attribute :path
|
17
17
|
attribute :capacity
|
18
18
|
attribute :allocation
|
19
|
+
attribute :owner
|
20
|
+
attribute :group
|
19
21
|
attribute :format_type
|
20
22
|
attribute :backing_volume
|
21
23
|
|
@@ -106,18 +108,18 @@ module Fog
|
|
106
108
|
:name => randomized_name,
|
107
109
|
:capacity => "10G",
|
108
110
|
:allocation => "1G",
|
111
|
+
:owner => nil,
|
112
|
+
:group => nil,
|
109
113
|
}
|
110
114
|
end
|
111
115
|
|
112
116
|
def split_size_unit(text)
|
113
|
-
if text.kind_of?
|
114
|
-
# if text is an integer, match will fail
|
115
|
-
size = text
|
116
|
-
unit = 'G'
|
117
|
-
else
|
118
|
-
matcher = text.match(/(\d+)(.+)/)
|
117
|
+
if (text.kind_of? String) && (matcher = text.match(/(\d+)(.+)/))
|
119
118
|
size = matcher[1]
|
120
119
|
unit = matcher[2]
|
120
|
+
else
|
121
|
+
size = text.to_i
|
122
|
+
unit = "G"
|
121
123
|
end
|
122
124
|
[size, unit]
|
123
125
|
end
|
@@ -2,10 +2,10 @@ require 'fog/core/collection'
|
|
2
2
|
require 'fog/libvirt/models/compute/volume'
|
3
3
|
|
4
4
|
module Fog
|
5
|
-
module
|
6
|
-
class
|
5
|
+
module Libvirt
|
6
|
+
class Compute
|
7
7
|
class Volumes < Fog::Collection
|
8
|
-
model Fog::Compute::
|
8
|
+
model Fog::Libvirt::Compute::Volume
|
9
9
|
|
10
10
|
def all(filter = {})
|
11
11
|
load(service.list_volumes(filter))
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Fog
|
2
|
-
module
|
3
|
-
class
|
2
|
+
module Libvirt
|
3
|
+
class Compute
|
4
4
|
class Real
|
5
5
|
def clone_volume (pool_name, xml, name)
|
6
6
|
vol = client.lookup_storage_pool_by_name(pool_name).lookup_volume_by_name(name)
|
@@ -10,7 +10,7 @@ module Fog
|
|
10
10
|
|
11
11
|
class Mock
|
12
12
|
def clone_volume(pool_name, xml, name)
|
13
|
-
Fog::Compute::
|
13
|
+
Fog::Libvirt::Compute::Volume.new({:pool_name => pool_name, :xml => xml})
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Fog
|
2
|
-
module
|
3
|
-
class
|
2
|
+
module Libvirt
|
3
|
+
class Compute
|
4
4
|
class Real
|
5
5
|
def list_domains(filter = { })
|
6
6
|
data=[]
|
@@ -39,7 +39,13 @@ module Fog
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def domain_volumes xml
|
42
|
-
xml_elements(xml, "domain/devices/disk/source", "file")
|
42
|
+
vols_by_file = xml_elements(xml, "domain/devices/disk/source", "file")
|
43
|
+
vols_by_name = xml_elements(xml, "domain/devices/disk/source", "name")
|
44
|
+
vols = []
|
45
|
+
vols_by_file.zip(vols_by_name).each do |by_file,by_name|
|
46
|
+
vols.push(by_file.nil? ? by_name : by_file)
|
47
|
+
end
|
48
|
+
vols
|
43
49
|
end
|
44
50
|
|
45
51
|
def boot_order xml
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Fog
|
2
|
-
module
|
3
|
-
class
|
2
|
+
module Libvirt
|
3
|
+
class Compute
|
4
4
|
class Real
|
5
5
|
def list_networks(filter = { })
|
6
6
|
data=[]
|
@@ -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
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Fog
|
2
|
-
module
|
3
|
-
class
|
2
|
+
module Libvirt
|
3
|
+
class Compute
|
4
4
|
class Real
|
5
5
|
def list_volumes(filter = { })
|
6
6
|
data = []
|
@@ -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