fog-kubevirt 1.1.2 → 1.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/kubevirt/compute/models/server.rb +1 -0
- data/lib/fog/kubevirt/compute/models/vm.rb +1 -0
- data/lib/fog/kubevirt/compute/models/vm_action.rb +29 -0
- data/lib/fog/kubevirt/compute/models/vm_base.rb +6 -32
- data/lib/fog/kubevirt/compute/models/vm_data.rb +0 -146
- data/lib/fog/kubevirt/compute/models/vm_parser.rb +141 -0
- data/lib/fog/kubevirt/compute/models/vminstance.rb +2 -2
- data/lib/fog/kubevirt/compute/models/vmnic.rb +20 -0
- data/lib/fog/kubevirt/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 394dc624c69b8bf42ce40a4bbc01215739f02af9
|
4
|
+
data.tar.gz: 6b8b0f38edf9f2c82717752e11a4fb50666110a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4e382201cf05aed39177df9b0eb83007361ef195bb900819e2b15e415df21459b69dd75a604b337359b5153b3111dd5ff1ca3edb151c9b58a131ee07a4cb6ff
|
7
|
+
data.tar.gz: 2f4b6871e21d29ef6cf75f051850cb7dfd22956153e5976806f81f1ad7ea7cb5b5b040e758ef1c458deec2543bd41c85ada9232d5f7db6141edaf37217b5cef3
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Fog
|
2
|
+
module Kubevirt
|
3
|
+
class Compute
|
4
|
+
module VmAction
|
5
|
+
def start(options = {})
|
6
|
+
# Change the `running` attribute to `true` so that the virtual machine controller will take it and
|
7
|
+
# create the virtual machine instance.
|
8
|
+
vm = service.get_raw_vm(name)
|
9
|
+
vm = deep_merge!(vm,
|
10
|
+
:spec => {
|
11
|
+
:running => true
|
12
|
+
}
|
13
|
+
)
|
14
|
+
service.update_vm(vm)
|
15
|
+
end
|
16
|
+
|
17
|
+
def stop(options = {})
|
18
|
+
vm = service.get_raw_vm(name)
|
19
|
+
vm = deep_merge!(vm,
|
20
|
+
:spec => {
|
21
|
+
:running => false
|
22
|
+
}
|
23
|
+
)
|
24
|
+
service.update_vm(vm)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require 'fog/kubevirt/compute/models/
|
1
|
+
require 'fog/kubevirt/compute/models/vm_parser'
|
2
2
|
|
3
3
|
module Fog
|
4
4
|
module Kubevirt
|
5
5
|
class Compute
|
6
6
|
module VmBase
|
7
|
-
include
|
7
|
+
include VmParser
|
8
8
|
|
9
9
|
def define_properties
|
10
10
|
identity :name
|
@@ -17,11 +17,11 @@ module Fog
|
|
17
17
|
attribute :annotations, :aliases => 'metadata_annotations'
|
18
18
|
attribute :cpu_cores, :aliases => 'spec_cpu_cores'
|
19
19
|
attribute :memory, :aliases => 'spec_memory'
|
20
|
-
attribute :disks, :aliases => 'spec_disks'
|
21
|
-
attribute :volumes, :aliases => 'spec_volumes'
|
20
|
+
attribute :disks, :aliases => 'spec_disks', :default => []
|
21
|
+
attribute :volumes, :aliases => 'spec_volumes', :default => []
|
22
22
|
attribute :status, :aliases => 'spec_running'
|
23
|
-
attribute :interfaces, :aliases => 'spec_interfaces'
|
24
|
-
attribute :networks, :aliases => 'spec_networks'
|
23
|
+
attribute :interfaces, :aliases => 'spec_interfaces', :default => []
|
24
|
+
attribute :networks, :aliases => 'spec_networks', :default => []
|
25
25
|
attribute :machine_type, :aliases => 'spec_machine_type'
|
26
26
|
end
|
27
27
|
|
@@ -55,32 +55,6 @@ module Fog
|
|
55
55
|
vm
|
56
56
|
end
|
57
57
|
end
|
58
|
-
|
59
|
-
module VmAction
|
60
|
-
include Shared
|
61
|
-
|
62
|
-
def start(options = {})
|
63
|
-
# Change the `running` attribute to `true` so that the virtual machine controller will take it and
|
64
|
-
# create the virtual machine instance.
|
65
|
-
vm = service.get_raw_vm(name)
|
66
|
-
vm = deep_merge!(vm,
|
67
|
-
:spec => {
|
68
|
-
:running => true
|
69
|
-
}
|
70
|
-
)
|
71
|
-
service.update_vm(vm)
|
72
|
-
end
|
73
|
-
|
74
|
-
def stop(options = {})
|
75
|
-
vm = service.get_raw_vm(name)
|
76
|
-
vm = deep_merge!(vm,
|
77
|
-
:spec => {
|
78
|
-
:running => false
|
79
|
-
}
|
80
|
-
)
|
81
|
-
service.update_vm(vm)
|
82
|
-
end
|
83
|
-
end
|
84
58
|
end
|
85
59
|
end
|
86
60
|
end
|
@@ -1,154 +1,8 @@
|
|
1
|
-
require 'fog/kubevirt/compute/models/volume'
|
2
|
-
|
3
1
|
module Fog
|
4
2
|
module Kubevirt
|
5
3
|
class Compute
|
6
4
|
module VmData
|
7
5
|
|
8
|
-
#
|
9
|
-
# Returns an array of parsed network interfaces
|
10
|
-
#
|
11
|
-
# @param object [Hash] A hash with raw interfaces data.
|
12
|
-
#
|
13
|
-
def parse_interfaces(object)
|
14
|
-
return {} if object.nil?
|
15
|
-
nics = []
|
16
|
-
object.each do |iface|
|
17
|
-
nic = VmNic.new
|
18
|
-
nic.name = iface[:name]
|
19
|
-
nic.mac_address = iface[:macAddress]
|
20
|
-
nic.type = 'bridge' if iface.keys.include?(:bridge)
|
21
|
-
nic.type = 'slirp' if iface.keys.include?(:slirp)
|
22
|
-
nics << nic
|
23
|
-
end
|
24
|
-
|
25
|
-
nics
|
26
|
-
end
|
27
|
-
|
28
|
-
#
|
29
|
-
# Returns an array of parsed networks
|
30
|
-
#
|
31
|
-
# @param object [Hash] A hash with raw networks data.
|
32
|
-
#
|
33
|
-
def parse_networks(object)
|
34
|
-
return {} if object.nil?
|
35
|
-
networks = []
|
36
|
-
object.each do |net|
|
37
|
-
network = VmNetwork.new
|
38
|
-
network.name = net[:name]
|
39
|
-
network.type = 'pod' if net.keys.include?(:pod)
|
40
|
-
network.type = 'multus' if net.keys.include?(:multus)
|
41
|
-
network.type = 'genie' if net.keys.include?(:genie)
|
42
|
-
networks << network
|
43
|
-
end
|
44
|
-
|
45
|
-
networks
|
46
|
-
end
|
47
|
-
|
48
|
-
#
|
49
|
-
# Returns an array of parsed disks
|
50
|
-
#
|
51
|
-
# @param object [Hash] A hash with raw disks data.
|
52
|
-
#
|
53
|
-
def parse_disks(object)
|
54
|
-
return {} if object.nil?
|
55
|
-
disks = []
|
56
|
-
object.each do |d|
|
57
|
-
disk = VmDisk.new
|
58
|
-
disk.name = d[:name]
|
59
|
-
disk.boot_order = d[:bootOrder]
|
60
|
-
|
61
|
-
if d.keys.include?(:cdrom)
|
62
|
-
disk.type = 'cdrom'
|
63
|
-
disk.bus = d.dig(:cdrom, :bus)
|
64
|
-
disk.readonly = d.dig(:cdrom, :readonly)
|
65
|
-
elsif d.keys.include?(:disk)
|
66
|
-
disk.type = 'disk'
|
67
|
-
disk.bus = d.dig(:disk, :bus)
|
68
|
-
disk.readonly = d.dig(:disk, :readonly)
|
69
|
-
elsif d.keys.include?(:floppy)
|
70
|
-
disk.type = 'floppy'
|
71
|
-
disk.readonly = d.dig(:floppy, :readonly)
|
72
|
-
elsif d.keys.include?(:lun)
|
73
|
-
disk.type = 'lun'
|
74
|
-
disk.readonly = d.dig(:lun, :readonly)
|
75
|
-
end
|
76
|
-
disks << disk
|
77
|
-
end
|
78
|
-
|
79
|
-
disks
|
80
|
-
end
|
81
|
-
|
82
|
-
#
|
83
|
-
# Returns an array of parsed volumes
|
84
|
-
#
|
85
|
-
# @param object [Hash] A hash with raw volumes data.
|
86
|
-
# @param disks [Array] the disks of the vm associated to the volumes
|
87
|
-
#
|
88
|
-
def parse_volumes(object, disks)
|
89
|
-
return {} if object.nil?
|
90
|
-
volumes = []
|
91
|
-
object.each do |v|
|
92
|
-
volume = Volume.new
|
93
|
-
volume.name = v[:name]
|
94
|
-
if v.keys.include?(:containerDisk)
|
95
|
-
volume.type = 'containerDisk'
|
96
|
-
volume.info = v.dig(:containerDisk, :image)
|
97
|
-
elsif v.keys.include?(:persistentVolumeClaim)
|
98
|
-
volume.type = 'persistentVolumeClaim'
|
99
|
-
volume.info = v.dig(:persistentVolumeClaim, :claimName)
|
100
|
-
elsif v.keys.include?(:emptyDisk)
|
101
|
-
volume.type = 'emptyDisk'
|
102
|
-
volume.info = v.dig(:emptyDisk, :capacity)
|
103
|
-
elsif v.keys.include?(:ephemeral)
|
104
|
-
volume.type = 'ephemeral'
|
105
|
-
volume.info = v.dig(:ephemeral, :persistentVolumeClaim, :claimName)
|
106
|
-
elsif v.keys.include?(:cloudInitNoCloud)
|
107
|
-
volume.type = 'cloudInitNoCloud'
|
108
|
-
volume.info = v.dig(:cloudInitNoCloud, :userDataBase64)
|
109
|
-
elsif v.keys.include?(:hostDisk)
|
110
|
-
volume.type = 'hostDisk'
|
111
|
-
volume.info = v.dig(:hostDisk, :path)
|
112
|
-
elsif v.keys.include?(:secret)
|
113
|
-
volume.type = 'secret'
|
114
|
-
volume.info = v.dig(:secret, :secretName)
|
115
|
-
elsif v.keys.include?(:dataVolume)
|
116
|
-
volume.type = 'dataVolume'
|
117
|
-
volume.info = v.dig(:dataVolume, :name)
|
118
|
-
elsif v.keys.include?(:serviceAccount)
|
119
|
-
volume.type = 'serviceAccount'
|
120
|
-
volume.info = v.dig(:serviceAccount, :serviceAccountName)
|
121
|
-
elsif v.keys.include?(:configMap)
|
122
|
-
volume.type = 'configMap'
|
123
|
-
volume.info = v.dig(:configMap, :name)
|
124
|
-
end
|
125
|
-
|
126
|
-
volume.config = v[volume.type.to_sym]
|
127
|
-
disk = disks.select { |d| d.name == volume.name }.first
|
128
|
-
volume.boot_order = disk.boot_order
|
129
|
-
volume.bus = disk.bus if disk.respond_to?(:bus)
|
130
|
-
|
131
|
-
volumes << volume
|
132
|
-
end
|
133
|
-
|
134
|
-
volumes
|
135
|
-
end
|
136
|
-
|
137
|
-
class VmNic < Fog::Model
|
138
|
-
attr_accessor :name
|
139
|
-
|
140
|
-
attribute :mac_address
|
141
|
-
attribute :type # values: bridge, slirp
|
142
|
-
attribute :model
|
143
|
-
attribute :ports
|
144
|
-
attribute :boot_order
|
145
|
-
alias :mac :mac_address
|
146
|
-
|
147
|
-
def persisted?
|
148
|
-
!name.nil?
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
6
|
class VmNetwork
|
153
7
|
attr_accessor :name,
|
154
8
|
:type # values: multus, pod, genie
|
@@ -0,0 +1,141 @@
|
|
1
|
+
require 'fog/kubevirt/compute/models/volume'
|
2
|
+
require 'fog/kubevirt/compute/models/vmnic'
|
3
|
+
require 'fog/kubevirt/compute/models/vm_data'
|
4
|
+
|
5
|
+
module Fog
|
6
|
+
module Kubevirt
|
7
|
+
class Compute
|
8
|
+
module VmParser
|
9
|
+
|
10
|
+
#
|
11
|
+
# Returns an array of parsed network interfaces
|
12
|
+
#
|
13
|
+
# @param object [Hash] A hash with raw interfaces data.
|
14
|
+
#
|
15
|
+
def parse_interfaces(object)
|
16
|
+
return {} if object.nil?
|
17
|
+
nics = []
|
18
|
+
object.each do |iface|
|
19
|
+
nic = VmNic.new
|
20
|
+
nic.name = iface[:name]
|
21
|
+
nic.mac_address = iface[:macAddress]
|
22
|
+
nic.type = 'bridge' if iface.keys.include?(:bridge)
|
23
|
+
nic.type = 'slirp' if iface.keys.include?(:slirp)
|
24
|
+
nics << nic
|
25
|
+
end
|
26
|
+
|
27
|
+
nics
|
28
|
+
end
|
29
|
+
|
30
|
+
#
|
31
|
+
# Returns an array of parsed networks
|
32
|
+
#
|
33
|
+
# @param object [Hash] A hash with raw networks data.
|
34
|
+
#
|
35
|
+
def parse_networks(object)
|
36
|
+
return {} if object.nil?
|
37
|
+
networks = []
|
38
|
+
object.each do |net|
|
39
|
+
network = VmData::VmNetwork.new
|
40
|
+
network.name = net[:name]
|
41
|
+
network.type = 'pod' if net.keys.include?(:pod)
|
42
|
+
network.type = 'multus' if net.keys.include?(:multus)
|
43
|
+
network.type = 'genie' if net.keys.include?(:genie)
|
44
|
+
networks << network
|
45
|
+
end
|
46
|
+
|
47
|
+
networks
|
48
|
+
end
|
49
|
+
|
50
|
+
#
|
51
|
+
# Returns an array of parsed disks
|
52
|
+
#
|
53
|
+
# @param object [Hash] A hash with raw disks data.
|
54
|
+
#
|
55
|
+
def parse_disks(object)
|
56
|
+
return {} if object.nil?
|
57
|
+
disks = []
|
58
|
+
object.each do |d|
|
59
|
+
disk = VmData::VmDisk.new
|
60
|
+
disk.name = d[:name]
|
61
|
+
disk.boot_order = d[:bootOrder]
|
62
|
+
|
63
|
+
if d.keys.include?(:cdrom)
|
64
|
+
disk.type = 'cdrom'
|
65
|
+
disk.bus = d.dig(:cdrom, :bus)
|
66
|
+
disk.readonly = d.dig(:cdrom, :readonly)
|
67
|
+
elsif d.keys.include?(:disk)
|
68
|
+
disk.type = 'disk'
|
69
|
+
disk.bus = d.dig(:disk, :bus)
|
70
|
+
disk.readonly = d.dig(:disk, :readonly)
|
71
|
+
elsif d.keys.include?(:floppy)
|
72
|
+
disk.type = 'floppy'
|
73
|
+
disk.readonly = d.dig(:floppy, :readonly)
|
74
|
+
elsif d.keys.include?(:lun)
|
75
|
+
disk.type = 'lun'
|
76
|
+
disk.readonly = d.dig(:lun, :readonly)
|
77
|
+
end
|
78
|
+
disks << disk
|
79
|
+
end
|
80
|
+
|
81
|
+
disks
|
82
|
+
end
|
83
|
+
|
84
|
+
#
|
85
|
+
# Returns an array of parsed volumes
|
86
|
+
#
|
87
|
+
# @param object [Hash] A hash with raw volumes data.
|
88
|
+
# @param disks [Array] the disks of the vm associated to the volumes
|
89
|
+
#
|
90
|
+
def parse_volumes(object, disks)
|
91
|
+
return {} if object.nil?
|
92
|
+
volumes = []
|
93
|
+
object.each do |v|
|
94
|
+
volume = Volume.new
|
95
|
+
volume.name = v[:name]
|
96
|
+
if v.keys.include?(:containerDisk)
|
97
|
+
volume.type = 'containerDisk'
|
98
|
+
volume.info = v.dig(:containerDisk, :image)
|
99
|
+
elsif v.keys.include?(:persistentVolumeClaim)
|
100
|
+
volume.type = 'persistentVolumeClaim'
|
101
|
+
volume.info = v.dig(:persistentVolumeClaim, :claimName)
|
102
|
+
elsif v.keys.include?(:emptyDisk)
|
103
|
+
volume.type = 'emptyDisk'
|
104
|
+
volume.info = v.dig(:emptyDisk, :capacity)
|
105
|
+
elsif v.keys.include?(:ephemeral)
|
106
|
+
volume.type = 'ephemeral'
|
107
|
+
volume.info = v.dig(:ephemeral, :persistentVolumeClaim, :claimName)
|
108
|
+
elsif v.keys.include?(:cloudInitNoCloud)
|
109
|
+
volume.type = 'cloudInitNoCloud'
|
110
|
+
volume.info = v.dig(:cloudInitNoCloud, :userDataBase64)
|
111
|
+
elsif v.keys.include?(:hostDisk)
|
112
|
+
volume.type = 'hostDisk'
|
113
|
+
volume.info = v.dig(:hostDisk, :path)
|
114
|
+
elsif v.keys.include?(:secret)
|
115
|
+
volume.type = 'secret'
|
116
|
+
volume.info = v.dig(:secret, :secretName)
|
117
|
+
elsif v.keys.include?(:dataVolume)
|
118
|
+
volume.type = 'dataVolume'
|
119
|
+
volume.info = v.dig(:dataVolume, :name)
|
120
|
+
elsif v.keys.include?(:serviceAccount)
|
121
|
+
volume.type = 'serviceAccount'
|
122
|
+
volume.info = v.dig(:serviceAccount, :serviceAccountName)
|
123
|
+
elsif v.keys.include?(:configMap)
|
124
|
+
volume.type = 'configMap'
|
125
|
+
volume.info = v.dig(:configMap, :name)
|
126
|
+
end
|
127
|
+
|
128
|
+
volume.config = v[volume.type.to_sym]
|
129
|
+
disk = disks.select { |d| d.name == volume.name }.first
|
130
|
+
volume.boot_order = disk.boot_order
|
131
|
+
volume.bus = disk.bus if disk.respond_to?(:bus)
|
132
|
+
|
133
|
+
volumes << volume
|
134
|
+
end
|
135
|
+
|
136
|
+
volumes
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Fog
|
2
|
+
module Kubevirt
|
3
|
+
class Compute
|
4
|
+
class VmNic < Fog::Model
|
5
|
+
identity :mac_address
|
6
|
+
attr_accessor :name
|
7
|
+
|
8
|
+
attribute :type # values: bridge, slirp
|
9
|
+
attribute :model
|
10
|
+
attribute :ports
|
11
|
+
attribute :boot_order
|
12
|
+
alias :mac :mac_address
|
13
|
+
|
14
|
+
def persisted?
|
15
|
+
!name.nil?
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
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: 1.1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Kliczewski
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2019-04-
|
16
|
+
date: 2019-04-05 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: minitest
|
@@ -161,10 +161,13 @@ files:
|
|
161
161
|
- lib/fog/kubevirt/compute/models/template.rb
|
162
162
|
- lib/fog/kubevirt/compute/models/templates.rb
|
163
163
|
- lib/fog/kubevirt/compute/models/vm.rb
|
164
|
+
- lib/fog/kubevirt/compute/models/vm_action.rb
|
164
165
|
- lib/fog/kubevirt/compute/models/vm_base.rb
|
165
166
|
- lib/fog/kubevirt/compute/models/vm_data.rb
|
167
|
+
- lib/fog/kubevirt/compute/models/vm_parser.rb
|
166
168
|
- lib/fog/kubevirt/compute/models/vminstance.rb
|
167
169
|
- lib/fog/kubevirt/compute/models/vminstances.rb
|
170
|
+
- lib/fog/kubevirt/compute/models/vmnic.rb
|
168
171
|
- lib/fog/kubevirt/compute/models/vms.rb
|
169
172
|
- lib/fog/kubevirt/compute/models/volume.rb
|
170
173
|
- lib/fog/kubevirt/compute/models/volumes.rb
|