fog-ovirt 1.2.0 → 1.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -0
  3. data/Rakefile +1 -1
  4. data/lib/fog/ovirt/compute.rb +4 -4
  5. data/lib/fog/ovirt/compute/v3.rb +1 -2
  6. data/lib/fog/ovirt/compute/v4.rb +39 -24
  7. data/lib/fog/ovirt/models/compute/instance_type.rb +1 -0
  8. data/lib/fog/ovirt/models/compute/interfaces.rb +0 -2
  9. data/lib/fog/ovirt/models/compute/server.rb +0 -2
  10. data/lib/fog/ovirt/models/compute/volume.rb +1 -0
  11. data/lib/fog/ovirt/models/compute/volumes.rb +0 -2
  12. data/lib/fog/ovirt/requests/compute/v3/get_volume.rb +19 -0
  13. data/lib/fog/ovirt/requests/compute/v3/mock_files/volume.xml +21 -0
  14. data/lib/fog/ovirt/requests/compute/v4/add_interface.rb +0 -2
  15. data/lib/fog/ovirt/requests/compute/v4/add_volume.rb +2 -2
  16. data/lib/fog/ovirt/requests/compute/v4/create_vm.rb +4 -4
  17. data/lib/fog/ovirt/requests/compute/v4/get_volume.rb +19 -0
  18. data/lib/fog/ovirt/requests/compute/v4/list_template_volumes.rb +0 -2
  19. data/lib/fog/ovirt/requests/compute/v4/list_vm_volumes.rb +0 -2
  20. data/lib/fog/ovirt/requests/compute/v4/mock_files/disk.xml +28 -0
  21. data/lib/fog/ovirt/requests/compute/v4/mock_files/template.xml +48 -45
  22. data/lib/fog/ovirt/requests/compute/v4/mock_files/templates.xml +17 -2
  23. data/lib/fog/ovirt/requests/compute/v4/mock_files/vnic_profile.xml +10 -0
  24. data/lib/fog/ovirt/requests/compute/v4/storage_domains.rb +1 -0
  25. data/lib/fog/ovirt/requests/compute/v4/update_vm.rb +0 -2
  26. data/lib/fog/ovirt/version.rb +1 -1
  27. data/tests/ovirt/models/compute/instance_type_tests.rb +23 -0
  28. data/tests/ovirt/models/compute/instance_types_tests.rb +7 -0
  29. data/tests/ovirt/requests/compute/v4/client_tests.rb +1 -1
  30. data/tests/ovirt/requests/compute/v4/create_vm_tests.rb +1 -0
  31. metadata +12 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e6c8f50700ff436d3f31a8c67a536c630cd6b8166dffd761f0ec3eaa751bad22
4
- data.tar.gz: d3ab17d6c140811ec0843778869c416ea0323cf222efbd5c648128b63ccbe52e
3
+ metadata.gz: f7b24b23699c22d16d6f7a5da99f613ec7e7066022e5d6f0097fc15236745db8
4
+ data.tar.gz: e7f4357f8b657cd35625ebffe798cbc9bc09a65db3cb2aa6d5ec6f9706fad6c1
5
5
  SHA512:
6
- metadata.gz: f6a869a3392da2cb17182a5b1d4dbbcaf286757bf55dbf7b0a00bec3ee79351c4d0cd137e1ad1c03001202b1a7e0ae56854b27f65ba78ee81b0e9555291d2998
7
- data.tar.gz: df66a186ce9979c987bbc62097b20dd0d1022d5f547549c42806b32441c7a5c3ca58d59e014a24b9e9b6094a3c882356d116cccd31a615504da130788aefdeb5
6
+ metadata.gz: 805c36e9f5631026c94921b4278f1a193e5e52287a270e83a13c7bc1dfcdcd04a9588d76eb572ae5e2c632aba578acad499fd74a6bc3ca1965ac72ce72c37f9c
7
+ data.tar.gz: 83ce48a44a9f6952b18e8314551529e44cb7caf5df055dfdfb2402a4e976966f1191970538f8c5215f67ecf917c195ef464f841f931e8b2707d6077bf704ab52
@@ -21,3 +21,6 @@ Style/SignalException:
21
21
 
22
22
  Layout/EmptyLineAfterGuardClause:
23
23
  Enabled: false
24
+
25
+ Metrics/AbcSize:
26
+ Enabled: false
data/Rakefile CHANGED
@@ -12,7 +12,7 @@ mock = ENV["FOG_MOCK"] || "true"
12
12
  begin
13
13
  require "rubocop/rake_task"
14
14
  RuboCop::RakeTask.new do |t|
15
- t.patterns = Dir["{lib,spec,tests}/**/*"]
15
+ t.patterns = Dir["{lib,spec,tests}/**/*.rb"]
16
16
  end
17
17
  rescue StandardError
18
18
  puts "Rubocop not loaded"
@@ -78,10 +78,10 @@ module Fog
78
78
  class Mock
79
79
  def initialize(options = {})
80
80
  if options[:api_version] == "v4"
