fog-kubevirt 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fog/compute/kubevirt.rb +52 -6
- data/lib/fog/compute/kubevirt/models/server.rb +1 -1
- data/lib/fog/compute/kubevirt/models/vm_base.rb +3 -1
- data/lib/fog/compute/kubevirt/models/vm_data.rb +13 -7
- data/lib/fog/compute/kubevirt/models/vms.rb +4 -5
- data/lib/fog/kubevirt/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: aa2d9409a7b3472593ad9f4851e75b1e702d6be9
|
4
|
+
data.tar.gz: bb3258447667e18c78273407587d4adbf25ff308
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a866f0a383c98f3f08e913374d9b0d4d7a57059423848ce96628119ff20bf122d2d459cb5ed5888793a11e4a6ff2044604ca7f531a1c004a28b167468c4b7b07
|
7
|
+
data.tar.gz: 4c972287cffa8afcc7b81730115daf8bbe5052124dda86d62c92fa95b3abfc04074812b9ce9bae29c863687712577a26bee539896c9757191a057b73b6890a36
|
data/lib/fog/compute/kubevirt.rb
CHANGED
@@ -7,8 +7,7 @@ require "fog/core"
|
|
7
7
|
module Fog
|
8
8
|
module Compute
|
9
9
|
class Kubevirt < Fog::Service
|
10
|
-
|
11
|
-
recognizes :kubevirt_hostname, :kubevirt_port, :kubevirt_namespace, \
|
10
|
+
recognizes :kubevirt_token, :kubevirt_hostname, :kubevirt_port, :kubevirt_namespace, \
|
12
11
|
:kubevirt_log, :kubevirt_verify_ssl, :kubevirt_ca_cert
|
13
12
|
|
14
13
|
model_path 'fog/compute/kubevirt/models'
|
@@ -278,7 +277,7 @@ module Fog
|
|
278
277
|
populate_notice_attributes(vminstance, notice)
|
279
278
|
vminstance
|
280
279
|
end
|
281
|
-
watch = kubevirt_client.
|
280
|
+
watch = kubevirt_client.watch_virtual_machine_instances(opts)
|
282
281
|
|
283
282
|
WatchWrapper.new(watch, mapper)
|
284
283
|
end
|
@@ -352,9 +351,28 @@ module Fog
|
|
352
351
|
:path => path
|
353
352
|
)
|
354
353
|
|
354
|
+
if @kubevirt_token.to_s.empty?
|
355
|
+
create_client_from_config(path)
|
356
|
+
else
|
357
|
+
create_client_from_token(url)
|
358
|
+
end
|
359
|
+
end
|
360
|
+
|
361
|
+
def create_client_from_token(url)
|
362
|
+
# Prepare the TLS and authentication options that will be used for the standard Kubernetes API
|
363
|
+
# and also for the KubeVirt extension:
|
364
|
+
@opts = {
|
365
|
+
:ssl_options => {
|
366
|
+
:verify_ssl => OpenSSL::SSL::VERIFY_NONE,
|
367
|
+
},
|
368
|
+
:auth_options => {
|
369
|
+
:bearer_token => @kubevirt_token
|
370
|
+
}
|
371
|
+
}
|
355
372
|
version = detect_version(url.to_s, @opts[:ssl_options])
|
356
|
-
key = path + '/' + version
|
357
|
-
|
373
|
+
key = url.path + '/' + version
|
374
|
+
|
375
|
+
client = check_client(key)
|
358
376
|
return client if client
|
359
377
|
|
360
378
|
client = Kubeclient::Client.new(
|
@@ -362,10 +380,38 @@ module Fog
|
|
362
380
|
version,
|
363
381
|
@opts
|
364
382
|
)
|
383
|
+
|
384
|
+
wrap_client(client, version, key)
|
385
|
+
end
|
386
|
+
|
387
|
+
def create_client_from_config(path)
|
388
|
+
config = Kubeclient::Config.read(ENV['KUBECONFIG'] || ENV['HOME']+'/.kube/config')
|
389
|
+
context = config.context
|
390
|
+
url = context.api_endpoint
|
391
|
+
version = detect_version(url + path, context.ssl_options)
|
392
|
+
key = path + '/' + version
|
393
|
+
|
394
|
+
client = check_client(key)
|
395
|
+
return client if client
|
396
|
+
|
397
|
+
client = Kubeclient::Client.new(
|
398
|
+
url + path,
|
399
|
+
version,
|
400
|
+
ssl_options: context.ssl_options,
|
401
|
+
auth_options: context.auth_options
|
402
|
+
)
|
403
|
+
|
404
|
+
wrap_client(client, version, key)
|
405
|
+
end
|
406
|
+
|
407
|
+
def check_client(key)
|
408
|
+
@clients[key]
|
409
|
+
end
|
410
|
+
|
411
|
+
def wrap_client(client, version, key)
|
365
412
|
wrapped_client = ExceptionWrapper.new(client, version)
|
366
413
|
@clients[key] = wrapped_client
|
367
414
|
|
368
|
-
# Return the client:
|
369
415
|
wrapped_client
|
370
416
|
end
|
371
417
|
|
@@ -43,7 +43,7 @@ module Fog
|
|
43
43
|
:volumes => parse_volumes(spec[:volumes]),
|
44
44
|
:interfaces => parse_interfaces(domain[:devices][:interfaces]),
|
45
45
|
:networks => parse_networks(spec[:networks]),
|
46
|
-
:
|
46
|
+
:status => object[:spec][:running].to_s == "true" ? "running" : "stopped",
|
47
47
|
:machine_type => domain.dig(:machine, :type)
|
48
48
|
}
|
49
49
|
vm[:owner_reference] = owner unless owner.nil?
|
@@ -56,6 +56,8 @@ module Fog
|
|
56
56
|
end
|
57
57
|
|
58
58
|
module VmAction
|
59
|
+
include Shared
|
60
|
+
|
59
61
|
def start(options = {})
|
60
62
|
# Change the `running` attribute to `true` so that the virtual machine controller will take it and
|
61
63
|
# create the virtual machine instance.
|
@@ -150,13 +150,19 @@ module Fog
|
|
150
150
|
:readonly
|
151
151
|
end
|
152
152
|
|
153
|
-
class VmVolume
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
153
|
+
class VmVolume < Fog::Model
|
154
|
+
identity :name
|
155
|
+
attribute :id
|
156
|
+
# values: containerDisk, persistentVolumeClaim, emptyDisk,
|
157
|
+
# ephemeral, cloudInitNoCloud, hostDisk, secret,
|
158
|
+
# dataVolume, serviceAccount, configMap
|
159
|
+
attribute :type
|
160
|
+
|
161
|
+
attribute :info # specific piece of information per volume type
|
162
|
+
|
163
|
+
def persisted?
|
164
|
+
!name.nil?
|
165
|
+
end
|
160
166
|
end
|
161
167
|
end
|
162
168
|
end
|
@@ -59,8 +59,8 @@ module Fog
|
|
59
59
|
image = args.fetch(:image, nil)
|
60
60
|
pvc = args.fetch(:pvc, nil)
|
61
61
|
init = args.fetch(:cloudinit, {})
|
62
|
-
networks = args.fetch(:networks)
|
63
|
-
interfaces = args.fetch(:interfaces)
|
62
|
+
networks = args.fetch(:networks, nil)
|
63
|
+
interfaces = args.fetch(:interfaces, nil)
|
64
64
|
|
65
65
|
if image.nil? && pvc.nil?
|
66
66
|
raise ::Fog::Kubevirt::Errors::ValidationError
|
@@ -103,7 +103,7 @@ module Fog
|
|
103
103
|
{:disk => {
|
104
104
|
:bus => "virtio"
|
105
105
|
},
|
106
|
-
:name =>
|
106
|
+
:name => volume_name,
|
107
107
|
}
|
108
108
|
]
|
109
109
|
},
|
@@ -141,8 +141,7 @@ module Fog
|
|
141
141
|
:disk => {
|
142
142
|
:bus => "virtio"
|
143
143
|
},
|
144
|
-
:name => "
|
145
|
-
:volumeName => "cloudinitvolume"
|
144
|
+
:name => "cloudinitvolume",
|
146
145
|
) unless init.empty?
|
147
146
|
|
148
147
|
vm = deep_merge!(vm,
|
data/lib/fog/kubevirt/version.rb
CHANGED
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: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Kliczewski
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2019-
|
15
|
+
date: 2019-02-05 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: minitest
|