fog-kubevirt 0.1.4 → 0.1.5
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 +28 -4
- data/lib/fog/compute/kubevirt/models/templates.rb +6 -1
- data/lib/fog/compute/kubevirt/models/vminstance.rb +3 -4
- data/lib/fog/compute/kubevirt/models/vminstances.rb +7 -2
- data/lib/fog/compute/kubevirt/models/vms.rb +6 -1
- data/lib/fog/compute/kubevirt/requests/create_pvc.rb +1 -1
- data/lib/fog/compute/kubevirt/requests/create_vm.rb +1 -1
- data/lib/fog/compute/kubevirt/requests/create_vminstance.rb +2 -1
- data/lib/fog/kubevirt.rb +1 -0
- 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: 1c337ff2c2a840dbac40190eeb2f68142439c7ce
|
4
|
+
data.tar.gz: d1cf9a63c550417736ccccb088b2a3eab636808b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad5568f12fd77a0301de97b524b3b427eb65c75bb5be393d238fd226c34b4014870236a09f985a707f4393b856d221e4b339cb33340756ae263c52bf1a06f120
|
7
|
+
data.tar.gz: b2101735200e5f5f2f4c69e490ed886f49d43b4723bec949e68088dc439c452cf451113c33d8a304136fe834378f47040e8d5541c4fbec85600c2b73f006257b
|
data/lib/fog/compute/kubevirt.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'delegate'
|
2
|
-
require 'logger'
|
3
2
|
|
4
3
|
require "fog/core"
|
5
4
|
|
@@ -50,6 +49,30 @@ module Fog
|
|
50
49
|
end
|
51
50
|
end
|
52
51
|
|
52
|
+
class ExceptionWrapper
|
53
|
+
def initialize(client)
|
54
|
+
@client = client
|
55
|
+
end
|
56
|
+
|
57
|
+
def method_missing(symbol, *args)
|
58
|
+
super unless @client.respond_to?(symbol)
|
59
|
+
|
60
|
+
if block_given?
|
61
|
+
@client.__send__(symbol, *args) do |*block_args|
|
62
|
+
yield(*block_args)
|
63
|
+
end
|
64
|
+
else
|
65
|
+
@client.__send__(symbol, *args)
|
66
|
+
end
|
67
|
+
rescue KubeException => e
|
68
|
+
raise ::Fog::Kubevirt::Errors::ClientError, e
|
69
|
+
end
|
70
|
+
|
71
|
+
def respond_to_missing?(method_name, include_private = false)
|
72
|
+
@client.respond_to?(symbol, include_all) || super
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
53
76
|
#
|
54
77
|
# Label name which identifies operation system information
|
55
78
|
#
|
@@ -118,7 +141,7 @@ module Fog
|
|
118
141
|
@port = options[:kubevirt_port]
|
119
142
|
|
120
143
|
@log = options[:kubevirt_log]
|
121
|
-
@log ||=
|
144
|
+
@log ||= ::Logger.new(STDOUT)
|
122
145
|
|
123
146
|
@namespace = options[:kubevirt_namespace] || 'default'
|
124
147
|
|
@@ -306,10 +329,11 @@ module Fog
|
|
306
329
|
version,
|
307
330
|
@opts
|
308
331
|
)
|
309
|
-
|
332
|
+
wrapped_client = ExceptionWrapper.new(client)
|
333
|
+
@clients[key] = wrapped_client
|
310
334
|
|
311
335
|
# Return the client:
|
312
|
-
|
336
|
+
wrapped_client
|
313
337
|
end
|
314
338
|
|
315
339
|
def openshift_client
|
@@ -10,7 +10,12 @@ module Fog
|
|
10
10
|
model Fog::Compute::Kubevirt::Template
|
11
11
|
|
12
12
|
def all(filters = {})
|
13
|
-
|
13
|
+
begin
|
14
|
+
temps = service.list_templates(filters)
|
15
|
+
rescue ::Fog::Kubevirt::Errors::ClientError
|
16
|
+
# we assume that we get 404
|
17
|
+
temps = []
|
18
|
+
end
|
14
19
|
@kind = temps.kind
|
15
20
|
@resource_version = temps.resource_version
|
16
21
|
load temps
|
@@ -20,7 +20,6 @@ module Fog
|
|
20
20
|
def self.parse(object)
|
21
21
|
metadata = object[:metadata]
|
22
22
|
status = object[:status]
|
23
|
-
owner = metadata[:ownerReferences][0]
|
24
23
|
spec = object[:spec]
|
25
24
|
domain = spec[:domain]
|
26
25
|
{
|
@@ -28,9 +27,9 @@ module Fog
|
|
28
27
|
:name => metadata[:name],
|
29
28
|
:resource_version => metadata[:resourceVersion],
|
30
29
|
:uid => metadata[:uid],
|
31
|
-
:owner_name =>
|
32
|
-
:owner_uid =>
|
33
|
-
:cpu_cores => domain
|
30
|
+
:owner_name => metadata.dig(:ownerReferences, 0, :name),
|
31
|
+
:owner_uid => metadata.dig(:ownerReferences, 0, :uid),
|
32
|
+
:cpu_cores => domain.dig(:cpu, :cores),
|
34
33
|
:memory => domain[:resources][:requests][:memory],
|
35
34
|
:disks => domain[:devices][:disks],
|
36
35
|
:volumes => spec[:volumes],
|
@@ -10,7 +10,12 @@ module Fog
|
|
10
10
|
model Fog::Compute::Kubevirt::Vminstance
|
11
11
|
|
12
12
|
def all(filters = {})
|
13
|
-
|
13
|
+
begin
|
14
|
+
vms = service.list_vminstances(filters)
|
15
|
+
rescue ::Fog::Kubevirt::Errors::ClientError
|
16
|
+
# we assume that we get 404
|
17
|
+
vms = []
|
18
|
+
end
|
14
19
|
@kind = vms.kind
|
15
20
|
@resource_version = vms.resource_version
|
16
21
|
load vms
|
@@ -23,7 +28,7 @@ module Fog
|
|
23
28
|
def destroy(name, namespace)
|
24
29
|
begin
|
25
30
|
vm_instance = get(name)
|
26
|
-
rescue
|
31
|
+
rescue ::Fog::Kubevirt::Errors::ClientError
|
27
32
|
# the virtual machine instance doesn't exist
|
28
33
|
vm_instance = nil
|
29
34
|
end
|
@@ -10,7 +10,12 @@ module Fog
|
|
10
10
|
model Fog::Compute::Kubevirt::Vm
|
11
11
|
|
12
12
|
def all(filters = {})
|
13
|
-
|
13
|
+
begin
|
14
|
+
vms = service.list_vms(filters)
|
15
|
+
rescue ::Fog::Kubevirt::Errors::ClientError
|
16
|
+
# we assume that we get 404
|
17
|
+
vms = []
|
18
|
+
end
|
14
19
|
@kind = vms.kind
|
15
20
|
@resource_version = vms.resource_version
|
16
21
|
load vms
|
@@ -2,9 +2,10 @@ module Fog
|
|
2
2
|
module Compute
|
3
3
|
class Kubevirt
|
4
4
|
class Real
|
5
|
+
|
5
6
|
def create_vminstance(vm)
|
6
7
|
kubevirt_client.create_virtual_machine_instance(vm)
|
7
|
-
rescue
|
8
|
+
rescue ::Fog::Kubevirt::Errors::ClientError => err
|
8
9
|
log.warn(err)
|
9
10
|
raise ::Fog::Kubevirt::Errors::AlreadyExistsError
|
10
11
|
end
|
data/lib/fog/kubevirt.rb
CHANGED
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.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Kliczewski
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2018-
|
14
|
+
date: 2018-07-04 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|