81
- Fog::Ovirt::Compute::V4::Mock.send(:include, Fog::Ovirt::Compute::Collections)
81
+ Fog::Ovirt::Compute::V4::Mock.include Fog::Ovirt::Compute::Collections
82
82
  @client = Fog::Ovirt::Compute::V4::Mock.new(options)
83
83
  else
84
- Fog::Ovirt::Compute::V3::Mock.send(:include, Fog::Ovirt::Compute::Collections)
84
+ Fog::Ovirt::Compute::V3::Mock.include Fog::Ovirt::Compute::Collections
85
85
  @client = Fog::Ovirt::Compute::V3::Mock.new(options)
86
86
  end
87
87
  end
@@ -100,10 +100,10 @@ module Fog
100
100
  class Real
101
101
  def initialize(options = {})
102
102
  if options[:api_version] == "v4"
103
- Fog::Ovirt::Compute::V4::Real.send(:include, Fog::Ovirt::Compute::Collections)
103
+ Fog::Ovirt::Compute::V4::Real.include Fog::Ovirt::Compute::Collections
104
104
  @client = Fog::Ovirt::Compute::V4::Real.new(options)
105
105
  else
106
- Fog::Ovirt::Compute::V3::Real.send(:include, Fog::Ovirt::Compute::Collections)
106
+ Fog::Ovirt::Compute::V3::Real.include Fog::Ovirt::Compute::Collections
107
107
  @client = Fog::Ovirt::Compute::V3::Real.new(options)
108
108
  end
109
109
  end
@@ -34,6 +34,7 @@ module Fog
34
34
  request :list_template_volumes
35
35
  request :list_volumes
36
36
  request :add_volume
37
+ request :get_volume
37
38
  request :destroy_volume
38
39
  request :update_volume
39
40
  request :attach_volume
@@ -102,7 +103,6 @@ module Fog
102
103
  class Real
103
104
  include Shared
104
105
 
105
- # rubocop:disable Metrics/AbcSize
106
106
  def initialize(options = {})
107
107
  require "rbovirt"
108
108
  username = options[:ovirt_username]
@@ -121,7 +121,6 @@ module Fog
121
121
 
122
122
  @client = ExceptionWrapper.new(OVIRT::Client.new(username, password, url, connection_opts))
123
123
  end
124
- # rubocop:enable Metrics/AbcSize
125
124
 
126
125
  def api_version
127
126
  client.api_version
@@ -33,6 +33,7 @@ module Fog
33
33
  request :list_template_volumes
34
34
  request :list_volumes
35
35
  request :add_volume
36
+ request :get_volume
36
37
  request :destroy_volume
37
38
  request :update_volume
38
39
  request :get_api_version
@@ -41,9 +42,9 @@ module Fog
41
42
  request :list_operating_systems
42
43
 
43
44
  module Shared
44
- # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
45
+ # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
45
46
  # converts an OVIRT object into an hash for fog to consume.
46
- def ovirt_attrs(obj)
47
+ def shared_ovirt_attrs(obj)
47
48
  opts = {}
48
49
  # TODO: stop using instance_variables, they will change
49
50
  obj.instance_variables.each do |v|
@@ -51,7 +52,7 @@ module Fog
51
52
  value = obj.instance_variable_get(v)
52
53
 
53
54
  if key == :network
54
- opts[key] = obj.vnic_profile.present? ? client.follow_link(obj.vnic_profile).network.id : value
55
+ opts[key] = obj.vnic_profile.present? ? yield(obj) : value
55
56
  next
56
57
  end
57
58
 
@@ -69,9 +70,10 @@ module Fog
69
70
  end
70
71
  opts
71
72
  end
72
- # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
73
73
 
74
- # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
74
+ # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
75
+
76
+ # rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
75
77
  def get_attr_value(value, opts)
76
78
  case value
77
79
  when OvirtSDK4::List
@@ -102,29 +104,31 @@ module Fog
102
104
  when OvirtSDK4::Console
103
105
  { :enabled => value.enabled }
104
106
  else
105
- if value.class.respond_to?(:parent) && value.class.parent == OvirtSDK4
107
+ if value.class.respond_to?(:module_parent) && value.class.module_parent == OvirtSDK4
106
108
  value.id if value.respond_to?(:id)
107
109
  else
108
110
  value.to_s.strip
109
111
  end
110
112
  end
111
113
  end
112
- # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
113
-
114
- def convert_string_to_bool(opts)
115
- return opts unless opts.present?
116
- opts.each do |key, value|
117
- if value == "true"
118
- opts[key] = true
119
- elsif value == "false"
120
- opts[key] = false
121
- elsif value.is_a? Hash
122
- convert_string_to_bool(value)
123
- elsif value.is_a? Array
124
- value.map { |item| convert_string_to_bool(item) }
114
+ # rubocop:enable Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
115
+
116
+ def convert_string_to_bool(value)
117
+ case value
118
+ when "true"
119
+ true
120
+ when "false"
121
+ false
122
+ when Array
123
+ value.map { |elem| convert_string_to_bool(elem) }
124
+ when Hash
125
+ value.each do |key, elem|
126
+ value[key] = convert_string_to_bool(elem)
125
127
  end
