fog-kubevirt 0.1.2 → 0.1.3
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 +27 -27
- data/lib/fog/compute/kubevirt/models/template.rb +15 -15
- data/lib/fog/compute/kubevirt/models/{offlinevm.rb → vm.rb} +9 -9
- data/lib/fog/compute/kubevirt/models/{livevm.rb → vminstance.rb} +2 -2
- data/lib/fog/compute/kubevirt/models/vminstances.rb +40 -0
- data/lib/fog/compute/kubevirt/models/vms.rb +25 -0
- data/lib/fog/compute/kubevirt/requests/create_vm.rb +2 -3
- data/lib/fog/compute/kubevirt/requests/{create_offlinevm.rb → create_vminstance.rb} +5 -4
- data/lib/fog/compute/kubevirt/requests/{delete_livevm.rb → delete_vm.rb} +2 -2
- data/lib/fog/compute/kubevirt/requests/delete_vminstance.rb +16 -0
- data/lib/fog/compute/kubevirt/requests/get_node.rb +1 -1
- data/lib/fog/compute/kubevirt/requests/get_vm.rb +24 -0
- data/lib/fog/compute/kubevirt/requests/{get_livevm.rb → get_vminstance.rb} +9 -9
- data/lib/fog/compute/kubevirt/requests/list_templates.rb +2 -2
- data/lib/fog/compute/kubevirt/requests/list_vminstances.rb +21 -0
- data/lib/fog/compute/kubevirt/requests/list_vms.rb +55 -0
- data/lib/fog/compute/kubevirt/requests/update_vm.rb +16 -0
- data/lib/fog/kubevirt/version.rb +1 -1
- metadata +14 -14
- data/lib/fog/compute/kubevirt/models/livevms.rb +0 -40
- data/lib/fog/compute/kubevirt/models/offlinevms.rb +0 -25
- data/lib/fog/compute/kubevirt/requests/delete_offlinevm.rb +0 -16
- data/lib/fog/compute/kubevirt/requests/get_offlinevm.rb +0 -24
- data/lib/fog/compute/kubevirt/requests/list_livevms.rb +0 -21
- data/lib/fog/compute/kubevirt/requests/list_offlinevms.rb +0 -52
- data/lib/fog/compute/kubevirt/requests/update_offlinevm.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5246648e5a5f2830f1ac4a9c177f02cd6d22cc5c
|
4
|
+
data.tar.gz: c11e2e2b8a2924b0a814560d872e2749d93cddbd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdce78cc9bd4e5ee885baeba9ba9f2098da3ff41b0a2e0e32ae534d2958c46cfc84b3e7acd5517154f4c35b1948a97bc2e2c6ba07b9bf4efd3755de45a71e8e5
|
7
|
+
data.tar.gz: 1c64fc9fd3d74b778323d47c6bf922d0cfbef6cf14ddcefa1aef03181cf47426f2ef1046faefbae5090bc2b7b66486f3e63339c05855971e4b9cc3c5dcd081a2
|
data/lib/fog/compute/kubevirt.rb
CHANGED
@@ -10,12 +10,12 @@ module Fog
|
|
10
10
|
recognizes :kubevirt_hostname, :kubevirt_port, :kubevirt_namespace, :kubevirt_log
|
11
11
|
|
12
12
|
model_path 'fog/compute/kubevirt/models'
|
13
|
-
model :
|
14
|
-
collection :
|
13
|
+
model :vminstance
|
14
|
+
collection :vminstances
|
15
15
|
model :node
|
16
16
|
collection :nodes
|
17
|
-
model :
|
18
|
-
collection :
|
17
|
+
model :vm
|
18
|
+
collection :vms
|
19
19
|
model :template
|
20
20
|
collection :templates
|
21
21
|
model :volume
|
@@ -24,19 +24,19 @@ module Fog
|
|
24
24
|
request_path 'fog/compute/kubevirt/requests'
|
25
25
|
|
26
26
|
request :create_vm
|
27
|
-
request :
|
27
|
+
request :create_vminstance
|
28
28
|
request :create_pvc
|
29
|
-
request :
|
30
|
-
request :
|
31
|
-
request :
|
29
|
+
request :delete_vminstance
|
30
|
+
request :delete_vm
|
31
|
+
request :get_vminstance
|
32
32
|
request :get_node
|
33
|
-
request :
|
33
|
+
request :get_vm
|
34
34
|
request :get_template
|
35
|
-
request :
|
35
|
+
request :list_vminstances
|
36
36
|
request :list_nodes
|
37
|
-
request :
|
37
|
+
request :list_vms
|
38
38
|
request :list_templates
|
39
|
-
request :
|
39
|
+
request :update_vm
|
40
40
|
|
41
41
|
module Shared
|
42
42
|
|
@@ -108,7 +108,7 @@ module Fog
|
|
108
108
|
# The API version and group of KubeVirt:
|
109
109
|
#
|
110
110
|
KUBEVIRT_GROUP = 'kubevirt.io'.freeze
|
111
|
-
KUBEVIRT_VERSION = '
|
111
|
+
KUBEVIRT_VERSION = 'v1alpha2'.freeze
|
112
112
|
|
113
113
|
def initialize(options={})
|
114
114
|
require 'kubeclient'
|
@@ -118,7 +118,7 @@ module Fog
|
|
118
118
|
@port = options[:kubevirt_port]
|
119
119
|
|
120
120
|
@log = options[:kubevirt_log]
|
121
|
-
@log ||= Logger.new(STDOUT)
|
121
|
+
@log ||= Logger::Logger.new(STDOUT)
|
122
122
|
|
123
123
|
@namespace = options[:kubevirt_namespace] || 'default'
|
124
124
|
|
@@ -193,37 +193,37 @@ module Fog
|
|
193
193
|
end
|
194
194
|
|
195
195
|
#
|
196
|
-
# Returns a watcher for
|
196
|
+
# Returns a watcher for virtual machines.
|
197
197
|
#
|
198
198
|
# @param opts [Hash] A hash with options for the watcher.
|
199
199
|
# @return [WatchWrapper] The watcher.
|
200
200
|
#
|
201
|
-
def
|
201
|
+
def watch_vms(opts = {})
|
202
202
|
mapper = Proc.new do |notice|
|
203
|
-
|
204
|
-
|
203
|
+
vm = OpenStruct.new(Vm.parse(notice.object)) if notice.object.kind == 'VirtualMachine'
|
204
|
+
vm ||= OpenStruct.new
|
205
205
|
|
206
|
-
populate_notice_attributes(
|
207
|
-
|
206
|
+
populate_notice_attributes(vm, notice)
|
207
|
+
vm
|
208
208
|
end
|
209
|
-
watch = kubevirt_client.
|
209
|
+
watch = kubevirt_client.watch_virtual_machines(opts)
|
210
210
|
|
211
211
|
WatchWrapper.new(watch, mapper)
|
212
212
|
end
|
213
213
|
|
214
214
|
#
|
215
|
-
# Returns a watcher for
|
215
|
+
# Returns a watcher for virtual machine instances.
|
216
216
|
#
|
217
217
|
# @param opts [Hash] A hash with options for the watcher.
|
218
218
|
# @return [WatchWrapper] The watcher.
|
219
219
|
#
|
220
|
-
def
|
220
|
+
def watch_vminstances(opts = {})
|
221
221
|
mapper = Proc.new do |notice|
|
222
|
-
|
223
|
-
|
222
|
+
vminstance = OpenStruct.new(Vminstance.parse(notice.object)) if notice.object.kind == 'VirtualMachine'
|
223
|
+
vminstance ||= OpenStruct.new
|
224
224
|
|
225
|
-
populate_notice_attributes(
|
226
|
-
|
225
|
+
populate_notice_attributes(vminstance, notice)
|
226
|
+
vminstance
|
227
227
|
end
|
228
228
|
watch = kubevirt_client.watch_virtual_machines(opts)
|
229
229
|
|
@@ -21,8 +21,8 @@ module Fog
|
|
21
21
|
# use persistent volume claims if any from a template and send
|
22
22
|
create_persistent_volume_claims(persistent_volume_claims_from_objects(objects), params, namespace)
|
23
23
|
|
24
|
-
# use
|
25
|
-
|
24
|
+
# use vm definition from a template and send
|
25
|
+
create_vm(vm_from_objects(objects), params, namespace)
|
26
26
|
end
|
27
27
|
|
28
28
|
def self.parse(object)
|
@@ -39,7 +39,7 @@ module Fog
|
|
39
39
|
:parameters => object[:parameters],
|
40
40
|
:description => annotations && annotations[:description],
|
41
41
|
:tags => annotations && annotations[:tags]
|
42
|
-
}
|
42
|
+
}
|
43
43
|
end
|
44
44
|
|
45
45
|
private
|
@@ -65,16 +65,16 @@ module Fog
|
|
65
65
|
end
|
66
66
|
|
67
67
|
#
|
68
|
-
# Creates
|
68
|
+
# Creates a virtual machine within provided namespace.
|
69
69
|
#
|
70
|
-
# @param
|
70
|
+
# @param vm [Hash] Virtual machine hash as defined in the template.
|
71
71
|
# @param params [Hash] Containing mapping of name and value.
|
72
72
|
# @param namespace [String] Namespace used to store the object.
|
73
73
|
#
|
74
|
-
def
|
75
|
-
|
74
|
+
def create_vm(vm, params, namespace)
|
75
|
+
vm = param_substitution!(vm, params)
|
76
76
|
os_labels = labels || {}
|
77
|
-
|
77
|
+
vm = deep_merge!(vm,
|
78
78
|
:spec => {
|
79
79
|
:running => false
|
80
80
|
},
|
@@ -83,7 +83,7 @@ module Fog
|
|
83
83
|
}
|
84
84
|
)
|
85
85
|
|
86
|
-
|
86
|
+
vm = deep_merge!(vm,
|
87
87
|
:metadata => {
|
88
88
|
:labels => {
|
89
89
|
OS_LABEL => os_labels[OS_LABEL_SYMBOL]
|
@@ -91,8 +91,8 @@ module Fog
|
|
91
91
|
}
|
92
92
|
) if os_labels[OS_LABEL_SYMBOL]
|
93
93
|
|
94
|
-
# Send the request to create the
|
95
|
-
|
94
|
+
# Send the request to create the virtual machine:
|
95
|
+
vm = service.create_vm(vm)
|
96
96
|
end
|
97
97
|
|
98
98
|
#
|
@@ -118,15 +118,15 @@ module Fog
|
|
118
118
|
end
|
119
119
|
|
120
120
|
#
|
121
|
-
# Returns object of `
|
121
|
+
# Returns object of `VirtualMachine` kind from provided objects.
|
122
122
|
#
|
123
123
|
# @param objects Array[Object] Objects defined in the template.
|
124
|
-
# @return [Hash]
|
124
|
+
# @return [Hash] Virtual machine hash
|
125
125
|
#
|
126
|
-
def
|
126
|
+
def vm_from_objects(objects)
|
127
127
|
vm = nil
|
128
128
|
objects.each do |object|
|
129
|
-
if object[:kind] == "
|
129
|
+
if object[:kind] == "VirtualMachine"
|
130
130
|
vm = object
|
131
131
|
end
|
132
132
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Fog
|
2
2
|
module Compute
|
3
3
|
class Kubevirt
|
4
|
-
class
|
4
|
+
class Vm < Fog::Model
|
5
5
|
include Shared
|
6
6
|
|
7
7
|
identity :name
|
@@ -19,25 +19,25 @@ module Fog
|
|
19
19
|
|
20
20
|
|
21
21
|
def start(options = {})
|
22
|
-
# Change the `running` attribute to `true` so that the
|
23
|
-
# create the
|
24
|
-
|
25
|
-
|
22
|
+
# Change the `running` attribute to `true` so that the virtual machine controller will take it and
|
23
|
+
# create the virtual machine instance.
|
24
|
+
vm = service.get_raw_vm(name)
|
25
|
+
vm = deep_merge!(vm,
|
26
26
|
:spec => {
|
27
27
|
:running => true
|
28
28
|
}
|
29
29
|
)
|
30
|
-
service.
|
30
|
+
service.update_vm(vm)
|
31
31
|
end
|
32
32
|
|
33
33
|
def stop(options = {})
|
34
|
-
|
35
|
-
|
34
|
+
vm = service.get_raw_vm(name)
|
35
|
+
vm = deep_merge!(vm,
|
36
36
|
:spec => {
|
37
37
|
:running => false
|
38
38
|
}
|
39
39
|
)
|
40
|
-
service.
|
40
|
+
service.update_vm(vm)
|
41
41
|
end
|
42
42
|
|
43
43
|
def self.parse(object)
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'fog/core/collection'
|
2
|
+
require 'fog/compute/kubevirt/models/vminstance'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module Compute
|
6
|
+
class Kubevirt
|
7
|
+
class Vminstances < Fog::Collection
|
8
|
+
attr_reader :kind, :resource_version
|
9
|
+
|
10
|
+
model Fog::Compute::Kubevirt::Vminstance
|
11
|
+
|
12
|
+
def all(filters = {})
|
13
|
+
vms = service.list_vminstances(filters)
|
14
|
+
kind = vms.kind
|
15
|
+
resource_version = vms.resource_version
|
16
|
+
load vms
|
17
|
+
end
|
18
|
+
|
19
|
+
def get(name)
|
20
|
+
new service.get_vminstance(name)
|
21
|
+
end
|
22
|
+
|
23
|
+
def destroy(name, namespace)
|
24
|
+
begin
|
25
|
+
vm_instance = get(name)
|
26
|
+
rescue Kubeclient::HttpError
|
27
|
+
# the virtual machine instance doesn't exist
|
28
|
+
vm_instance = nil
|
29
|
+
end
|
30
|
+
|
31
|
+
# delete vm
|
32
|
+
service.delete_vm(name, namespace)
|
33
|
+
|
34
|
+
# delete vm instance
|
35
|
+
service.delete_vminstance(name, namespace) unless vm_instance.nil?
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'fog/core/collection'
|
2
|
+
require 'fog/compute/kubevirt/models/vm'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module Compute
|
6
|
+
class Kubevirt
|
7
|
+
class Vms < Fog::Collection
|
8
|
+
attr_reader :kind, :resource_version
|
9
|
+
|
10
|
+
model Fog::Compute::Kubevirt::Vm
|
11
|
+
|
12
|
+
def all(filters = {})
|
13
|
+
vms = service.list_vms(filters)
|
14
|
+
kind = vms.kind
|
15
|
+
resource_version = vms.resource_version
|
16
|
+
load vms
|
17
|
+
end
|
18
|
+
|
19
|
+
def get(name)
|
20
|
+
new service.get_vm(name)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -4,15 +4,14 @@ module Fog
|
|
4
4
|
class Real
|
5
5
|
def create_vm(vm)
|
6
6
|
kubevirt_client.create_virtual_machine(vm)
|
7
|
-
rescue Kubeclient::HttpError
|
7
|
+
rescue Kubeclient::HttpError => err
|
8
8
|
log.warn(err)
|
9
9
|
raise ::Fog::Kubevirt::Errors::AlreadyExistsError
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
class Mock
|
14
|
-
def create_vm(vm)
|
15
|
-
end
|
14
|
+
def create_vm(vm); end
|
16
15
|
end
|
17
16
|
end
|
18
17
|
end
|
@@ -2,16 +2,17 @@ module Fog
|
|
2
2
|
module Compute
|
3
3
|
class Kubevirt
|
4
4
|
class Real
|
5
|
-
def
|
6
|
-
kubevirt_client.
|
7
|
-
rescue
|
5
|
+
def create_vminstance(vm)
|
6
|
+
kubevirt_client.create_virtual_machine_instance(vm)
|
7
|
+
rescue Kubeclient::HttpError => err
|
8
8
|
log.warn(err)
|
9
9
|
raise ::Fog::Kubevirt::Errors::AlreadyExistsError
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
class Mock
|
14
|
-
def
|
14
|
+
def create_vminstance(vm)
|
15
|
+
end
|
15
16
|
end
|
16
17
|
end
|
17
18
|
end
|
@@ -2,13 +2,13 @@ module Fog
|
|
2
2
|
module Compute
|
3
3
|
class Kubevirt
|
4
4
|
class Real
|
5
|
-
def
|
5
|
+
def delete_vm(name, namespace)
|
6
6
|
kubevirt_client.delete_virtual_machine(name, namespace)
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
10
|
class Mock
|
11
|
-
def
|
11
|
+
def delete_vm(name)
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Kubevirt
|
4
|
+
class Real
|
5
|
+
def delete_vminstance(name, namespace)
|
6
|
+
kubevirt_client.delete_virtual_machine_instance(name, namespace)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class Mock
|
11
|
+
def delete_virtual_machine_instance(name, namespace = nil)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Kubevirt
|
4
|
+
class Real
|
5
|
+
def get_vm(name)
|
6
|
+
Vm.parse get_raw_vm(name)
|
7
|
+
end
|
8
|
+
|
9
|
+
def get_raw_vm(name)
|
10
|
+
object_to_hash( kubevirt_client.get_virtual_machine(name, @namespace) )
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class Mock
|
15
|
+
# TODO provide implementation
|
16
|
+
def get_vm(name)
|
17
|
+
end
|
18
|
+
|
19
|
+
def get_raw_vm(name)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -4,28 +4,28 @@ module Fog
|
|
4
4
|
module Compute
|
5
5
|
class Kubevirt
|
6
6
|
class Real
|
7
|
-
def
|
7
|
+
def get_vminstance(name)
|
8
8
|
# namespace is defined on the Real object
|
9
|
-
|
9
|
+
Vminstance.parse object_to_hash( kubevirt_client.get_virtual_machine_instance(name, @namespace) )
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
class Mock
|
14
|
-
def
|
15
|
-
vm = { :apiVersion => "kubevirt.io/
|
16
|
-
:kind => "
|
14
|
+
def get_vminstance(name)
|
15
|
+
vm = { :apiVersion => "kubevirt.io/v1alpha2",
|
16
|
+
:kind => "VirtualMachineInstance",
|
17
17
|
:metadata => { :clusterName => "",
|
18
18
|
:creationTimestamp => "2018-02-23T10:12:47Z",
|
19
19
|
:name => "demo",
|
20
20
|
:namespace => "default",
|
21
|
-
:ownerReferences => [{ :apiVersion => "kubevirt.io/
|
22
|
-
:kind => "
|
21
|
+
:ownerReferences => [{ :apiVersion => "kubevirt.io/v1alpha2",
|
22
|
+
:kind => "VirtualMachine",
|
23
23
|
:name => "demo",
|
24
24
|
:uid => "57e279c1-17ee-11e8-a9f9-525400a7f647"
|
25
25
|
}
|
26
26
|
],
|
27
27
|
:resourceVersion => "84873",
|
28
|
-
:selfLink => "/apis/kubevirt.io/
|
28
|
+
:selfLink => "/apis/kubevirt.io/v1alpha2/namespaces/default/virtualmachineinstances/demo",
|
29
29
|
:uid => "1906421f-1882-11e8-b539-525400a7f647"
|
30
30
|
},
|
31
31
|
:spec => { :domain => { :cpu => { :cores => "4" },
|
@@ -52,7 +52,7 @@ module Fog
|
|
52
52
|
}
|
53
53
|
}
|
54
54
|
object = RecursiveOpenStruct.new(vm, recurse_over_arrays: true)
|
55
|
-
|
55
|
+
Vminstance.parse object_to_hash(object)
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
@@ -26,8 +26,8 @@ module Fog
|
|
26
26
|
annotations: { description: 'OCP kubevirt linux, template',
|
27
27
|
tags: 'kubevirt,ocp,template,linux' }
|
28
28
|
},
|
29
|
-
objects: [{ apiVersion: 'kubevirt.io/
|
30
|
-
kind: '
|
29
|
+
objects: [{ apiVersion: 'kubevirt.io/v1alpha2',
|
30
|
+
kind: 'VirtualMachine',
|
31
31
|
metadata: { name: '${NAME}' },
|
32
32
|
spec: { template: { spec: { domain:
|
33
33
|
{ cpu: { cores: '${CPU_CORES}' },
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class Kubevirt
|
4
|
+
class Real
|
5
|
+
def list_vminstances(_filters = {})
|
6
|
+
vminstances = kubevirt_client.get_virtual_machine_instances(namespace: @namespace)
|
7
|
+
entities = vminstances.map do |kubevirt_obj|
|
8
|
+
Vminstance.parse object_to_hash(kubevirt_obj)
|
9
|
+
end
|
10
|
+
EntityCollection.new(vminstances.kind, vminstances.resourceVersion, entities)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class Mock
|
15
|
+
# TODO provide implementation
|
16
|
+
def list_vminstances(_filters = {})
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'recursive_open_struct'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Compute
|
5
|
+
class Kubevirt
|
6
|
+
class Real
|
7
|
+
def list_vms(_filters = {})
|
8
|
+
vms = kubevirt_client.get_virtual_machines(namespace: @namespace)
|
9
|
+
entities = vms.map do |kubevirt_obj|
|
10
|
+
Vm.parse object_to_hash(kubevirt_obj)
|
11
|
+
end
|
12
|
+
EntityCollection.new(vms.kind, vms.resourceVersion, entities)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Mock
|
17
|
+
def list_vms(_filters = {})
|
18
|
+
vms = [{ apiVersion: 'kubevirt.io/v1alpha2',
|
19
|
+
kind: 'VirtualMachine',
|
20
|
+
metadata: {
|
21
|
+
clusterName: '',
|
22
|
+
creationTimestamp: '2018-02-21T11:15:41Z',
|
23
|
+
name: 'aaa',
|
24
|
+
namespace: 'default',
|
25
|
+
resourceVersion: '967810',
|
26
|
+
selfLink: '/apis/kubevirt.io/v1alpha2/namespaces/default/virtualmachines/aaa',
|
27
|
+
uid: '8d27ad76-16f8-11e8-95dc-525400b2cba8'
|
28
|
+
},
|
29
|
+
spec: {
|
30
|
+
template: {
|
31
|
+
spec: { domain: { cpu: { cores: 4 },
|
32
|
+
devices: { disks: [{ disk: { dev: 'vda' },
|
33
|
+
name: 'registrydisk',
|
34
|
+
volumeName: 'registryvolume' },
|
35
|
+
{ disk: { dev: 'vdb' },
|
36
|
+
name: 'cloudinitdisk',
|
37
|
+
volumeName: 'cloudinitvolume' }] },
|
38
|
+
machine: { type: 'q35' },
|
39
|
+
resources: { requests: { memory: '512Mi' } } },
|
40
|
+
volumes: [
|
41
|
+
{ name: 'registryvolume',
|
42
|
+
registryDisk: { image: 'kubevirt/fedora-cloud-registry-disk-demo:latest' }
|
43
|
+
},
|
44
|
+
{ cloudInitNoCloud: { userDataBase64: 'I2Nsb3VkLWNvbmZpZwpwYXNzd29yZDogYXRvbWljCnNzaF9wd2F1dGg6IFRydWUKY2hwYXNzd2Q6IHsgZXhwaXJlOiBGYWxzZSB9Cg==' },
|
45
|
+
name: 'cloudinitvolume' }]
|
46
|
+
}
|
47
|
+
}
|
48
|
+
}}]
|
49
|
+
object = RecursiveOpenStruct.new(vms, recurse_over_arrays: true)
|
50
|
+
object.map { |kubevirt_obj| Vm.parse object_to_hash(kubevirt_obj) }
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
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.3
|
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-06-18 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|
@@ -111,30 +111,30 @@ files:
|
|
111
111
|
- README.md
|
112
112
|
- lib/fog/bin/kubevirt.rb
|
113
113
|
- lib/fog/compute/kubevirt.rb
|
114
|
-
- lib/fog/compute/kubevirt/models/livevm.rb
|
115
|
-
- lib/fog/compute/kubevirt/models/livevms.rb
|
116
114
|
- lib/fog/compute/kubevirt/models/node.rb
|
117
115
|
- lib/fog/compute/kubevirt/models/nodes.rb
|
118
|
-
- lib/fog/compute/kubevirt/models/offlinevm.rb
|
119
|
-
- lib/fog/compute/kubevirt/models/offlinevms.rb
|
120
116
|
- lib/fog/compute/kubevirt/models/template.rb
|
121
117
|
- lib/fog/compute/kubevirt/models/templates.rb
|
118
|
+
- lib/fog/compute/kubevirt/models/vm.rb
|
119
|
+
- lib/fog/compute/kubevirt/models/vminstance.rb
|
120
|
+
- lib/fog/compute/kubevirt/models/vminstances.rb
|
121
|
+
- lib/fog/compute/kubevirt/models/vms.rb
|
122
122
|
- lib/fog/compute/kubevirt/models/volume.rb
|
123
123
|
- lib/fog/compute/kubevirt/models/volumes.rb
|
124
|
-
- lib/fog/compute/kubevirt/requests/create_offlinevm.rb
|
125
124
|
- lib/fog/compute/kubevirt/requests/create_pvc.rb
|
126
125
|
- lib/fog/compute/kubevirt/requests/create_vm.rb
|
127
|
-
- lib/fog/compute/kubevirt/requests/
|
128
|
-
- lib/fog/compute/kubevirt/requests/
|
129
|
-
- lib/fog/compute/kubevirt/requests/
|
126
|
+
- lib/fog/compute/kubevirt/requests/create_vminstance.rb
|
127
|
+
- lib/fog/compute/kubevirt/requests/delete_vm.rb
|
128
|
+
- lib/fog/compute/kubevirt/requests/delete_vminstance.rb
|
130
129
|
- lib/fog/compute/kubevirt/requests/get_node.rb
|
131
|
-
- lib/fog/compute/kubevirt/requests/get_offlinevm.rb
|
132
130
|
- lib/fog/compute/kubevirt/requests/get_template.rb
|
133
|
-
- lib/fog/compute/kubevirt/requests/
|
131
|
+
- lib/fog/compute/kubevirt/requests/get_vm.rb
|
132
|
+
- lib/fog/compute/kubevirt/requests/get_vminstance.rb
|
134
133
|
- lib/fog/compute/kubevirt/requests/list_nodes.rb
|
135
|
-
- lib/fog/compute/kubevirt/requests/list_offlinevms.rb
|
136
134
|
- lib/fog/compute/kubevirt/requests/list_templates.rb
|
137
|
-
- lib/fog/compute/kubevirt/requests/
|
135
|
+
- lib/fog/compute/kubevirt/requests/list_vminstances.rb
|
136
|
+
- lib/fog/compute/kubevirt/requests/list_vms.rb
|
137
|
+
- lib/fog/compute/kubevirt/requests/update_vm.rb
|
138
138
|
- lib/fog/kubevirt.rb
|
139
139
|
- lib/fog/kubevirt/version.rb
|
140
140
|
homepage: https://github.com/pkliczewski/fog-kubevirt
|
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'fog/core/collection'
|
2
|
-
require 'fog/compute/kubevirt/models/livevm'
|
3
|
-
|
4
|
-
module Fog
|
5
|
-
module Compute
|
6
|
-
class Kubevirt
|
7
|
-
class Livevms < Fog::Collection
|
8
|
-
attr_reader :kind, :resource_version
|
9
|
-
|
10
|
-
model Fog::Compute::Kubevirt::Livevm
|
11
|
-
|
12
|
-
def all(filters = {})
|
13
|
-
vms = service.list_livevms(filters)
|
14
|
-
kind = vms.kind
|
15
|
-
resource_version = vms.resource_version
|
16
|
-
load vms
|
17
|
-
end
|
18
|
-
|
19
|
-
def get(name)
|
20
|
-
new service.get_livevm(name)
|
21
|
-
end
|
22
|
-
|
23
|
-
def destroy(name, namespace)
|
24
|
-
begin
|
25
|
-
live_vm = get(name)
|
26
|
-
rescue KubeException
|
27
|
-
# the live virtual machine doesn't exist
|
28
|
-
live_vm = nil
|
29
|
-
end
|
30
|
-
|
31
|
-
# delete offline vm
|
32
|
-
service.delete_offlinevm(name, namespace)
|
33
|
-
|
34
|
-
# delete live vm
|
35
|
-
service.delete_livevm(name, namespace) unless live_vm.nil?
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'fog/core/collection'
|
2
|
-
require 'fog/compute/kubevirt/models/offlinevm'
|
3
|
-
|
4
|
-
module Fog
|
5
|
-
module Compute
|
6
|
-
class Kubevirt
|
7
|
-
class Offlinevms < Fog::Collection
|
8
|
-
attr_reader :kind, :resource_version
|
9
|
-
|
10
|
-
model Fog::Compute::Kubevirt::Offlinevm
|
11
|
-
|
12
|
-
def all(filters = {})
|
13
|
-
ovms = service.list_offlinevms(filters)
|
14
|
-
kind = ovms.kind
|
15
|
-
resource_version = ovms.resource_version
|
16
|
-
load ovms
|
17
|
-
end
|
18
|
-
|
19
|
-
def get(name)
|
20
|
-
new service.get_offlinevm(name)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module Fog
|
2
|
-
module Compute
|
3
|
-
class Kubevirt
|
4
|
-
class Real
|
5
|
-
def delete_offlinevm(name, namespace)
|
6
|
-
kubevirt_client.delete_offline_virtual_machine(name, namespace)
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
class Mock
|
11
|
-
def delete_offlinevm(name)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
module Fog
|
2
|
-
module Compute
|
3
|
-
class Kubevirt
|
4
|
-
class Real
|
5
|
-
def get_offlinevm(name)
|
6
|
-
Offlinevm.parse get_raw_offlinevm(name)
|
7
|
-
end
|
8
|
-
|
9
|
-
def get_raw_offlinevm(name)
|
10
|
-
object_to_hash( kubevirt_client.get_offline_virtual_machine(name, @namespace) )
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
class Mock
|
15
|
-
# TODO provide implementation
|
16
|
-
def get_offlinevm(name)
|
17
|
-
end
|
18
|
-
|
19
|
-
def get_raw_offlinevm(name)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module Fog
|
2
|
-
module Compute
|
3
|
-
class Kubevirt
|
4
|
-
class Real
|
5
|
-
def list_livevms(_filters = {})
|
6
|
-
vms = kubevirt_client.get_virtual_machines(namespace: @namespace)
|
7
|
-
entities = vms.map do |kubevirt_obj|
|
8
|
-
Livevm.parse object_to_hash(kubevirt_obj)
|
9
|
-
end
|
10
|
-
EntityCollection.new(vms.kind, vms.resourceVersion, entities)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
class Mock
|
15
|
-
# TODO provide implementation
|
16
|
-
def list_livevms(_filters = {})
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
require 'recursive_open_struct'
|
2
|
-
|
3
|
-
module Fog
|
4
|
-
module Compute
|
5
|
-
class Kubevirt
|
6
|
-
class Real
|
7
|
-
def list_offlinevms(_filters = {})
|
8
|
-
ovms = kubevirt_client.get_offline_virtual_machines(namespace: @namespace)
|
9
|
-
entities = ovms.map do |kubevirt_obj|
|
10
|
-
Offlinevm.parse object_to_hash(kubevirt_obj)
|
11
|
-
end
|
12
|
-
EntityCollection.new(ovms.kind, ovms.resourceVersion, entities)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
class Mock
|
17
|
-
def list_offlinevms(_filters = {})
|
18
|
-
offlinevms = [{ apiVersion: 'kubevirt.io/v1alpha1',
|
19
|
-
kind: 'OfflineVirtualMachine',
|
20
|
-
metadata: {
|
21
|
-
clusterName: '',
|
22
|
-
creationTimestamp: '2018-02-21T11:15:41Z',
|
23
|
-
name: 'aaa',
|
24
|
-
namespace: 'default',
|
25
|
-
resourceVersion: '967810',
|
26
|
-
selfLink: '/apis/kubevirt.io/v1alpha1/namespaces/default/offlinevirtualmachines/aaa',
|
27
|
-
uid: '8d27ad76-16f8-11e8-95dc-525400b2cba8'
|
28
|
-
},
|
29
|
-
spec: {
|
30
|
-
template: {
|
31
|
-
spec: { domain: { cpu: { cores: 4 },
|
32
|
-
devices: { disks: [{ disk: { dev: 'vda' },
|
33
|
-
name: 'registrydisk',
|
34
|
-
volumeName: 'registryvolume' },
|
35
|
-
{ disk: { dev: 'vdb' },
|
36
|
-
name: 'cloudinitdisk',
|
37
|
-
volumeName: 'cloudinitvolume' }] },
|
38
|
-
machine: { type: 'q35' },
|
39
|
-
resources: { requests: { memory: '512Mi' } } },
|
40
|
-
volumes: [{ name: 'registryvolume',
|
41
|
-
registryDisk: { image: 'kubevirt/fedora-cloud-registry-disk-demo:latest' } },
|
42
|
-
{ cloudInitNoCloud: { userDataBase64: 'I2Nsb3VkLWNvbmZpZwpwYXNzd29yZDogYXRvbWljCnNzaF9wd2F1dGg6IFRydWUKY2hwYXNzd2Q6IHsgZXhwaXJlOiBGYWxzZSB9Cg==' },
|
43
|
-
name: 'cloudinitvolume' }] }
|
44
|
-
}
|
45
|
-
} }]
|
46
|
-
object = RecursiveOpenStruct.new(offlinevms, recurse_over_arrays: true)
|
47
|
-
object.map { |kubevirt_obj| Offlinevm.parse object_to_hash(kubevirt_obj) }
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|