fog-kubevirt 1.2.2 → 1.2.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/vm_base.rb +3 -2
- data/lib/fog/kubevirt/compute/models/vm_data.rb +3 -2
- data/lib/fog/kubevirt/compute/models/vm_parser.rb +13 -3
- data/lib/fog/kubevirt/compute/models/vminstance.rb +3 -2
- data/lib/fog/kubevirt/compute/models/vmnic.rb +2 -0
- data/lib/fog/kubevirt/compute/requests/get_server.rb +4 -1
- data/lib/fog/kubevirt/version.rb +1 -1
- data/spec/create_vm_spec.rb +3 -3
- data/spec/pvcs_v1alpha2_spec.rb +2 -2
- data/spec/vm_parse_spec.rb +45 -0
- metadata +4 -4
- data/spec/vm_parse.rb +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e1ad47434b4be227ffa7e32f9435021980784c0
|
4
|
+
data.tar.gz: 78189c5ee24ea2f3a3314c1c32e242a2dc66a764
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d128816adb81bb5e438348537003b6893305cf3df4c9ebac3a611db2ebb974bfbfa360fb6937e0ccaff0292ca68d2f410107fd3d02b440842d61619d2a064d3
|
7
|
+
data.tar.gz: 34b7f11414b8dec2720386485e25e2d0746579566828d5e2cebf85f75d2d27de9b9dce2774122b4674f7e65c9319b4c135ca5ef3affebd7e8ac0ed3a4f15f06d
|
@@ -34,6 +34,7 @@ module Fog
|
|
34
34
|
cpu = domain[:cpu]
|
35
35
|
mem = domain.dig(:resources, :requests, :memory)
|
36
36
|
disks = parse_disks(domain[:devices][:disks])
|
37
|
+
networks = parse_networks(spec[:networks])
|
37
38
|
vm = {
|
38
39
|
:namespace => metadata[:namespace],
|
39
40
|
:name => metadata[:name],
|
@@ -43,8 +44,8 @@ module Fog
|
|
43
44
|
:disks => disks,
|
44
45
|
:volumes => parse_volumes(spec[:volumes], disks),
|
45
46
|
:status => object[:spec][:running].to_s == "true" ? "running" : "stopped",
|
46
|
-
:interfaces => parse_interfaces(domain[:devices][:interfaces], object[:status].nil? ? [] : object[:status][:interfaces]),
|
47
|
-
:networks =>
|
47
|
+
:interfaces => parse_interfaces(domain[:devices][:interfaces], object[:status].nil? ? [] : object[:status][:interfaces], networks),
|
48
|
+
:networks => networks,
|
48
49
|
:machine_type => domain.dig(:machine, :type)
|
49
50
|
}
|
50
51
|
vm[:owner_reference] = owner unless owner.nil?
|
@@ -4,8 +4,9 @@ module Fog
|
|
4
4
|
module VmData
|
5
5
|
|
6
6
|
class VmNetwork
|
7
|
-
attr_accessor :name,
|
8
|
-
:type # values: multus, pod, genie
|
7
|
+
attr_accessor :name, # inner name used to map to interface
|
8
|
+
:type, # values: multus, pod, genie
|
9
|
+
:network_name # name of network attachment definition
|
9
10
|
end
|
10
11
|
|
11
12
|
class VmDisk
|
@@ -12,7 +12,7 @@ module Fog
|
|
12
12
|
#
|
13
13
|
# @param object [Hash] A hash with raw interfaces data.
|
14
14
|
#
|
15
|
-
def parse_interfaces(object, object_status)
|
15
|
+
def parse_interfaces(object, object_status, networks)
|
16
16
|
return {} if object.nil?
|
17
17
|
nics = []
|
18
18
|
object.each do |iface|
|
@@ -23,6 +23,13 @@ module Fog
|
|
23
23
|
nic.mac_address = !status_iface.nil? && status_iface.key?(:mac) ? status_iface[:mac] : iface[:macAddress]
|
24
24
|
nic.type = 'bridge' if iface.keys.include?(:bridge)
|
25
25
|
nic.type = 'slirp' if iface.keys.include?(:slirp)
|
26
|
+
|
27
|
+
net = networks.detect { |n| n.name == iface[:name] }
|
28
|
+
if net
|
29
|
+
nic.cni_provider = net.type
|
30
|
+
nic.network = net.network_name
|
31
|
+
end
|
32
|
+
|
26
33
|
nics << nic
|
27
34
|
end
|
28
35
|
|
@@ -41,7 +48,10 @@ module Fog
|
|
41
48
|
network = VmData::VmNetwork.new
|
42
49
|
network.name = net[:name]
|
43
50
|
network.type = 'pod' if net.keys.include?(:pod)
|
44
|
-
|
51
|
+
if net.keys.include?(:multus)
|
52
|
+
network.type = 'multus'
|
53
|
+
network.network_name = net[:multus][:networkName]
|
54
|
+
end
|
45
55
|
network.type = 'genie' if net.keys.include?(:genie)
|
46
56
|
networks << network
|
47
57
|
end
|
@@ -128,7 +138,7 @@ module Fog
|
|
128
138
|
end
|
129
139
|
|
130
140
|
volume.config = v[volume.type.to_sym]
|
131
|
-
disk = disks.
|
141
|
+
disk = disks.detect { |d| d.name == volume.name }
|
132
142
|
volume.boot_order = disk.boot_order
|
133
143
|
volume.bus = disk.bus if disk.respond_to?(:bus)
|
134
144
|
|
@@ -29,6 +29,7 @@ module Fog
|
|
29
29
|
spec = object[:spec]
|
30
30
|
domain = spec[:domain]
|
31
31
|
disks = parse_disks(domain[:devices][:disks])
|
32
|
+
networks = parse_networks(spec[:networks])
|
32
33
|
{
|
33
34
|
:namespace => metadata[:namespace],
|
34
35
|
:name => metadata[:name],
|
@@ -40,8 +41,8 @@ module Fog
|
|
40
41
|
:memory => domain[:resources][:requests][:memory],
|
41
42
|
:disks => disks,
|
42
43
|
:volumes => parse_volumes(spec[:volumes], disks),
|
43
|
-
:interfaces => parse_interfaces(domain[:devices][:interfaces], status[:interfaces]),
|
44
|
-
:networks =>
|
44
|
+
:interfaces => parse_interfaces(domain[:devices][:interfaces], status[:interfaces], networks),
|
45
|
+
:networks => networks,
|
45
46
|
:ip_address => status.dig(:interfaces, 0, :ipAddress),
|
46
47
|
:node_name => status[:nodeName],
|
47
48
|
:status => status[:phase]
|
@@ -47,13 +47,15 @@ module Fog
|
|
47
47
|
disk
|
48
48
|
end
|
49
49
|
|
50
|
-
def vm_nic(mac_address: "")
|
50
|
+
def vm_nic(mac_address: "", network: "ovs-foreman")
|
51
51
|
vm_nic = Fog::Kubevirt::Compute::VmNic.new
|
52
52
|
vm_nic.mac_address = mac_address
|
53
53
|
vm_nic.type = "bridge"
|
54
|
+
vm_nic.network = network
|
54
55
|
vm_nic.model = nil
|
55
56
|
vm_nic.ports = nil
|
56
57
|
vm_nic.boot_order = nil
|
58
|
+
vm_nic
|
57
59
|
end
|
58
60
|
|
59
61
|
def get_server(name)
|
@@ -69,6 +71,7 @@ module Fog
|
|
69
71
|
vm_network = Fog::Kubevirt::Compute::VmData::VmNetwork.new
|
70
72
|
vm_network.name="ovs-foreman"
|
71
73
|
vm_network.type="multus"
|
74
|
+
vm_network.network_name="ovs-foreman"
|
72
75
|
|
73
76
|
interfaces = name != 'no_interfaces' ? [vm_nic(mac_address: "a2:b4:a2:b6:a2:a8")] : nil
|
74
77
|
|
data/lib/fog/kubevirt/version.rb
CHANGED
data/spec/create_vm_spec.rb
CHANGED
@@ -58,7 +58,7 @@ describe Fog::Compute do
|
|
58
58
|
assert_equal(volumes.count, 3)
|
59
59
|
|
60
60
|
# verify first claim values
|
61
|
-
volume = volumes.
|
61
|
+
volume = volumes.detect { |v| v.name == 'test-disk-01' }
|
62
62
|
refute_nil(volume)
|
63
63
|
refute_nil(volume.pvc)
|
64
64
|
assert_equal(volume.name, 'test-disk-01')
|
@@ -66,7 +66,7 @@ describe Fog::Compute do
|
|
66
66
|
assert_equal(volume.type, 'persistentVolumeClaim')
|
67
67
|
|
68
68
|
# verify second claim values
|
69
|
-
volume = volumes.
|
69
|
+
volume = volumes.detect { |v| v.name == 'test-disk-02' }
|
70
70
|
refute_nil(volume)
|
71
71
|
refute_nil(volume.pvc)
|
72
72
|
assert_equal(volume.pvc.name, pvc2)
|
@@ -74,7 +74,7 @@ describe Fog::Compute do
|
|
74
74
|
assert_equal(volume.type, 'persistentVolumeClaim')
|
75
75
|
|
76
76
|
# verify third claim values
|
77
|
-
volume = volumes.
|
77
|
+
volume = volumes.detect { |v| v.name == 'test-disk-03' }
|
78
78
|
refute_nil(volume)
|
79
79
|
assert_equal(volume.name, 'test-disk-03')
|
80
80
|
assert_equal(volume.type, 'hostDisk')
|
data/spec/pvcs_v1alpha2_spec.rb
CHANGED
@@ -49,7 +49,7 @@ require 'spec_helper'
|
|
49
49
|
|
50
50
|
# test all volumes based on PVCs
|
51
51
|
volumes = @service.volumes.all
|
52
|
-
volume = volumes.
|
52
|
+
volume = volumes.detect { |v| v.name == name }
|
53
53
|
refute_nil(volume)
|
54
54
|
assert_equal(volume.name, 'my-local-storage-pvc')
|
55
55
|
assert_equal(volume.type, 'persistentVolumeClaim')
|
@@ -90,7 +90,7 @@ require 'spec_helper'
|
|
90
90
|
|
91
91
|
# test all volumes based on PVCs
|
92
92
|
volumes = @service.volumes.all
|
93
|
-
volume = volumes.
|
93
|
+
volume = volumes.detect { |v| v.name == name }
|
94
94
|
refute_nil(volume)
|
95
95
|
assert_equal(volume.name, 'my-local-storage-pvc')
|
96
96
|
assert_equal(volume.type, 'persistentVolumeClaim')
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Fog::Kubevirt::Compute do
|
4
|
+
it 'parses vm' do
|
5
|
+
Fog.mock!
|
6
|
+
mock = Fog::Kubevirt::Compute.new
|
7
|
+
vm = mock.get_vm('test')
|
8
|
+
|
9
|
+
assert_nil(vm[:interfaces][0].mac_address)
|
10
|
+
assert_nil(vm[:interfaces][1].mac_address)
|
11
|
+
Fog.unmock!
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'parses vmi' do
|
15
|
+
Fog.mock!
|
16
|
+
mock = Fog::Kubevirt::Compute.new
|
17
|
+
vm = mock.get_vminstance('test')
|
18
|
+
|
19
|
+
assert_equal(vm[:interfaces][0].mac_address, '0e:fc:6c:c3:20:ec')
|
20
|
+
assert_equal(vm[:interfaces][1].mac_address, '4a:90:1c:2e:fe:d7')
|
21
|
+
Fog.unmock!
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'parses not ready server' do
|
25
|
+
Fog.mock!
|
26
|
+
mock = Fog::Kubevirt::Compute.new
|
27
|
+
server = mock.get_server('no_interfaces')
|
28
|
+
|
29
|
+
assert_nil(server[:interfaces])
|
30
|
+
Fog.unmock!
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'parses vm interface of pod network' do
|
34
|
+
Fog.mock!
|
35
|
+
mock = Fog::Kubevirt::Compute.new
|
36
|
+
vm = mock.get_vm('robin-rykert.example.com')
|
37
|
+
|
38
|
+
assert_nil(vm[:interfaces][0].network)
|
39
|
+
assert_equal(vm[:interfaces][0].cni_provider, "pod")
|
40
|
+
|
41
|
+
assert_equal(vm[:interfaces][1].network, "ptp-conf")
|
42
|
+
assert_equal(vm[:interfaces][1].cni_provider, "multus")
|
43
|
+
Fog.unmock!
|
44
|
+
end
|
45
|
+
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.2.
|
4
|
+
version: 1.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Kliczewski
|
@@ -14,7 +14,7 @@ authors:
|
|
14
14
|
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
|
-
date: 2019-04-
|
17
|
+
date: 2019-04-15 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: minitest
|
@@ -226,7 +226,7 @@ files:
|
|
226
226
|
- spec/shared_context.rb
|
227
227
|
- spec/spec_helper.rb
|
228
228
|
- spec/storage_classes_v1_spec.rb
|
229
|
-
- spec/
|
229
|
+
- spec/vm_parse_spec.rb
|
230
230
|
homepage: https://github.com/pkliczewski/fog-kubevirt
|
231
231
|
licenses:
|
232
232
|
- Apache-2.0
|
@@ -268,4 +268,4 @@ test_files:
|
|
268
268
|
- spec/shared_context.rb
|
269
269
|
- spec/spec_helper.rb
|
270
270
|
- spec/storage_classes_v1_spec.rb
|
271
|
-
- spec/
|
271
|
+
- spec/vm_parse_spec.rb
|
data/spec/vm_parse.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
describe Fog::Kubevirt::Compute do
|
2
|
-
it 'parses vm' do
|
3
|
-
mock = Fog::Kubevirt::Compute::Mock.new
|
4
|
-
vm = mock.get_vm('test')
|
5
|
-
|
6
|
-
assert_nil(vm[:interfaces][0].mac_address)
|
7
|
-
assert_nil(vm[:interfaces][1].mac_address)
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'parses vmi' do
|
11
|
-
mock = Fog::Kubevirt::Compute::Mock.new
|
12
|
-
vm = mock.get_vminstance('test')
|
13
|
-
|
14
|
-
assert_equal(vm[:interfaces][0].mac_address, '0e:fc:6c:c3:20:ec')
|
15
|
-
assert_equal(vm[:interfaces][1].mac_address, '4a:90:1c:2e:fe:d7')
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'parses not ready server' do
|
19
|
-
mock = Fog::Kubevirt::Compute::Mock.new
|
20
|
-
server = mock.get_server('no_interfaces')
|
21
|
-
|
22
|
-
assert_nil(server[:interfaces])
|
23
|
-
end
|
24
|
-
end
|