128
+ value
129
+ else
130
+ value
126
131
  end
127
- opts
128
132
  end
129
133
  end
130
134
 
@@ -135,6 +139,13 @@ module Fog
135
139
  require "ovirtsdk4"
136
140
  end
137
141
 
142
+ def ovirt_attrs(obj)
143
+ shared_ovirt_attrs(obj) do
144
+ xml = read_xml("vnic_profile.xml")
145
+ Nokogiri::XML(xml).xpath("/vnic_profile/network/@id").to_s
146
+ end
147
+ end
148
+
138
149
  private
139
150
 
140
151
  def client
@@ -151,7 +162,6 @@ module Fog
151
162
  class Real
152
163
  include Shared
153
164
 
154
- # rubocop:disable Metrics/AbcSize
155
165
  def initialize(options = {})
156
166
  require "ovirtsdk4"
157
167
  username = options[:ovirt_username]
@@ -172,7 +182,12 @@ module Fog
172
182
 
173
183
  @client = ExceptionWrapper.new(OvirtSDK4::Connection.new(connection_opts))
174
184
  end
175
- # rubocop:enable Metrics/AbcSize
185
+
186
+ def ovirt_attrs(obj)
187
+ shared_ovirt_attrs(obj) do
188
+ client.follow_link(obj.vnic_profile).network.id
189
+ end
190
+ end
176
191
 
177
192
  def api_version
178
193
  api = client.system_service.get
@@ -180,11 +195,11 @@ module Fog
180
195
  end
181
196
 
182
197
  def datacenter
183
- @datacenter ||= datacenter_hash[:id]
198
+ datacenter_hash[:id]
184
199
  end
185
200
 
186
201
  def datacenter_hash
187
- @datacenter_hash ||= datacenters.find { |x| x[:id] == @datacenter } if @datacenter
202
+ @datacenter_hash ||= datacenters.find { |x| x[:id] == @datacenter } || datacenters.find { |x| x[:name] == @datacenter } if @datacenter
188
203
  @datacenter_hash ||= datacenters.first
189
204
  end
190
205
 
@@ -10,6 +10,7 @@ module Fog
10
10
  attribute :description
11
11
  attribute :memory
12
12
  attribute :cores
13
+ attribute :sockets
13
14
  attribute :creation_time
14
15
  attribute :os
15
16
  attribute :ha
@@ -9,7 +9,6 @@ module Fog
9
9
 
10
10
  attr_accessor :vm
11
11
 
12
- # rubocop:disable Metrics/AbcSize
13
12
  def all(_filters = {})
14
13
  requires :vm
15
14
  if vm.is_a? Fog::Ovirt::Compute::Server
@@ -20,7 +19,6 @@ module Fog
20
19
  raise ::Fog::Ovirt::Errors::OvirtError, "interfaces should have vm or template"
21
20
  end
22
21
  end
23
- # rubocop:enable Metrics/AbcSize
24
22
 
25
23
  def get(id)
26
24
  new service.get_interface(id)
@@ -121,7 +121,6 @@ module Fog
121
121
  vm_power_action(:start)
122
122
  end
123
123
 
124
- # rubocop:disable Metrics/AbcSize
125
124
  def start_with_cloudinit(options = {})
126
125
  wait_for { !locked? } if options[:blocking]
127
126
  user_data = if options[:use_custom_script]
@@ -133,7 +132,6 @@ module Fog
133
132
  reload
134
133
  action_status
135
134
  end
136
- # rubocop:enable Metrics/AbcSize
137
135
 
138
136
  def stop(_options = {})
139
137
  vm_power_action(:stop)
@@ -17,6 +17,7 @@ module Fog
17
17
  attribute :quota
18
18
  attribute :alias
19
19
  attribute :wipe_after_delete
20
+ attribute :name
20
21
 
21
22
  def size_gb
22
23
  attributes[:size_gb] ||= attributes[:size].to_i / Fog::Ovirt::Compute::DISK_SIZE_TO_GB if attributes[:size]
@@ -9,7 +9,6 @@ module Fog
9
9
 
10
10
  attr_accessor :vm
11
11
 
12
- # rubocop:disable Metrics/AbcSize
13
12
  def all(_filters = {})
14
13
  if vm.is_a? Fog::Ovirt::Compute::Server
15
14
  load service.list_vm_volumes(vm.id)
@@ -19,7 +18,6 @@ module Fog
19
18
  load service.list_volumes
20
19
  end
21
20
  end
22
- # rubocop:enable Metrics/AbcSize
23
21
 
24
22
  def get(id)
25
23
  new service.get_volume(id)
