fog-kubevirt 1.3.1 → 1.3.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1e2d2c6f98b5fa86ae26dfab40696be4b5bae710a8466179ccef3afa175b6f34
4
- data.tar.gz: f13369106d1359001eeb59a249499b2f944bf4651da66b52f647a83838b5f6a2
3
+ metadata.gz: b3179fe8d9931ca7ea27fe0f345109c213c60d030045a4678d2951ec0fad61dd
4
+ data.tar.gz: ee83703dadbf2509eef8905117a935f1c7cbb14b3aa7f17b2334821502b3592d
5
5
  SHA512:
6
- metadata.gz: d866029c4dbef7324093049cc6e2c69eac5b6c205633134d7f89d75d25b51f0024e62809d12c66b61e4cd62d6455782340a5e15ce808240c93bc2712b14aa320
7
- data.tar.gz: c0adb18fac7ea2530e6552f71f2caf686410eadbdf106c13ff17fefe6fce75a1e4528ce7b78dc48ba49e2104ec0208d9534268abca692956c01c087a54679d48
6
+ metadata.gz: 7a6fc1a166cdc365409d1ad16aa665d8672037174aa54f66d39698defb4a03ebe8376da5553e64c55dac13129b097e1399af9825a333125601e46a4e78b4eabb
7
+ data.tar.gz: 408db587d8256e0cfa20f103bab0be5f62f5b56b8acdc2829e1a23e17f1bfaa5dd83f3eb9978975aaf398c2b6cd952675d506b8b1227185a2a60c401582c36a7
@@ -9,7 +9,7 @@ module Fog
9
9
  module Kubevirt
10
10
  class Compute < Fog::Service
11
11
  recognizes :kubevirt_token, :kubevirt_hostname, :kubevirt_port, :kubevirt_namespace, \
12
- :kubevirt_log, :kubevirt_verify_ssl, :kubevirt_ca_cert
12
+ :kubevirt_log, :kubevirt_verify_ssl, :kubevirt_ca_cert , :kubevirt_version
13
13
 
14
14
  model_path 'fog/kubevirt/compute/models'
15
15
  model :vminstance
@@ -60,6 +60,7 @@ module Fog
60
60
  request :get_service
61
61
  request :get_storageclass
62
62
  request :get_template
63
+ request :get_vnc_console_details
63
64
  request :list_vminstances
64
65
  request :list_nodes
65
66
  request :list_networkattachmentdefs
@@ -147,12 +148,18 @@ module Fog
147
148
  #
148
149
  STORAGE_GROUP = 'storage.k8s.io'.freeze
149
150
 
151
+ #
152
+ # The API group of the Openshift Templates extension:
153
+ #
154
+ TEMPLATE_GROUP = 'template.openshift.io'.freeze
155
+
150
156
  def initialize(options={})
151
157
  require 'kubeclient'
152
158
 
153
159
  @kubevirt_token = options[:kubevirt_token]
154
160
  @host = options[:kubevirt_hostname]
155
161
  @port = options[:kubevirt_port]
162
+ @kubevirt_version = options[:kubevirt_version]
156
163
 
157
164
  @log = options[:kubevirt_log]
158
165
  @log ||= ::Logger.new(STDOUT)
@@ -283,7 +290,7 @@ module Fog
283
290
  populate_notice_attributes(template, notice)
284
291
  template
285
292
  end
286
- watch = openshift_client.watch_templates(opts)
293
+ watch = openshift_template_client.watch_templates(opts)
287
294
 
288
295
  WatchWrapper.new(watch, mapper)
289
296
  end
@@ -420,12 +427,17 @@ module Fog
420
427
  # version detected based on
421
428
  # https://github.com/kubernetes-incubator/apiserver-builder/blob/master/docs/concepts/aggregation.md#viewing-discovery-information
422
429
  preferredVersion = response["preferredVersion"]
423
- return preferredVersion["version"] if preferredVersion
424
- response["versions"][0]
430
+ if url.include? KUBEVIRT_GROUP
431
+ version = @kubevirt_version || preferredVersion["version"]
432
+ else
433
+ version = preferredVersion["version"] if preferredVersion
434
+ version = version || response["versions"][0]
435
+ end
436
+ version
425
437
  end
426
438
 
427
- def openshift_client
428
- create_client('/oapi')
439
+ def openshift_template_client
440
+ create_client('/apis/' + TEMPLATE_GROUP)
429
441
  end
430
442
 
431
443
  def kube_client
@@ -448,6 +460,10 @@ module Fog
448
460
  @log
449
461
  end
450
462
 
463
+ def cert_expired?(cert)
464
+ Time.now > cert.not_after
465
+ end
466
+
451
467
  #
452
468
  # Prepare the TLS and authentication options that will be used for the
453
469
  # standard Kubernetes API and also for the KubeVirt extension
@@ -465,6 +481,7 @@ module Fog
465
481
 
466
482
  cert_store = OpenSSL::X509::Store.new
467
483
  certs.each do |cert|
484
+ raise ::Fog::Kubevirt::Errors::ValidationError, "Certificate has been expired" if cert_expired?(cert)
468
485
  cert_store.add_cert(cert)
469
486
  end
470
487
 
@@ -139,7 +139,7 @@ module Fog
139
139
 
140
140
  volume.config = v[volume.type.to_sym]
141
141
  disk = disks.detect { |d| d.name == volume.name }
