fog-ovirt 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/fog/ovirt/compute/v4.rb +9 -2
- data/lib/fog/ovirt/requests/compute/v4/add_volume.rb +5 -5
- data/lib/fog/ovirt/requests/compute/v4/create_vm.rb +20 -8
- data/lib/fog/ovirt/requests/compute/v4/list_clusters.rb +3 -2
- data/lib/fog/ovirt/requests/compute/v4/list_virtual_machines.rb +1 -3
- data/lib/fog/ovirt/requests/compute/v4/list_vm_volumes.rb +10 -6
- data/lib/fog/ovirt/requests/compute/v4/update_vm.rb +1 -1
- data/lib/fog/ovirt/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88ead8cc94b6a7acb2e54a922633619a62e86d54
|
4
|
+
data.tar.gz: 2ced4f951fa5a6950bdf854bbae056437410e26f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8ab39302130b3697d45fc13dfd8693f2b58e00b28d15386654e8e7551633bb8c644bb7fe5c525bb6059620b1b9ecb4ea43c2c9b4681210e1aaaf1b9caefbd59
|
7
|
+
data.tar.gz: c2fe9a22bd7f3821cb226d3afa92eb39c5cdf1ead6d5886d0a49a46745b18eb0e18776d05c015100419995c0b56ff7d14aefc529b4cb08acfb9c3c7d6b1941c3
|
data/README.md
CHANGED
@@ -46,7 +46,7 @@ Version 1.0.2 adds support API V4 as well.
|
|
46
46
|
The first version does not give full support.
|
47
47
|
The supported requests for API V4 are:
|
48
48
|
|
49
|
-
:vm_action, :destroy_vm, :create_vm
|
49
|
+
:vm_action, :destroy_vm, :create_vm, :update_vm (without os changes)
|
50
50
|
:datacenters
|
51
51
|
:storage_domains
|
52
52
|
:list_virtual_machines, :get_virtual_machine
|
data/lib/fog/ovirt/compute/v4.rb
CHANGED
@@ -56,7 +56,7 @@ module Fog
|
|
56
56
|
end
|
57
57
|
|
58
58
|
if key == :provisioned_size
|
59
|
-
opts[:size] = value
|
59
|
+
opts[:size] = value.to_s
|
60
60
|
next
|
61
61
|
end
|
62
62
|
|
@@ -148,7 +148,6 @@ module Fog
|
|
148
148
|
:username => username,
|
149
149
|
:password => password
|
150
150
|
}
|
151
|
-
|
152
151
|
@datacenter = options[:ovirt_datacenter]
|
153
152
|
connection_opts[:ca_file] = options[:ca_file]
|
154
153
|
connection_opts[:ca_certs] = [OpenSSL::X509::Certificate.new(options[:public_key])] if options[:public_key].present?
|
@@ -167,6 +166,7 @@ module Fog
|
|
167
166
|
end
|
168
167
|
|
169
168
|
def datacenter_hash
|
169
|
+
@datacenter_hash ||= datacenters.find { |x| x[:id] == @datacenter } if @datacenter
|
170
170
|
@datacenter_hash ||= datacenters.first
|
171
171
|
end
|
172
172
|
|
@@ -174,6 +174,13 @@ module Fog
|
|
174
174
|
@blank_template ||= client.system_service.get.special_objects.blank_template
|
175
175
|
end
|
176
176
|
|
177
|
+
def create_search_by_datacenter(search:, datacenter:, page: nil)
|
178
|
+
search ||= ""
|
179
|
+
search += " datacenter=#{datacenter}" if datacenter
|
180
|
+
search += " page #{page}" if page
|
181
|
+
search
|
182
|
+
end
|
183
|
+
|
177
184
|
private
|
178
185
|
|
179
186
|
attr_reader :client
|
@@ -13,11 +13,11 @@ module Fog
|
|
13
13
|
disk_attachments_service.add(disk)
|
14
14
|
end
|
15
15
|
|
16
|
-
# rubocop:disable Metrics/AbcSize
|
16
|
+
# rubocop:disable Metrics/AbcSize
|
17
17
|
def add_options_defaults(options)
|
18
18
|
options = options.dup
|
19
19
|
search = options[:search] || format("datacenter=%<datacenter>s", :datacenter => datacenter)
|
20
|
-
options[:bootable]
|
20
|
+
options[:bootable] = options.delete(:bootable) == "true"
|
21
21
|
options[:interface] ||= OvirtSDK4::DiskInterface::VIRTIO
|
22
22
|
options[:provisioned_size] = options[:size_gb].to_i * Fog::Compute::Ovirt::DISK_SIZE_TO_GB if options[:size_gb]
|
23
23
|
|
@@ -32,12 +32,12 @@ module Fog
|
|
32
32
|
options[:disk] ||= {}
|
33
33
|
options[:disk][:storage_domains] ||= [client.system_service.storage_domains_service.storage_domain_service(options[:storage_domain_id]).get]
|
34
34
|
options[:disk][:provisioned_size] ||= options.delete(:provisioned_size)
|
35
|
-
options[:disk][:type] ||= options.delete(:type)
|
36
35
|
options[:disk][:format] ||= options.delete(:format)
|
37
|
-
options[:disk][:sparse]
|
36
|
+
options[:disk][:sparse] ||= options.delete(:sparse) == "true"
|
37
|
+
options[:disk][:wipe_after_delete] ||= options.delete(:wipe_after_delete) == "true"
|
38
38
|
options
|
39
39
|
end
|
40
|
-
# rubocop:enable Metrics/AbcSize
|
40
|
+
# rubocop:enable Metrics/AbcSize
|
41
41
|
end
|
42
42
|
|
43
43
|
class Mock
|
@@ -24,7 +24,7 @@ module Fog
|
|
24
24
|
end
|
25
25
|
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
26
26
|
|
27
|
-
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
27
|
+
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength
|
28
28
|
def create_vm(attrs)
|
29
29
|
attrs = attrs.dup
|
30
30
|
|
@@ -44,11 +44,12 @@ module Fog
|
|
44
44
|
vms_service = client.system_service.vms_service
|
45
45
|
attrs[:instance_type] = attrs[:instance_type].present? ? client.system_service.instance_types_service.instance_type_service(attrs[:instance_type]).get : nil
|
46
46
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
47
|
+
if attrs[:template].present?
|
48
|
+
attrs[:template] = client.system_service.templates_service.template_service(attrs[:template]).get
|
49
|
+
else
|
50
|
+
attrs[:template] = client.system_service.get.special_objects.blank_template
|
51
|
+
update_os_attrs(attrs)
|
52
|
+
end
|
52
53
|
|
53
54
|
attrs[:comment] ||= ""
|
54
55
|
attrs[:quota] = attrs[:quota].present? ? client.system_service.data_centers_service.data_center_service(datacenter).quotas_service.quota_service(attrs[:quota]).get : nil
|
@@ -56,15 +57,26 @@ module Fog
|
|
56
57
|
cpu_topology = OvirtSDK4::CpuTopology.new(:cores => attrs.fetch(:cores, "1"), :sockets => attrs.fetch(:sockets, "1"))
|
57
58
|
attrs[:cpu] = OvirtSDK4::Cpu.new(:topology => cpu_topology)
|
58
59
|
end
|
59
|
-
|
60
60
|
attrs[:memory_policy] = OvirtSDK4::MemoryPolicy.new(:guaranteed => attrs[:memory]) if attrs[:memory].to_i < Fog::Compute::Ovirt::DISK_SIZE_TO_GB
|
61
|
+
attrs[:high_availability] = OvirtSDK4::HighAvailability.new(:enabled => attrs[:ha] == "1") if attrs[:ha].present?
|
61
62
|
|
62
63
|
# TODO: handle cloning from template
|
63
64
|
process_vm_opts(attrs)
|
64
65
|
new_vm = OvirtSDK4::Vm.new(attrs)
|
65
66
|
vms_service.add(new_vm)
|
66
67
|
end
|
67
|
-
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
68
|
+
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength
|
69
|
+
|
70
|
+
# rubocop:disable Metrics/AbcSize
|
71
|
+
def update_os_attrs(attrs)
|
72
|
+
attrs[:os] ||= {}
|
73
|
+
attrs[:os][:type] ||= "Other OS"
|
74
|
+
attrs[:os][:boot] ||= [attrs.fetch(:boot_dev1, OvirtSDK4::BootDevice::NETWORK), attrs.fetch(:boot_dev2, OvirtSDK4::BootDevice::HD)]
|
75
|
+
attrs[:os][:boot] = attrs[:os][:boot].without(attrs["first_boot_dev"]).prepend(attrs["first_boot_dev"]) if attrs["first_boot_dev"]
|
76
|
+
|
77
|
+
attrs[:os] = OvirtSDK4::OperatingSystem.new(:type => attrs[:os][:type], :boot => OvirtSDK4::Boot.new(:devices => attrs[:os][:boot]))
|
78
|
+
end
|
79
|
+
# rubocop:enable Metrics/AbcSize
|
68
80
|
end
|
69
81
|
|
70
82
|
class Mock
|
@@ -3,8 +3,9 @@ module Fog
|
|
3
3
|
class Ovirt
|
4
4
|
class V4
|
5
5
|
class Real
|
6
|
-
def list_clusters(
|
7
|
-
|
6
|
+
def list_clusters(opts = {})
|
7
|
+
opts[:search] = create_search_by_datacenter(:search => opts[:search], :datacenter => datacenter_hash[:name])
|
8
|
+
client.system_service.clusters_service.list(opts).map { |ovirt_obj| ovirt_attrs(ovirt_obj) }
|
8
9
|
end
|
9
10
|
end
|
10
11
|
class Mock
|
@@ -7,10 +7,8 @@ module Fog
|
|
7
7
|
filters = filters.dup
|
8
8
|
page = filters.delete(:page)
|
9
9
|
without_details = filters.delete(:without_details)
|
10
|
-
|
11
10
|
filters[:all_content] = true unless without_details
|
12
|
-
filters[:search]
|
13
|
-
filters[:search] += " page #{page}"
|
11
|
+
filters[:search] = create_search_by_datacenter(:search => filters[:search], :datacenter => datacenter_hash[:name], :page => page)
|
14
12
|
client.system_service.vms_service.list(filters).map { |ovirt_obj| ovirt_attrs ovirt_obj }
|
15
13
|
end
|
16
14
|
end
|
@@ -3,18 +3,22 @@ module Fog
|
|
3
3
|
class Ovirt
|
4
4
|
class V4
|
5
5
|
class Real
|
6
|
+
# rubocop:disable Metrics/AbcSize
|
6
7
|
def list_vm_volumes(vm_id)
|
7
|
-
# disk_attachments_service = client.system_service.vms_service.vm_service(vm_id).disk_attachments_service
|
8
|
-
# disk_attachments_service.list.map {|ovirt_obj| ovirt_attrs client.system_service.disks_service.disk_service(ovirt_obj.id).get}
|
9
|
-
|
10
8
|
vm = client.system_service.vms_service.vm_service(vm_id).get
|
11
|
-
|
12
9
|
attachments = client.follow_link(vm.disk_attachments)
|
13
|
-
|
14
10
|
attachments.map do |attachment|
|
15
|
-
|
11
|
+
attachment_disk = client.follow_link(attachment.disk)
|
12
|
+
attachment = client.follow_link(attachment)
|
13
|
+
bootable = attachment.bootable
|
14
|
+
interface = attachment.interface
|
15
|
+
attachment_disk.bootable = bootable if attachment_disk.bootable.nil?
|
16
|
+
attachment_disk.interface = interface if attachment_disk.interface.nil?
|
17
|
+
attachment_disk.storage_domain = attachment_disk.storage_domains[0].id
|
18
|
+
ovirt_attrs attachment_disk
|
16
19
|
end
|
17
20
|
end
|
21
|
+
# rubocop:enable Metrics/AbcSize
|
18
22
|
end
|
19
23
|
class Mock
|
20
24
|
def list_vm_volumes(_vm_id)
|
@@ -25,7 +25,7 @@ module Fog
|
|
25
25
|
wrap_attribute(attrs, :host, OvirtSDK4::Host)
|
26
26
|
wrap_attribute(attrs, :quota, OvirtSDK4::Quota)
|
27
27
|
wrap_attribute(attrs, :instance_type, OvirtSDK4::InstanceType)
|
28
|
-
attrs[:high_availability] = OvirtSDK4::HighAvailability.new(:enabled => attrs[:ha])
|
28
|
+
attrs[:high_availability] = OvirtSDK4::HighAvailability.new(:enabled => attrs[:ha] == "1") if attrs[:ha].present?
|
29
29
|
attrs[:original_template] = if attrs[:original_template].present?
|
30
30
|
OvirtSDK4::Template.new(:id => attrs[:original_template])
|
31
31
|
else
|
data/lib/fog/ovirt/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fog-ovirt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ori Rabin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fog-core
|