@@ -0,0 +1,19 @@
1
+ module Fog
2
+ module Ovirt
3
+ class Compute
4
+ class V3
5
+ class Real
6
+ def get_volume(id)
7
+ ovirt_attrs client.disk(id)
8
+ end
9
+ end
10
+ class Mock
11
+ def get_volume(_id)
12
+ xml = read_xml("volume.xml")
13
+ ovirt_attrs OVIRT::Volume.new(self, Nokogiri::XML(xml).root)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,21 @@
1
+ <disks>
2
+ <disk href="/api/vms/192cdd3f-3281-4e20-b81d-93bdc57ac387/disks/9f68ecfd-218b-4f80-8e7a-e70b2ab054cd" id="9f68ecfd-218b-4f80-8e7a-e70b2ab054cd">
3
+ <name>Disk 2</name>
4
+ <link href="/api/vms/192cdd3f-3281-4e20-b81d-93bdc57ac387/disks/9f68ecfd-218b-4f80-8e7a-e70b2ab054cd/statistics" rel="statistics"/>
5
+ <vm href="/api/vms/192cdd3f-3281-4e20-b81d-93bdc57ac387" id="192cdd3f-3281-4e20-b81d-93bdc57ac387"/>
6
+ <storage_domains>
7
+ <storage_domain id="cba62b33-887a-410c-b367-e3d9229a72f7"/>
8
+ </storage_domains>
9
+ <size>5368709120</size>
10
+ <type>data</type>
11
+ <status>
12
+ <state>ok</state>
13
+ </status>
14
+ <interface>virtio</interface>
15
+ <format>raw</format>
16
+ <sparse>true</sparse>
17
+ <bootable>false</bootable>
18
+ <wipe_after_delete>false</wipe_after_delete>
19
+ <propagate_errors>false</propagate_errors>
20
+ </disk>
21
+ </disks>
@@ -3,7 +3,6 @@ module Fog
3
3
  class Compute
4
4
  class V4
5
5
  class Real
6
- # rubocop:disable Metrics/AbcSize
7
6
  def add_interface(id, options = {})
8
7
  raise ArgumentError, "instance id is a required parameter" unless id
9
8
  vm = client.system_service.vms_service.vm_service(id)
@@ -26,7 +25,6 @@ module Fog
26
25
  interface = OvirtSDK4::Nic.new(options)
27
26
  nics_service.add(interface)
28
27
  end
29
- # rubocop:enable Metrics/AbcSize
30
28
  end
31
29
 
32
30
  class Mock
@@ -13,7 +13,7 @@ module Fog
13
13
  disk_attachments_service.add(disk)
14
14
  end
15
15
 
16
- # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
16
+ # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
17
17
  def add_options_defaults(options)
18
18
  options = options.dup
19
19
  options = convert_string_to_bool(options)
@@ -35,7 +35,7 @@ module Fog
35
35
  options[:disk][:wipe_after_delete] = options.delete(:wipe_after_delete) if options[:disk][:wipe_after_delete].nil?
36
36
  options
37
37
  end
38
- # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
38
+ # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
39
39
  end
40
40
 
41
41
  class Mock
@@ -21,7 +21,7 @@ module Fog
21
21
  opts.delete(:disks)
22
22
  end
23
23
 
24
- # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength
24
+ # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength
25
25
  def create_vm(attrs)
26
26
  attrs = attrs.dup
27
27
  attrs = convert_string_to_bool(attrs)
@@ -40,6 +40,8 @@ module Fog
40
40
  end
41
41
 
42
42
  vms_service = client.system_service.vms_service
43
+
44
+ attrs[:type] = attrs.fetch(:type, OvirtSDK4::VmType::SERVER)
43
45
  attrs[:instance_type] = attrs[:instance_type].present? ? client.system_service.instance_types_service.instance_type_service(attrs[:instance_type]).get : nil
44
46
 
45
47
  if attrs[:template].present?
@@ -63,9 +65,8 @@ module Fog
63
65
  new_vm = OvirtSDK4::Vm.new(attrs)
64
66
  vms_service.add(new_vm, :clone => attrs[:clone])
65
67
  end
66
- # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength
68
+ # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength
67
69
 
68
- # rubocop:disable Metrics/AbcSize
69
70
  def update_os_attrs(attrs)
70
71
  attrs[:os] ||= {}
71
72
  attrs[:os][:type] ||= "Other OS"
@@ -74,7 +75,6 @@ module Fog
74
75
 
75
76
  attrs[:os] = OvirtSDK4::OperatingSystem.new(:type => attrs[:os][:type], :boot => OvirtSDK4::Boot.new(:devices => attrs[:os][:boot]))
76
77
  end
77
- # rubocop:enable Metrics/AbcSize
78
78
  end
79
79
 
80
80
  class Mock
@@ -0,0 +1,19 @@
1
+ module Fog
2
+ module Ovirt
3
+ class Compute
4
+ class V4
5
+ class Real
6
+ def get_volume(id)
7
+ ovirt_attrs client.system_service.disks_service.disk_service(id).get
8
+ end
9
+ end
10
+ class Mock
11
+ def get_volume(_id)
12
+ xml = read_xml("disk.xml")
13
+ ovirt_attrs OvirtSDK4::Reader.read(Nokogiri::XML(xml).root.to_s)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -3,7 +3,6 @@ module Fog
3
3
  class Compute
4
4
  class V4
5
5
  class Real
6
- # rubocop:disable Metrics/AbcSize
7
6
  def list_template_volumes(template_id)
8
7
  template = client.system_service.templates_service.template_service(template_id).get