142
- volume.boot_order = disk.boot_order
142
+ volume.boot_order = disk.boot_order if disk.respond_to?(:boot_order)
143
143
  volume.bus = disk.bus if disk.respond_to?(:bus)
144
144
 
145
145
  volumes << volume
@@ -39,6 +39,10 @@ module Fog
39
39
  # delete vm instance
40
40
  service.delete_vminstance(name) unless vm_instance.nil?
41
41
  end
42
+
43
+ def get_vnc_console_details(name, namespace)
44
+ service.get_vnc_console_details(name, namespace)
45
+ end
42
46
  end
43
47
  end
44
48
  end
@@ -3,7 +3,7 @@ module Fog
3
3
  class Compute
4
4
  class Real
5
5
  def get_template(name)
6
- Template.parse object_to_hash( openshift_client.get_template(name, @namespace) )
6
+ Template.parse object_to_hash( openshift_template_client.get_template(name, @namespace) )
7
7
  end
8
8
  end
9
9
 
@@ -0,0 +1,29 @@
1
+ module Fog
2
+ module Kubevirt
3
+ class Compute
4
+ class Real
5
+ def get_vnc_console_details(name, namespace)
6
+
7
+ url = URI::Generic.build(
8
+ :scheme => 'https',
9
+ :host => @host,
10
+ :port => @port,
11
+ :path => "/apis/kubevirt.io"
12
+ )
13
+ version = detect_version(url.to_s, @opts[:ssl_options])
14
+ {
15
+ :host => @host,
16
+ :port => @port,
17
+ :path => "/apis/subresources.kubevirt.io/#{version}/namespaces/#{namespace}/virtualmachineinstances/#{name}/vnc",
18
+ :token => @opts[:auth_options][:bearer_token]
19
+ }
20
+ end
21
+ end
22
+
23
+ class Mock
24
+ def get_vnc_console_details(name, namespace)
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -5,7 +5,7 @@ module Fog
5
5
  class Compute
6
6
  class Real
7
7
  def list_templates(_filters = {})
8
- temps = openshift_client.get_templates(namespace: @namespace)
8
+ temps = openshift_template_client.get_templates(namespace: @namespace)
9
9
  entities = temps.map do |kubevirt_obj|
10
10
  Template.parse object_to_hash(kubevirt_obj)
11
11
  end
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Kubevirt
3
- VERSION = '1.3.1'
3
+ VERSION = '1.3.5'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog-kubevirt
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Kliczewski
@@ -11,11 +11,12 @@ authors:
11
11
  - Adam Grare
12
12
  - Boris Odnopozov
13
13
  - Shira Maximov
14
+ - yifatmakias
14
15
  - Wesley Beary
15
- autorequire:
16
+ autorequire:
16
17
  bindir: bin
17
18
  cert_chain: []
18
- date: 2019-07-07 00:00:00.000000000 Z
19
+ date: 2022-02-02 00:00:00.000000000 Z
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: minitest
@@ -121,23 +122,24 @@ dependencies:
121
122
  requirements:
122
123
  - - "~>"
123
124
  - !ruby/object:Gem::Version
124
- version: 4.3.0
125
+ version: '4.3'
125
126
  type: :runtime
126
127
  prerelease: false
127
128
  version_requirements: !ruby/object:Gem::Requirement
128
129
  requirements:
129
130
  - - "~>"
130
131
  - !ruby/object:Gem::Version
131
- version: 4.3.0
132
+ version: '4.3'
132
133
  description: This library can be used as a module for `fog`.
133
134
  email:
134
135
  - piotr.kliczewski@gmail.com
135
136
  - masayag@redhat.com
136
137
  - plribeiro3000@gmail.com
137
138
  - gilles@redhat.com
138
- - agrare@redhat.com
139
+ - adam@grare.com
139
140
  - bodnopoz@redhat.com
140
141
  - shiramaximov@gmail.com
142
+ - ymakias@redhat.com
141
143
  - geemus@gmail.com
142
144
  executables: []
143
145
  extensions: []
@@ -199,6 +201,7 @@ files:
199
201
  - lib/fog/kubevirt/compute/requests/get_template.rb
200
202
  - lib/fog/kubevirt/compute/requests/get_vm.rb
201
203
  - lib/fog/kubevirt/compute/requests/get_vminstance.rb
204
+ - lib/fog/kubevirt/compute/requests/get_vnc_console_details.rb
202
205
  - lib/fog/kubevirt/compute/requests/list_networkattachmentdefs.rb
203
206
  - lib/fog/kubevirt/compute/requests/list_nodes.rb
204
207
  - lib/fog/kubevirt/compute/requests/list_persistentvolumes.rb
@@ -243,7 +246,7 @@ homepage: https://github.com/fog/fog-kubevirt
243
246
  licenses:
244
247
  - Apache-2.0
245
248
  metadata: {}
246
- post_install_message:
249
+ post_install_message:
247
250
  rdoc_options: []
248
251
  require_paths:
249
252
  - lib
@@ -258,8 +261,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
258
261
  - !ruby/object:Gem::Version
259
262
  version: '0'
260
263
  requirements: []
261
- rubygems_version: 3.0.3
262
- signing_key:
264
+ rubygems_version: 3.1.6
265
+ signing_key:
263
266
  specification_version: 4
264
267
  summary: Module for the 'fog' gem to support Kubevirt.
265
268
  test_files: