fog-ovirt 1.1.4 → 1.1.5
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/ovirt.rb +1 -0
- data/lib/fog/ovirt/compute/v4.rb +16 -1
- data/lib/fog/ovirt/requests/compute/v4/add_interface.rb +1 -1
- data/lib/fog/ovirt/requests/compute/v4/add_volume.rb +7 -9
- data/lib/fog/ovirt/requests/compute/v4/create_vm.rb +17 -19
- data/lib/fog/ovirt/requests/compute/v4/update_interface.rb +1 -0
- data/lib/fog/ovirt/requests/compute/v4/update_vm.rb +1 -0
- data/lib/fog/ovirt/requests/compute/v4/update_volume.rb +1 -1
- data/lib/fog/ovirt/requests/compute/v4/vm_ticket.rb +1 -0
- 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: 60c557f87df7eed11973b2d486df972d4eb6d5e9
|
4
|
+
data.tar.gz: 012c8b79e06089c60b939780a883c8cfadaddf5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9a46e1b06e95bb0256d8b4eb4fdc22e1e5b6431f8e2bb321f73b6a51136ff80215683aec5c7fb5b391705b47d6a16235d2e21a67f0cfbd1523daec712f89057
|
7
|
+
data.tar.gz: c33adf408dd6f3d9cc8fe2fa80a2ef9ac0039b1146b52e88fac340170968c036fc834698f1c1c30ea467a2b1343e75fb87e319bad26d83cbbced077539f66238
|
data/lib/fog/ovirt.rb
CHANGED
data/lib/fog/ovirt/compute/v4.rb
CHANGED
@@ -76,7 +76,7 @@ module Fog
|
|
76
76
|
case value
|
77
77
|
when OvirtSDK4::List
|
78
78
|
value.to_a
|
79
|
-
when Array, Hash, DateTime
|
79
|
+
when Array, Hash, DateTime
|
80
80
|
value
|
81
81
|
when OvirtSDK4::HighAvailability
|
82
82
|
opts[:ha] = value.enabled
|
@@ -107,6 +107,21 @@ module Fog
|
|
107
107
|
end
|
108
108
|
end
|
109
109
|
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
|
110
|
+
|
111
|
+
def convert_string_to_bool(opts)
|
112
|
+
opts.each do |key, value|
|
113
|
+
if value == "true"
|
114
|
+
opts[key] = true
|
115
|
+
elsif value == "false"
|
116
|
+
opts[key] = false
|
117
|
+
elsif value.is_a? Hash
|
118
|
+
convert_string_to_bool(value)
|
119
|
+
elsif value.is_a? Array
|
120
|
+
value.map { |item| convert_string_to_bool(item) }
|
121
|
+
end
|
122
|
+
end
|
123
|
+
opts
|
124
|
+
end
|
110
125
|
end
|
111
126
|
|
112
127
|
class Mock
|
@@ -9,7 +9,7 @@ module Fog
|
|
9
9
|
vm = client.system_service.vms_service.vm_service(id)
|
10
10
|
nics_service = vm.nics_service
|
11
11
|
options = options.dup
|
12
|
-
|
12
|
+
options = convert_string_to_bool(options)
|
13
13
|
if options[:network].present?
|
14
14
|
network = client.system_service.networks_service.network_service(options[:network]).get
|
15
15
|
|
@@ -13,32 +13,30 @@ module Fog
|
|
13
13
|
disk_attachments_service.add(disk)
|
14
14
|
end
|
15
15
|
|
16
|
-
# rubocop:disable Metrics/AbcSize
|
16
|
+
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
17
17
|
def add_options_defaults(options)
|
18
18
|
options = options.dup
|
19
|
+
options = convert_string_to_bool(options)
|
19
20
|
search = options[:search] || format("datacenter=%<datacenter>s", :datacenter => datacenter)
|
20
|
-
options[:bootable] = options.delete(:bootable)
|
21
|
+
options[:bootable] = options.delete(:bootable)
|
21
22
|
options[:interface] ||= OvirtSDK4::DiskInterface::VIRTIO
|
22
23
|
options[:provisioned_size] = options[:size_gb].to_i * Fog::Compute::Ovirt::DISK_SIZE_TO_GB if options[:size_gb]
|
23
|
-
|
24
|
+
options[:sparse] = true if options[:sparse].nil?
|
24
25
|
options[:storage_domain_id] = options[:storage_domain] || storagedomains(:role => "data", :search => search).first.id
|
25
26
|
# If no size is given, default to a volume size of 8GB
|
26
27
|
options[:provisioned_size] ||= 8 * Fog::Compute::Ovirt::DISK_SIZE_TO_GB
|
27
28
|
options[:type] ||= OvirtSDK4::DiskType::DATA
|
28
29
|
options[:format] ||= OvirtSDK4::DiskFormat::COW
|
29
|
-
|
30
|
-
options[:sparse] = true unless options[:sparse].present?
|
31
30
|
options[:quota] = options[:quota].present? ? client.system_service.data_centers_service.data_center_service(datacenter).quotas_service.quota_service(options[:quota]).get : nil
|
32
|
-
|
33
31
|
options[:disk] ||= {}
|
32
|
+
options[:disk][:sparse] = options.delete(:sparse) if options[:disk][:sparse].nil?
|
34
33
|
options[:disk][:storage_domains] ||= [client.system_service.storage_domains_service.storage_domain_service(options[:storage_domain_id]).get]
|
35
34
|
options[:disk][:provisioned_size] ||= options.delete(:provisioned_size)
|
36
35
|
options[:disk][:format] ||= options.delete(:format)
|
37
|
-
options[:disk][:
|
38
|
-
options[:disk][:wipe_after_delete] ||= options.delete(:wipe_after_delete)
|
36
|
+
options[:disk][:wipe_after_delete] = options.delete(:wipe_after_delete) if options[:disk][:wipe_after_delete].nil?
|
39
37
|
options
|
40
38
|
end
|
41
|
-
# rubocop:enable Metrics/AbcSize
|
39
|
+
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
42
40
|
end
|
43
41
|
|
44
42
|
class Mock
|
@@ -3,30 +3,28 @@ module Fog
|
|
3
3
|
class Ovirt
|
4
4
|
class V4
|
5
5
|
class Real
|
6
|
-
def
|
7
|
-
|
8
|
-
end
|
9
|
-
|
10
|
-
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
11
|
-
def process_vm_opts(opts)
|
12
|
-
return unless check_for_option(opts, "template") && check_for_option(opts, "storagedomain")
|
6
|
+
def create_disk_attachment_from_disk(disk_to_attachment)
|
7
|
+
storage_domain = client.system_service.storage_domains_service.storage_domain_service(disk_to_attachment["storage_domain"]).get
|
13
8
|
|
14
|
-
|
15
|
-
|
16
|
-
|
9
|
+
disk = {
|
10
|
+
:id => disk_to_attachment["id"],
|
11
|
+
:format => disk_to_attachment.fetch("format", OvirtSDK4::DiskFormat::COW),
|
12
|
+
:sparse => disk_to_attachment.fetch("sparse", true),
|
13
|
+
:storage_domains => [storage_domain]
|
14
|
+
}
|
17
15
|
|
18
|
-
|
19
|
-
|
20
|
-
opts[:clone] = true unless opts[:clone] == true || template_disks.empty? || template_disks.all? { |d| d.storage_domain == storagedomain_id }
|
16
|
+
OvirtSDK4::DiskAttachment.new(:disk => disk)
|
17
|
+
end
|
21
18
|
|
22
|
-
|
23
|
-
opts[:
|
19
|
+
def process_vm_disks(opts)
|
20
|
+
opts[:disk_attachments] = opts[:disks].map { |disk| create_disk_attachment_from_disk(disk) }
|
21
|
+
opts.delete(:disks)
|
24
22
|
end
|
25
|
-
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
26
23
|
|
27
24
|
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength
|
28
25
|
def create_vm(attrs)
|
29
26
|
attrs = attrs.dup
|
27
|
+
attrs = convert_string_to_bool(attrs)
|
30
28
|
|
31
29
|
if attrs[:cluster].present?
|
32
30
|
attrs[:cluster] = client.system_service.clusters_service.cluster_service(attrs[:cluster]).get
|
@@ -60,10 +58,10 @@ module Fog
|
|
60
58
|
attrs[:memory_policy] = OvirtSDK4::MemoryPolicy.new(:guaranteed => attrs[:memory]) if attrs[:memory].to_i < Fog::Compute::Ovirt::DISK_SIZE_TO_GB
|
61
59
|
attrs[:high_availability] = OvirtSDK4::HighAvailability.new(:enabled => attrs[:ha] == "1") if attrs[:ha].present?
|
62
60
|
|
63
|
-
|
64
|
-
|
61
|
+
process_vm_disks(attrs) if attrs[:clone] == true && attrs[:disks].present?
|
62
|
+
|
65
63
|
new_vm = OvirtSDK4::Vm.new(attrs)
|
66
|
-
vms_service.add(new_vm)
|
64
|
+
vms_service.add(new_vm, :clone => attrs[:clone])
|
67
65
|
end
|
68
66
|
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength
|
69
67
|
|
@@ -14,7 +14,7 @@ module Fog
|
|
14
14
|
|
15
15
|
def update_volume(id, options)
|
16
16
|
check_arguments(id, options)
|
17
|
-
|
17
|
+
options = convert_string_to_bool(options)
|
18
18
|
disk_id = options[:id]
|
19
19
|
disk_attachment = client.system_service.vms_service.vm_service(id).disk_attachments_service.attachment_service(disk_id)
|
20
20
|
disk_attachment.update(disk_attachment, options)
|
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ori Rabin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fog-core
|