9
8
  attachments = client.follow_link(template.disk_attachments)
@@ -18,7 +17,6 @@ module Fog
18
17
  ovirt_attrs attachment_disk
19
18
  end
20
19
  end
21
- # rubocop:enable Metrics/AbcSize
22
20
  end
23
21
  class Mock
24
22
  def list_template_volumes(_template_id)
@@ -3,7 +3,6 @@ module Fog
3
3
  class Compute
4
4
  class V4
5
5
  class Real
6
- # rubocop:disable Metrics/AbcSize
7
6
  def list_vm_volumes(vm_id)
8
7
  vm = client.system_service.vms_service.vm_service(vm_id).get
9
8
  attachments = client.follow_link(vm.disk_attachments)
@@ -18,7 +17,6 @@ module Fog
18
17
  ovirt_attrs attachment_disk
19
18
  end
20
19
  end
21
- # rubocop:enable Metrics/AbcSize
22
20
  end
23
21
  class Mock
24
22
  def list_vm_volumes(_vm_id)
@@ -0,0 +1,28 @@
1
+ <disks>
2
+ <disk href="/api/disks/4d1abf9a-da81-4de2-bf20-f5f060018e05" id="4d1abf9a-da81-4de2-bf20-f5f060018e05">
3
+ <actions>
4
+ <link href="/api/disks/4d1abf9a-da81-4de2-bf20-f5f060018e05/export" rel="export"/>
5
+ <link href="/api/disks/4d1abf9a-da81-4de2-bf20-f5f060018e05/move" rel="move"/>
6
+ <link href="/api/disks/4d1abf9a-da81-4de2-bf20-f5f060018e05/copy" rel="copy"/>
7
+ </actions>
8
+ <name>Disk 2</name>
9
+ <link href="/api/disks/4d1abf9a-da81-4de2-bf20-f5f060018e05/permissions" rel="permissions"/>
10
+ <link href="/api/disks/4d1abf9a-da81-4de2-bf20-f5f060018e05/statistics" rel="statistics"/>
11
+ <alias>Disk 2</alias>
12
+ <image_id>d6034a90-39fa-46ee-888f-208a76f3baa4</image_id>
13
+ <storage_domains>
14
+ <storage_domain id="a23a4329-33b9-4246-a393-4f91071825b6"/>
15
+ </storage_domains>
16
+ <provisioned_size>4294967296</provisioned_size>
17
+ <actual_size>1073741824</actual_size>
18
+ <status>ok</status>
19
+ <interface>virtio</interface>
20
+ <format>cow</format>
21
+ <qcow_version>qcow2_v3</qcow_version>
22
+ <sparse>true</sparse>
23
+ <bootable>false</bootable>
24
+ <shareable>false</shareable>
25
+ <wipe_after_delete>false</wipe_after_delete>
26
+ <propagate_errors>false</propagate_errors>
27
+ </disk>
28
+ </disks>
@@ -1,45 +1,48 @@
1
- <templates>
2
- <template href="/api/templates/2a08ba05-f3b1-4e5a-ade9-496466a8b323" id="2a08ba05-f3b1-4e5a-ade9-496466a8b323">
3
- <name>hwp_small</name>
4
- <description>hardware profile small</description>
5
- <link href="/api/templates/2a08ba05-f3b1-4e5a-ade9-496466a8b323/disks" rel="disks"/>
6
- <link href="/api/templates/2a08ba05-f3b1-4e5a-ade9-496466a8b323/nics" rel="nics"/>
7
- <link href="/api/templates/2a08ba05-f3b1-4e5a-ade9-496466a8b323/cdroms" rel="cdroms"/>
8
- <link href="/api/templates/2a08ba05-f3b1-4e5a-ade9-496466a8b323/permissions" rel="permissions"/>
9
- <type>server</type>
10
- <status>ok</status>
11
- <memory>536870912</memory>
12
- <cpu>
13
- <topology>
14
- <cores>1</cores>
15
- <sockets>1</sockets>
16
- </topology>
17
- </cpu>
18
- <os>
19
- <type>unassigned</type>
20
- <boot>
21
- <devices>
22
- <device>network</device>
23
- </devices>
24
- </boot>
25
- <kernel/>
26
- <initrd/>
27
- <cmdline/>
28
- </os>
29
- <cluster href="/api/clusters/99408929-82cf-4dc7-a532-9d998063fa95" id="99408929-82cf-4dc7-a532-9d998063fa95"/>
30
- <creation_time>2012-01-31T07:47:03.811Z</creation_time>
31
- <origin>rhev</origin>
32
- <high_availability>
33
- <enabled>false</enabled>
34
- <priority>1</priority>
35
- </high_availability>
36
- <display>
37
- <type>spice</type>
38
- <monitors>1</monitors>
39
- </display>
40
- <stateless>false</stateless>
41
- <usb>
42
- <enabled>true</enabled>
43
- </usb>
44
- </template>
45
- </templates>
1
+ <template href="/api/templates/2a08ba05-f3b1-4e5a-ade9-496466a8b323" id="2a08ba05-f3b1-4e5a-ade9-496466a8b323">
2
+ <name>hwp_small</name>
3
+ <description>hardware profile small</description>
4
+ <link href="/api/templates/2a08ba05-f3b1-4e5a-ade9-496466a8b323/disks" rel="disks"/>
5
+ <link href="/api/templates/2a08ba05-f3b1-4e5a-ade9-496466a8b323/nics" rel="nics"/>
6
+ <link href="/api/templates/2a08ba05-f3b1-4e5a-ade9-496466a8b323/cdroms" rel="cdroms"/>
7
+ <link href="/api/templates/2a08ba05-f3b1-4e5a-ade9-496466a8b323/permissions" rel="permissions"/>
8
+ <type>server</type>
9
+ <memory>536870912</memory>
10
+ <cpu>
11
+ <topology>
12
+ <cores>1</cores>
13
+ <sockets>1</sockets>
14
+ </topology>
15
+ </cpu>
16
+ <os>
17
+ <type>unassigned</type>
18
+ <boot>
19
+ <devices>
20
+ <device>network</device>
21
+ </devices>
22
+ </boot>
23
+ <kernel/>
24
+ <initrd/>
25
+ <cmdline/>
26
+ </os>
27
+ <cluster href="/api/clusters/99408929-82cf-4dc7-a532-9d998063fa95" id="99408929-82cf-4dc7-a532-9d998063fa95"/>
28
+ <creation_time>2012-01-31T07:47:03.811Z</creation_time>
29
+ <origin>rhev</origin>
30
+ <high_availability>
31
+ <enabled>false</enabled>
32
+ <priority>1</priority>
33
+ </high_availability>
34
+ <display>
35
+ <type>spice</type>
36
+ <monitors>1</monitors>
37
+ </display>
38
+ <stateless>false</stateless>
39
+ <usb>
40
+ <enabled>true</enabled>
41
+ </usb>
42
+ <status>ok</status>
43
+ <version>
44
+ <version_name>base version</version_name>
45
+ <version_number>1</version_number>
46
+ <base_template href="/ovirt-engine/api/templates/2a08ba05-f3b1-4e5a-ade9-496466a8b323" id="2a08ba05-f3b1-4e5a-ade9-496466a8b323"/>
47
+ </version>
48
+ </template>
@@ -8,6 +8,11 @@
8
8
  <link href="/api/templates/00000000-0000-0000-0000-000000000000/permissions" rel="permissions"/>
9
9
  <type>desktop</type>
10
10
  <status>ok</status>
11
+ <version>
12
+ <version_name>base version</version_name>
13
+ <version_number>1</version_number>
14
+ <base_template href="/ovirt-engine/api/templates/00000000-0000-0000-0000-000000000000" id="00000000-0000-0000-0000-000000000000"/>
15
+ </version>
11
16
  <memory>536870912</memory>
12
17
  <cpu>
13
18
  <topology>
@@ -47,7 +52,6 @@
47
52
  <link href="/api/templates/05a5144f-8ef7-4151-b7f9-5014510b489e/cdroms" rel="cdroms"/>
48
53
  <link href="/api/templates/05a5144f-8ef7-4151-b7f9-5014510b489e/permissions" rel="permissions"/>
49
54
  <type>server</type>
50
- <status>ok</status>
51
55
  <memory>1073741824</memory>
52
56
  <cpu>
53
57
  <topology>
@@ -81,6 +85,12 @@
81
85
  <usb>
82
86
  <enabled>true</enabled>
83
87
  </usb>
88
+ <status>ok</status>
89
+ <version>
90
+ <version_name>base version</version_name>
91
+ <version_number>1</version_number>
92
+ <base_template href="/ovirt-engine/api/templates/05a5144f-8ef7-4151-b7f9-5014510b489e" id="05a5144f-8ef7-4151-b7f9-5014510b489e"/>
93
+ </version>
84
94
  </template>
85
95
  <template href="/api/templates/2a08ba05-f3b1-4e5a-ade9-496466a8b323" id="2a08ba05-f3b1-4e5a-ade9-496466a8b323">
86
96
  <name>hwp_small</name>
@@ -90,7 +100,6 @@
90
100
  <link href="/api/templates/2a08ba05-f3b1-4e5a-ade9-496466a8b323/cdroms" rel="cdroms"/>
91
101
  <link href="/api/templates/2a08ba05-f3b1-4e5a-ade9-496466a8b323/permissions" rel="permissions"/>
92
102
  <type>server</type>
93
- <status>ok</status>
94
103
  <memory>536870912</memory>
95
104
  <cpu>
96
105
  <topology>
@@ -124,5 +133,11 @@
124
133
  <usb>
125
134
  <enabled>true</enabled>
126
135
  </usb>
136
+ <status>ok</status>
137
+ <version>
138
+ <version_name>base version</version_name>
139
+ <version_number>1</version_number>
140
+ <base_template href="/ovirt-engine/api/templates/2a08ba05-f3b1-4e5a-ade9-496466a8b323" id="2a08ba05-f3b1-4e5a-ade9-496466a8b323"/>
141
+ </version>
127
142
  </template>
128
143
  </templates>
@@ -0,0 +1,10 @@
1
+ <vnic_profile href="/ovirt-engine/api/vnicprofiles/0000000a-000a-000a-000a-000000000398" id="0000000a-000a-000a-000a-000000000398">
2
+ <name>ovirtmgmt</name>
3
+ <link href="/ovirt-engine/api/vnicprofiles/0000000a-000a-000a-000a-000000000398/permissions" rel="permissions"/>
4
+ <pass_through>
5
+ <mode>disabled</mode>
6
+ </pass_through>
7
+ <port_mirroring>false</port_mirroring>
8
+ <network href="/ovirt-engine/api/networks/00000000-0000-0000-0000-000000000009" id="00000000-0000-0000-0000-000000000009"/>
9
+ <network_filter href="/ovirt-engine/api/networkfilters/593567f3-0314-011f-020e-0000000002d2" id="593567f3-0314-011f-020e-0000000002d2"/>
10
+ </vnic_profile>
@@ -6,6 +6,7 @@ module Fog
6
6
  def storage_domains(filter = {})
7
7
  filter = filter.dup
8
8
  role_filter = filter.delete(:role)
9
+ filter[:search] = create_search_by_datacenter(:search => filter[:search], :datacenter => datacenter_hash[:name])
9
10
  client.system_service.storage_domains_service.list(filter).collect do |sd|
10
11
  # Filter by role is not supported by the search language. The work around is to list all, then filter.
11
12
  role_filter.nil? || sd.type == role_filter ? sd : nil
@@ -3,7 +3,6 @@ module Fog
3
3
  class Compute
4
4
  class V4
5
5
  class Real
6
- # rubocop:disable Metrics/AbcSize
7
6
  def update_vm(attrs)
8
7
  attrs = attrs.dup
9
8
  attrs = convert_string_to_bool(attrs)
@@ -34,7 +33,6 @@ module Fog
34
33
  end
35
34
  vm_service.update(attrs)
36
35
  end
37
- # rubocop:enable Metrics/AbcSize
38
36
 
39
37
  def wrap_attribute(attrs, attribute, klass)
40
38
  if attrs[attribute].present?
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Ovirt
3
- VERSION = "1.2.0".freeze
3
+ VERSION = "1.2.5".freeze
4
4
  end
5
5
  end
@@ -0,0 +1,23 @@
1
+ Shindo.tests("Fog::Ovirt::Compute.new | instance_type model", ["ovirt"]) do
2
+ instance_types = Fog::Ovirt::Compute.new.instance_types
3
+ instance_type = instance_types.last
4
+
5
+ tests("The instance_type model should") do
6
+ tests("have attributes") do
7
+ model_attribute_hash = instance_type.attributes
8
+ attributes = %i[id name memory sockets cores]
9
+
10
+ tests("The instance type model should respond to") do
11
+ attributes.each do |attribute|
12
+ test(attribute.to_s) { instance_type.respond_to? attribute }
13
+ end
14
+ end
15
+ tests("The attributes hash should have key") do
16
+ attributes.each do |attribute|
17
+ test(attribute.to_s) { model_attribute_hash.key? attribute }
18
+ end
19
+ end
20
+ end
21
+ test("be a kind of Fog::Ovirt::Compute::InstanceType") { instance_type.is_a? Fog::Ovirt::Compute::InstanceType }
22
+ end
23
+ end
@@ -0,0 +1,7 @@
1
+ Shindo.tests("Fog::Ovirt::Compute.new | instance types collection", ["ovirt"]) do
2
+ instance_types = Fog::Ovirt::Compute.new.instance_types
3
+
4
+ tests("The instance types collection") do
5
+ test("should be a kind of Fog::Ovirt::Compute::InstanceTypes") { instance_types.is_a? Fog::Ovirt::Compute::InstanceTypes }
6
+ end
7
+ end
@@ -2,7 +2,7 @@ Shindo.tests("Fog::Ovirt::Compute.new | client", ["ovirt"]) do
2
2
  before do
3
3
  @client_mock = Object.new
4
4
  def @client_mock.foo
5
- raise OVIRT::OvirtException, "Test"
5
+ raise ::Fog::Ovirt::Errors::OvirtError, "Test"
6
6
  end
7
7
 
8
8
  @object_under_test = Fog::Ovirt::Compute::ExceptionWrapper.new(@client_mock)
@@ -5,6 +5,7 @@ Shindo.tests("Fog::Ovirt::Compute v4 | vm_create request", "ovirt") do
5
5
  tests("Create VM") do
6
6
  response = compute.create_vm(:name => "fog-" + name_base.to_s, :cluster_name => "Default")
7
7
  test("should be a kind of OvirtSDK4::Vm") { response.is_a? OvirtSDK4::Vm }
8
+ test("should be a 'OvirtSDK4::VmType::SERVER' VM type by default") { response.type == OvirtSDK4::VmType::SERVER }
8
9
  end
9
10
 
10
11
  tests("Create VM from template (clone)") do
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.2.0
4
+ version: 1.2.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: 2019-05-22 00:00:00.000000000 Z
11
+ date: 2020-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog-core
@@ -212,6 +212,7 @@ files:
212
212
  - lib/fog/ovirt/requests/compute/v3/get_quota.rb
213
213
  - lib/fog/ovirt/requests/compute/v3/get_template.rb
214
214
  - lib/fog/ovirt/requests/compute/v3/get_virtual_machine.rb
215
+ - lib/fog/ovirt/requests/compute/v3/get_volume.rb
215
216
  - lib/fog/ovirt/requests/compute/v3/list_affinity_group_vms.rb
216
217
  - lib/fog/ovirt/requests/compute/v3/list_affinity_groups.rb
217
218
  - lib/fog/ovirt/requests/compute/v3/list_clusters.rb
@@ -243,6 +244,7 @@ files:
243
244
  - lib/fog/ovirt/requests/compute/v3/mock_files/templates.xml
244
245
  - lib/fog/ovirt/requests/compute/v3/mock_files/vm.xml
245
246
  - lib/fog/ovirt/requests/compute/v3/mock_files/vms.xml
247
+ - lib/fog/ovirt/requests/compute/v3/mock_files/volume.xml
246
248
  - lib/fog/ovirt/requests/compute/v3/mock_files/volumes.xml
247
249
  - lib/fog/ovirt/requests/compute/v3/remove_from_affinity_group.rb
248
250
  - lib/fog/ovirt/requests/compute/v3/storage_domains.rb
@@ -265,6 +267,7 @@ files:
265
267
  - lib/fog/ovirt/requests/compute/v4/get_quota.rb
266
268
  - lib/fog/ovirt/requests/compute/v4/get_template.rb
267
269
  - lib/fog/ovirt/requests/compute/v4/get_virtual_machine.rb
270
+ - lib/fog/ovirt/requests/compute/v4/get_volume.rb
268
271
  - lib/fog/ovirt/requests/compute/v4/list_clusters.rb
269
272
  - lib/fog/ovirt/requests/compute/v4/list_instance_types.rb
270
273
  - lib/fog/ovirt/requests/compute/v4/list_networks.rb
@@ -283,6 +286,7 @@ files:
283
286
  - lib/fog/ovirt/requests/compute/v4/mock_files/cluster.xml
284
287
  - lib/fog/ovirt/requests/compute/v4/mock_files/clusters.xml
285
288
  - lib/fog/ovirt/requests/compute/v4/mock_files/data_centers.xml
289
+ - lib/fog/ovirt/requests/compute/v4/mock_files/disk.xml
286
290
  - lib/fog/ovirt/requests/compute/v4/mock_files/disks.xml
287
291
  - lib/fog/ovirt/requests/compute/v4/mock_files/instance_type.xml
288
292
  - lib/fog/ovirt/requests/compute/v4/mock_files/instance_types.xml
@@ -294,6 +298,7 @@ files:
294
298
  - lib/fog/ovirt/requests/compute/v4/mock_files/templates.xml
295
299
  - lib/fog/ovirt/requests/compute/v4/mock_files/vm.xml
296
300
  - lib/fog/ovirt/requests/compute/v4/mock_files/vms.xml
301
+ - lib/fog/ovirt/requests/compute/v4/mock_files/vnic_profile.xml
297
302
  - lib/fog/ovirt/requests/compute/v4/mock_files/volumes.xml
298
303
  - lib/fog/ovirt/requests/compute/v4/storage_domains.rb
299
304
  - lib/fog/ovirt/requests/compute/v4/update_interface.rb
@@ -311,6 +316,8 @@ files:
311
316
  - tests/ovirt/compute_tests.rb
312
317
  - tests/ovirt/models/compute/cluster_tests.rb
313
318
  - tests/ovirt/models/compute/clusters_tests.rb
319
+ - tests/ovirt/models/compute/instance_type_tests.rb
320
+ - tests/ovirt/models/compute/instance_types_tests.rb
314
321
  - tests/ovirt/models/compute/interface_tests.rb
315
322
  - tests/ovirt/models/compute/interfaces_tests.rb
316
323
  - tests/ovirt/models/compute/operating_system_tests.rb
@@ -353,7 +360,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
353
360
  - !ruby/object:Gem::Version
354
361
  version: '0'
355
362
  requirements: []
356
- rubygems_version: 3.0.3
363
+ rubygems_version: 3.0.8
357
364
  signing_key:
358
365
  specification_version: 4
359
366
  summary: Module for the 'fog' gem to support Ovirt.
@@ -364,6 +371,8 @@ test_files:
364
371
  - tests/ovirt/compute_tests.rb
365
372
  - tests/ovirt/models/compute/cluster_tests.rb
366
373
  - tests/ovirt/models/compute/clusters_tests.rb
374
+ - tests/ovirt/models/compute/instance_type_tests.rb
375
+ - tests/ovirt/models/compute/instance_types_tests.rb
367
376
  - tests/ovirt/models/compute/interface_tests.rb
368
377
  - tests/ovirt/models/compute/interfaces_tests.rb
369
378
  - tests/ovirt/models/compute/operating_system_tests.rb