fog-kubevirt 1.1.3 → 1.2.0
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/compute.rb +2 -4
- data/lib/fog/kubevirt/compute/models/server.rb +3 -3
- data/lib/fog/kubevirt/compute/requests/create_pvc.rb +86 -1
- data/lib/fog/kubevirt/compute/requests/create_vm.rb +122 -1
- data/lib/fog/kubevirt/compute/requests/get_server.rb +92 -1
- data/lib/fog/kubevirt/compute/requests/list_networkattachmentdefs.rb +10 -1
- data/lib/fog/kubevirt/compute/requests/list_storageclasses.rb +12 -0
- data/lib/fog/kubevirt/compute/requests/update_vm.rb +136 -2
- data/lib/fog/kubevirt/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d1fc639c608aa3c0bd89f32e9add52b726df21a
|
4
|
+
data.tar.gz: e4ac9e0849cd5804cb3bf21c0ba0dc31652bf8d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d84beb7ef3b1ed0a1c88ecfa08e064a85dbb4d9ae3ac3f60f81f7be8c9fc6415ada3a70d732f4def3ffc5a689fd1eba569e1322410a9a8c532b7d4bbe11d7a06
|
7
|
+
data.tar.gz: fa71d52ada8bbf8a397646c32a5b22c656cd40f0c8c4d44abc6396b4055163ed10896a5865cc105317149fdd8dd66c4a18f30caecc466d1713cfe369f8fb024b
|
@@ -520,16 +520,14 @@ module Fog
|
|
520
520
|
class Mock
|
521
521
|
include Shared
|
522
522
|
|
523
|
+
attr_accessor :namespace
|
523
524
|
def initialize(options={})
|
525
|
+
@namespace = options[:namespace]
|
524
526
|
end
|
525
527
|
|
526
|
-
private
|
527
|
-
|
528
528
|
def client
|
529
529
|
return @client if defined?(@client)
|
530
530
|
end
|
531
|
-
|
532
|
-
# TODO provide mocking
|
533
531
|
end
|
534
532
|
end
|
535
533
|
end
|
@@ -11,7 +11,7 @@ module Fog
|
|
11
11
|
extend VmBase
|
12
12
|
define_properties
|
13
13
|
|
14
|
-
attribute :
|
14
|
+
attribute :phase
|
15
15
|
attribute :ip_address
|
16
16
|
attribute :node_name
|
17
17
|
|
@@ -23,12 +23,12 @@ module Fog
|
|
23
23
|
# TODO: Once IP Addresses are reported to any networks, we should consider also
|
24
24
|
# the availabity of it (by extending the condition with !ip_address.empty?)
|
25
25
|
def ready?
|
26
|
-
running?(status) && running?(
|
26
|
+
running?(status) && running?(phase)
|
27
27
|
end
|
28
28
|
|
29
29
|
def self.parse(object)
|
30
30
|
server = parse_object(object)
|
31
|
-
server[:
|
31
|
+
server[:phase] = object[:phase]
|
32
32
|
server[:node_name] = object[:node_name]
|
33
33
|
server[:ip_address] = object[:ip_address]
|
34
34
|
server
|
@@ -11,7 +11,92 @@ module Fog
|
|
11
11
|
end
|
12
12
|
|
13
13
|
class Mock
|
14
|
-
def create_pvc(attrs)
|
14
|
+
def create_pvc(attrs)
|
15
|
+
attrs_set_1g = {:apiVersion=>"v1",
|
16
|
+
:kind=>"PersistentVolumeClaim",
|
17
|
+
:metadata=>{:name=>"robin-rykert-example-com-claim-1",
|
18
|
+
:namespace=>"default"},
|
19
|
+
:spec=>{:storageClassName=>"local-storage",
|
20
|
+
:resources=>{:requests=>{:storage=>"1G"}},
|
21
|
+
:selector=>{},
|
22
|
+
:accessModes=>["ReadWriteOnce"]}}
|
23
|
+
if attrs == attrs_set_1g
|
24
|
+
result = Kubeclient::Resource.new
|
25
|
+
result.kind = "PersistentVolumeClaim"
|
26
|
+
result.apiVersion="v1"
|
27
|
+
result.metadata = {:name=>"robin-rykert-example-com-claim-1",
|
28
|
+
:namespace=>"default",
|
29
|
+
:selfLink=>"/api/v1/namespaces/default/persistentvolumeclaims/robin-rykert-example-com-claim-1",
|
30
|
+
:uid=>"00a7e1d7-5875-11e9-9132-525400c5a686",
|
31
|
+
:resourceVersion=>"1020273",
|
32
|
+
:creationTimestamp=>"2019-04-06T14:05:15Z"}
|
33
|
+
result.spec = {:accessModes=>["ReadWriteOnce"],
|
34
|
+
:selector=>{},
|
35
|
+
:resources=>{:requests=>{:storage=>"1G"}},
|
36
|
+
:storageClassName=>"local-storage",
|
37
|
+
:volumeMode=>"Filesystem",
|
38
|
+
:dataSource=>nil}
|
39
|
+
result.status = {:phase=>"Pending"}
|
40
|
+
return result
|
41
|
+
end
|
42
|
+
|
43
|
+
attrs_set_2g = {:apiVersion=>"v1",
|
44
|
+
:kind=>"PersistentVolumeClaim",
|
45
|
+
:metadata=>{:name=>"robin-rykert-example-com-claim-2",
|
46
|
+
:namespace=>"default"},
|
47
|
+
:spec=>{:storageClassName=>"local-storage",
|
48
|
+
:resources=>{:requests=>{:storage=>"2G"}},
|
49
|
+
:selector=>{},
|
50
|
+
:accessModes=>["ReadWriteOnce"]}}
|
51
|
+
if attrs == attrs_set_2g
|
52
|
+
result = Kubeclient::Resource.new
|
53
|
+
result.kind="PersistentVolumeClaim"
|
54
|
+
result.apiVersion="v1"
|
55
|
+
result.metadata = {:name=>"robin-rykert-example-com-claim-2",
|
56
|
+
:namespace=>"default",
|
57
|
+
:selfLink=>"/api/v1/namespaces/default/persistentvolumeclaims/robin-rykert-example-com-claim-2",
|
58
|
+
:uid=>"00aa08ba-5875-11e9-9132-525400c5a686",
|
59
|
+
:resourceVersion=>"1020274",
|
60
|
+
:creationTimestamp=>"2019-04-06T14:05:15Z"}
|
61
|
+
result.spec = {:accessModes=>["ReadWriteOnce"],
|
62
|
+
:selector=>{},
|
63
|
+
:resources=>{:requests=>{:storage=>"2G"}},
|
64
|
+
:storageClassName=>"local-storage",
|
65
|
+
:volumeMode=>"Filesystem",
|
66
|
+
:dataSource=>nil}
|
67
|
+
result.status = {:phase=>"Pending"}
|
68
|
+
return result
|
69
|
+
end
|
70
|
+
|
71
|
+
attrs_set_1g_image = {:apiVersion=>"v1",
|
72
|
+
:kind=>"PersistentVolumeClaim",
|
73
|
+
:metadata=>{:name=>"olive-kempter-example-com-claim-1",
|
74
|
+
:namespace=>"default"},
|
75
|
+
:spec=>{:storageClassName=>"local-storage",
|
76
|
+
:resources=>{:requests=>{:storage=>"1G"}},
|
77
|
+
:selector=>{},
|
78
|
+
:accessModes=>["ReadWriteOnce"]}}
|
79
|
+
|
80
|
+
if attrs == attrs_set_1g_image
|
81
|
+
result = Kubeclient::Resource.new
|
82
|
+
result.kind="PersistentVolumeClaim"
|
83
|
+
result.apiVersion="v1"
|
84
|
+
result.metadata={:name=>"olive-kempter-example-com-claim-1",
|
85
|
+
:namespace=>"default",
|
86
|
+
:selfLink=>"/api/v1/namespaces/default/persistentvolumeclaims/olive-kempter-example-com-claim-1",
|
87
|
+
:uid=>"d4d63298-5945-11e9-9132-525400c5a686",
|
88
|
+
:resourceVersion=>"1075554",
|
89
|
+
:creationTimestamp=>"2019-04-07T15:00:06Z"}
|
90
|
+
result.spec={:accessModes=>["ReadWriteOnce"],
|
91
|
+
:selector=>{},
|
92
|
+
:resources=>{:requests=>{:storage=>"1G"}},
|
93
|
+
:storageClassName=>"local-storage",
|
94
|
+
:volumeMode=>"Filesystem",
|
95
|
+
:dataSource=>nil}
|
96
|
+
result.status={:phase=>"Pending"}
|
97
|
+
result
|
98
|
+
end
|
99
|
+
end
|
15
100
|
end
|
16
101
|
end
|
17
102
|
end
|
@@ -13,7 +13,128 @@ module Fog
|
|
13
13
|
end
|
14
14
|
|
15
15
|
class Mock
|
16
|
-
def create_vm(vm)
|
16
|
+
def create_vm(vm)
|
17
|
+
args_network_based ={:kind=>"VirtualMachine",
|
18
|
+
:metadata=>{:labels=>{:"kubevirt.io/vm"=>"robin-rykert.example.com"},
|
19
|
+
:name=>"robin-rykert.example.com",
|
20
|
+
:namespace=>"default"},
|
21
|
+
:spec=>{:running=>false,
|
22
|
+
:template=>{:metadata=>{:creationTimestamp=>nil,
|
23
|
+
:labels=>{:"kubevirt.io/vm"=>"robin-rykert.example.com"}},
|
24
|
+
:spec=>{:domain=>{:devices=>{:disks=>[{:name=>"robin-rykert-example-com-disk-00",
|
25
|
+
:disk=>{:bus=>"virtio"}},
|
26
|
+
{:name=>"robin-rykert-example-com-disk-01",
|
27
|
+
:disk=>{:bus=>"virtio"}}],
|
28
|
+
:interfaces=>[{:bridge=>{},
|
29
|
+
:name=>"ovs-foreman",
|
30
|
+
:bootOrder=>1,
|
31
|
+
:macAddress=>"a2:b4:a2:b6:a2:a8"}]},
|
32
|
+
:machine=>{:type=>""},
|
33
|
+
:resources=>{:requests=>{:memory=>"1024M"}},
|
34
|
+
:cpu=>{:cores=>1}},
|
35
|
+
:terminationGracePeriodSeconds=>0,
|
36
|
+
:volumes=>[{:name=>"robin-rykert-example-com-disk-00",
|
37
|
+
:persistentVolumeClaim=>{:claimName=>"robin-rykert-example-com-claim-1"}},
|
38
|
+
{:name=>"robin-rykert-example-com-disk-01",
|
39
|
+
:persistentVolumeClaim=>{:claimName=>"robin-rykert-example-com-claim-2"}}],
|
40
|
+
:networks=>[{:name=>"ovs-foreman",
|
41
|
+
:multus=>{:networkName=>"ovs-foreman"}}]}}}}
|
42
|
+
if vm == args_network_based
|
43
|
+
result = Kubeclient::Resource.new
|
44
|
+
result.apiVersion="kubevirt.io/v1alpha3"
|
45
|
+
result.kind="VirtualMachine"
|
46
|
+
result.metadata={:creationTimestamp=>"2019-04-06T14:05:15Z",
|
47
|
+
:generation=>1,
|
48
|
+
:labels=>{:"kubevirt.io/vm"=>"robin-rykert.example.com"},
|
49
|
+
:name=>"robin-rykert.example.com",
|
50
|
+
:namespace=>"default",
|
51
|
+
:resourceVersion=>"1020275",
|
52
|
+
:selfLink=>"/apis/kubevirt.io/v1alpha3/namespaces/default/virtualmachines/robin-rykert.example.com",
|
53
|
+
:uid=>"00ae63ee-5875-11e9-9132-525400c5a686"}
|
54
|
+
result.spec={:running=>false,
|
55
|
+
:template=>{:metadata=>{:creationTimestamp=>nil,
|
56
|
+
:labels=>{:"kubevirt.io/vm"=>"robin-rykert.example.com"}},
|
57
|
+
:spec=>{:domain=>{:cpu=>{:cores=>1},
|
58
|
+
:devices=>{:disks=>[{:disk=>{:bus=>"virtio"},
|
59
|
+
:name=>"robin-rykert-example-com-disk-00"},
|
60
|
+
{:disk=>{:bus=>"virtio"},
|
61
|
+
:name=>"robin-rykert-example-com-disk-01"}],
|
62
|
+
:interfaces=>[{:bootOrder=>1,
|
63
|
+
:bridge=>{},
|
64
|
+
:macAddress=>"a2:b4:a2:b6:a2:a8",
|
65
|
+
:name=>"ovs-foreman"}]},
|
66
|
+
:machine=>{:type=>""},
|
67
|
+
:resources=>{:requests=>{:memory=>"1024M"}}},
|
68
|
+
:networks=>[{:multus=>{:networkName=>"ovs-foreman"},
|
69
|
+
:name=>"ovs-foreman"}],
|
70
|
+
:terminationGracePeriodSeconds=>0,
|
71
|
+
:volumes=>[{:name=>"robin-rykert-example-com-disk-00",
|
72
|
+
:persistentVolumeClaim=>{:claimName=>"robin-rykert-example-com-claim-1"}},
|
73
|
+
{:name=>"robin-rykert-example-com-disk-01",
|
74
|
+
:persistentVolumeClaim=>{:claimName=>"robin-rykert-example-com-claim-2"}}]}}}
|
75
|
+
return result
|
76
|
+
end
|
77
|
+
|
78
|
+
args_image_based = {:kind=>"VirtualMachine",
|
79
|
+
:metadata=>{:labels=>{:"kubevirt.io/vm"=>"olive-kempter.example.com"},
|
80
|
+
:name=>"olive-kempter.example.com",
|
81
|
+
:namespace=>"default"},
|
82
|
+
:spec=>{:running=>false,
|
83
|
+
:template=>{:metadata=>{:creationTimestamp=>nil,
|
84
|
+
:labels=>{:"kubevirt.io/vm"=>"olive-kempter.example.com"}},
|
85
|
+
:spec=>{:domain=>{:devices=>{:disks=>[{:name=>"olive-kempter-example-com-disk-00",
|
86
|
+
:disk=>{:bus=>"virtio"},
|
87
|
+
:bootOrder=>1},
|
88
|
+
{:name=>"olive-kempter-example-com-disk-01",
|
89
|
+
:disk=>{:bus=>"virtio"}}],
|
90
|
+
:interfaces=>[{:bridge=>{},
|
91
|
+
:name=>"ovs-foreman",
|
92
|
+
:macAddress=>"a2:a4:a2:b2:a2:b6"}]},
|
93
|
+
:machine=>{:type=>""},
|
94
|
+
:resources=>{:requests=>{:memory=>"1024M"}},
|
95
|
+
:cpu=>{:cores=>1}},
|
96
|
+
:terminationGracePeriodSeconds=>0,
|
97
|
+
:volumes=>[{:name=>"olive-kempter-example-com-disk-00",
|
98
|
+
:containerDisk=>{:image=>"kubevirt/fedora-cloud-registry-disk-demo"}},
|
99
|
+
{:name=>"olive-kempter-example-com-disk-01",
|
100
|
+
:persistentVolumeClaim=>{:claimName=>"olive-kempter-example-com-claim-1"}}],
|
101
|
+
:networks=>[{:name=>"ovs-foreman",
|
102
|
+
:multus=>{:networkName=>"ovs-foreman"}}]}}}}
|
103
|
+
if vm == args_image_based
|
104
|
+
result = Kubeclient::Resource.new
|
105
|
+
result.apiVersion="kubevirt.io/v1alpha3"
|
106
|
+
result.kind = "VirtualMachine"
|
107
|
+
result.metadata={:creationTimestamp=>"2019-04-07T15:00:07Z",
|
108
|
+
:generation=>1,
|
109
|
+
:labels=>{:"kubevirt.io/vm"=>"olive-kempter.example.com"},
|
110
|
+
:name=>"olive-kempter.example.com",
|
111
|
+
:namespace=>"default",
|
112
|
+
:resourceVersion=>"1075555",
|
113
|
+
:selfLink=>"/apis/kubevirt.io/v1alpha3/namespaces/default/virtualmachines/olive-kempter.example.com",
|
114
|
+
:uid=>"d4dba9e4-5945-11e9-9132-525400c5a686"},
|
115
|
+
result.spec={:running=>false,
|
116
|
+
:template=>{:metadata=>{:creationTimestamp=>nil,
|
117
|
+
:labels=>{:"kubevirt.io/vm"=>"olive-kempter.example.com"}},
|
118
|
+
:spec=>{:domain=>{:cpu=>{:cores=>1},
|
119
|
+
:devices=>{:disks=>[{:bootOrder=>1,
|
120
|
+
:disk=>{:bus=>"virtio"},
|
121
|
+
:name=>"olive-kempter-example-com-disk-00"},
|
122
|
+
{:disk=>{:bus=>"virtio"},
|
123
|
+
:name=>"olive-kempter-example-com-disk-01"}],
|
124
|
+
:interfaces=>[{:bridge=>{},
|
125
|
+
:macAddress=>"a2:a4:a2:b2:a2:b6",
|
126
|
+
:name=>"ovs-foreman"}]},
|
127
|
+
:machine=>{:type=>""},
|
128
|
+
:resources=>{:requests=>{:memory=>"1024M"}}},
|
129
|
+
:networks=>[{:multus=>{:networkName=>"ovs-foreman"},
|
130
|
+
:name=>"ovs-foreman"}],
|
131
|
+
:terminationGracePeriodSeconds=>0,
|
132
|
+
:volumes=>[{:containerDisk=>{:image=>"kubevirt/fedora-cloud-registry-disk-demo"},
|
133
|
+
:name=>"olive-kempter-example-com-disk-00"},
|
134
|
+
{:name=>"olive-kempter-example-com-disk-01",
|
135
|
+
:persistentVolumeClaim=>{:claimName=>"olive-kempter-example-com-claim-1"}}]}}}
|
136
|
+
end
|
137
|
+
end
|
17
138
|
end
|
18
139
|
end
|
19
140
|
end
|
@@ -23,8 +23,99 @@ module Fog
|
|
23
23
|
end
|
24
24
|
|
25
25
|
class Mock
|
26
|
-
|
26
|
+
def volume(name: "", type: "persistentVolumeClaim", info: "", pvc: nil, config: {}, boot_order: nil, bus: nil)
|
27
|
+
volume = Fog::Kubevirt::Compute::Volume.new
|
28
|
+
volume.name = name
|
29
|
+
volume.type = type
|
30
|
+
volume.info = info
|
31
|
+
volume.pvc = pvc
|
32
|
+
volume.config = config
|
33
|
+
volume.boot_order = boot_order
|
34
|
+
volume.bus = bus
|
35
|
+
volume
|
36
|
+
end
|
37
|
+
|
38
|
+
def disk(name: "", boot_order: nil, type: "disk", bus: "virtio", readonly: nil)
|
39
|
+
disk = Fog::Kubevirt::Compute::VmData::VmDisk.new
|
40
|
+
disk.name = name
|
41
|
+
disk.boot_order = boot_order
|
42
|
+
disk.type = type
|
43
|
+
disk.bus = bus
|
44
|
+
disk.readonly = readonly
|
45
|
+
disk
|
46
|
+
end
|
47
|
+
|
48
|
+
def vm_nic(mac_address: "")
|
49
|
+
vm_nic = Fog::Kubevirt::Compute::VmNic.new
|
50
|
+
vm_nic.mac_address = mac_address
|
51
|
+
vm_nic.type = "bridge"
|
52
|
+
vm_nic.model = nil
|
53
|
+
vm_nic.ports = nil
|
54
|
+
vm_nic.boot_order = nil
|
55
|
+
end
|
56
|
+
|
27
57
|
def get_server(name)
|
58
|
+
if name == "robin-rykert.example.com"
|
59
|
+
disk1 = disk(name: "robin-rykert-example-com-disk-00", boot_order: nil,type: "disk", bus: "virtio", readonly: nil)
|
60
|
+
disk2 = disk(name: "robin-rykert-example-com-disk-01", boot_order: nil,type: "disk", bus: "virtio", readonly: nil)
|
61
|
+
|
62
|
+
volume1 = volume(name: "robin-rykert-example-com-disk-00", type: "persistentVolumeClaim", info: "robin-rykert-example-com-claim-1",
|
63
|
+
pvc: nil, config: {:claimName=>"robin-rykert-example-com-claim-1"}, boot_order: nil, bus: "virtio")
|
64
|
+
volume2 = volume(name: "robin-rykert-example-com-disk-01", type: "persistentVolumeClaim", info: "robin-rykert-example-com-claim-2",
|
65
|
+
pvc: nil, config: {:claimName=>"robin-rykert-example-com-claim-2"}, boot_order: nil, bus: "virtio")
|
66
|
+
|
67
|
+
vm_network = Fog::Kubevirt::Compute::VmData::VmNetwork.new
|
68
|
+
vm_network.name="ovs-foreman"
|
69
|
+
vm_network.type="multus"
|
70
|
+
|
71
|
+
return {
|
72
|
+
:namespace=>"default",
|
73
|
+
:name=>"robin-rykert.example.com",
|
74
|
+
:resource_version=>"1020275",
|
75
|
+
:uid=>"00ae63ee-5875-11e9-9132-525400c5a686",
|
76
|
+
:labels=>{:"kubevirt.io/vm"=>"robin-rykert.example.com"},
|
77
|
+
:disks=>[disk1, disk2],
|
78
|
+
:volumes=>[volume1, volume2],
|
79
|
+
:status=>"stopped",
|
80
|
+
:interfaces=>[vm_nic(mac_address: "a2:b4:a2:b6:a2:a8")],
|
81
|
+
:networks=>[vm_network],
|
82
|
+
:machine_type=>"",
|
83
|
+
:cpu_cores=>1,
|
84
|
+
:memory=>"1024M",
|
85
|
+
:state=>nil,
|
86
|
+
:node_name=>nil,
|
87
|
+
:ip_address=>nil
|
88
|
+
}
|
89
|
+
end
|
90
|
+
|
91
|
+
if name == "olive-kempter.example.com"
|
92
|
+
disk1 = disk(name: "olive-kempter-example-com-disk-00", boot_order: nil,type: "disk", bus: "virtio", readonly: nil)
|
93
|
+
disk2 = disk(name: "olive-kempter-example-com-disk-01", boot_order: nil,type: "disk", bus: "virtio", readonly: nil)
|
94
|
+
volume1 = volume(name: "olive-kempter-example-com-disk-00", type: "containerDisk", info: "kubevirt/fedora-cloud-registry-disk-demo",
|
95
|
+
pvc: nil, config: {:image=>"kubevirt/fedora-cloud-registry-disk-demo"}, boot_order: nil, bus: "virtio")
|
96
|
+
volume2 = volume(name: "olive-kempter-example-com-disk-01", type: "containerDisk", info: "olive-kempter-example-com-claim-1",
|
97
|
+
pvc: nil, config: {:claimName=>"olive-kempter-example-com-claim-1"}, boot_order: nil, bus: "virtio")
|
98
|
+
return {
|
99
|
+
:namespace => "default",
|
100
|
+
:name =>"olive-kempter.example.com",
|
101
|
+
:resource_version => "1075555",
|
102
|
+
:uid => "d4dba9e4-5945-11e9-9132-525400c5a686",
|
103
|
+
:labels => {:"kubevirt.io/vm"=>"olive-kempter.example.com"},
|
104
|
+
:disks => [disk1, disk2],
|
105
|
+
:volumes => [ volume1, volume2],
|
106
|
+
:status => "stopped",
|
107
|
+
:interfaces => [vm_nic(mac_address: "a2:a4:a2:b2:a2:b6")],
|
108
|
+
:networks => [vm_network],
|
109
|
+
:machine_type => "",
|
110
|
+
:cpu_cores => 1,
|
111
|
+
:memory => "1024M",
|
112
|
+
:state => nil,
|
113
|
+
:node_name => nil,
|
114
|
+
:ip_address => nil
|
115
|
+
}
|
116
|
+
end
|
117
|
+
|
118
|
+
raise ::Fog::Kubevirt::Errors::ClientError, "HTTP status code 404, virtualmachines.kubevirt.io \"#{name}\" not found for GET"
|
28
119
|
end
|
29
120
|
end
|
30
121
|
end
|
@@ -12,8 +12,17 @@ module Fog
|
|
12
12
|
end
|
13
13
|
|
14
14
|
class Mock
|
15
|
-
# TODO provide implementation
|
16
15
|
def list_networkattachmentdefs(_filters = {})
|
16
|
+
if _filters == {}
|
17
|
+
EntityCollection.new("NetworkAttachmentDefinition", "1080",
|
18
|
+
[{:namespace=>"default",
|
19
|
+
:name=>"ovs-foreman",
|
20
|
+
:resource_version=>"1080",
|
21
|
+
:uid=>"0e35b868-2464-11e9-93b4-525400c5a686",
|
22
|
+
:config=>"{ \"cniVersion\": \"0.3.1\",\"type\": \"ovs\",\"bridge\": \"foreman\" }"
|
23
|
+
}]
|
24
|
+
)
|
25
|
+
end
|
17
26
|
end
|
18
27
|
end
|
19
28
|
end
|
@@ -15,6 +15,18 @@ module Fog
|
|
15
15
|
|
16
16
|
class Mock
|
17
17
|
def list_storageclasses(_filters = {})
|
18
|
+
if _filters == {}
|
19
|
+
[{
|
20
|
+
:name=>"local-storage",
|
21
|
+
:resource_version=>"775504",
|
22
|
+
:uid=>"c930bca9-5471-11e9-9132-525400c5a686",
|
23
|
+
:parameters=>nil,
|
24
|
+
:mount_options=>nil,
|
25
|
+
:provisioner=>"kubernetes.io/no-provisioner",
|
26
|
+
:reclaim_policy=>"Delete",
|
27
|
+
:volume_binding_mode=>"WaitForFirstConsumer"
|
28
|
+
}]
|
29
|
+
end
|
18
30
|
end
|
19
31
|
end
|
20
32
|
end
|
@@ -8,8 +8,142 @@ module Fog
|
|
8
8
|
end
|
9
9
|
|
10
10
|
class Mock
|
11
|
-
|
12
|
-
|
11
|
+
def update_vm(update)
|
12
|
+
update_args = {:apiVersion=>"kubevirt.io/v1alpha3",
|
13
|
+
:kind=>"VirtualMachine",
|
14
|
+
:metadata=>{:creationTimestamp=>"2019-04-06T14:05:15Z",
|
15
|
+
:generation=>1,
|
16
|
+
:labels=>{:"kubevirt.io/vm"=>"robin-rykert.example.com"},
|
17
|
+
:name=>"robin-rykert.example.com",
|
18
|
+
:namespace=>"default",
|
19
|
+
:resourceVersion=>"1020275",
|
20
|
+
:selfLink=>"/apis/kubevirt.io/v1alpha3/namespaces/default/virtualmachines/robin-rykert.example.com",
|
21
|
+
:uid=>"00ae63ee-5875-11e9-9132-525400c5a686"},
|
22
|
+
:spec=>{:running=>true,
|
23
|
+
:template=>{:metadata=>{:creationTimestamp=>nil,
|
24
|
+
:labels=>{:"kubevirt.io/vm"=>"robin-rykert.example.com"}},
|
25
|
+
:spec=>{:domain=>{:cpu=>{:cores=>1},
|
26
|
+
:devices=>{:disks=>[{:disk=>{:bus=>"virtio"},
|
27
|
+
:name=>"robin-rykert-example-com-disk-00"},
|
28
|
+
{:disk=>{:bus=>"virtio"},
|
29
|
+
:name=>"robin-rykert-example-com-disk-01"}],
|
30
|
+
:interfaces=>[{:bootOrder=>1,
|
31
|
+
:bridge=>{},
|
32
|
+
:macAddress=>"a2:b4:a2:b6:a2:a8",
|
33
|
+
:name=>"ovs-foreman"}]},
|
34
|
+
:machine=>{:type=>""},
|
35
|
+
:resources=>{:requests=>{:memory=>"1024M"}}},
|
36
|
+
:networks=>[{:multus=>{:networkName=>"ovs-foreman"},
|
37
|
+
:name=>"ovs-foreman"}],
|
38
|
+
:terminationGracePeriodSeconds=>0,
|
39
|
+
:volumes=>[{:name=>"robin-rykert-example-com-disk-00",
|
40
|
+
:persistentVolumeClaim=>{:claimName=>"robin-rykert-example-com-claim-1"}},
|
41
|
+
{:name=>"robin-rykert-example-com-disk-01",
|
42
|
+
:persistentVolumeClaim=>{:claimName=>"robin-rykert-example-com-claim-2"}}]}}}}
|
43
|
+
if update == update_args
|
44
|
+
result = Kubeclient::Resource.new
|
45
|
+
result.apiVersion="kubevirt.io/v1alpha3"
|
46
|
+
result.kind="VirtualMachine"
|
47
|
+
result.metadata={:creationTimestamp=>"2019-04-06T14:05:15Z",
|
48
|
+
:generation=>2,
|
49
|
+
:labels=>{:"kubevirt.io/vm"=>"robin-rykert.example.com"},
|
50
|
+
:name=>"robin-rykert.example.com",
|
51
|
+
:namespace=>"default",
|
52
|
+
:resourceVersion=>"1020276",
|
53
|
+
:selfLink=>"/apis/kubevirt.io/v1alpha3/namespaces/default/virtualmachines/robin-rykert.example.com",
|
54
|
+
:uid=>"00ae63ee-5875-11e9-9132-525400c5a686"}
|
55
|
+
result.spec={:running=>true,
|
56
|
+
:template=>{:metadata=>{:creationTimestamp=>nil,
|
57
|
+
:labels=>{:"kubevirt.io/vm"=>"robin-rykert.example.com"}},
|
58
|
+
:spec=>{:domain=>{:cpu=>{:cores=>1},
|
59
|
+
:devices=>{:disks=>[{:disk=>{:bus=>"virtio"},
|
60
|
+
:name=>"robin-rykert-example-com-disk-00"},
|
61
|
+
{:disk=>{:bus=>"virtio"},
|
62
|
+
:name=>"robin-rykert-example-com-disk-01"}],
|
63
|
+
:interfaces=>[{:bootOrder=>1,
|
64
|
+
:bridge=>{},
|
65
|
+
:macAddress=>"a2:b4:a2:b6:a2:a8",
|
66
|
+
:name=>"ovs-foreman"}]},
|
67
|
+
:machine=>{:type=>""},
|
68
|
+
:resources=>{:requests=>{:memory=>"1024M"}}},
|
69
|
+
:networks=>[{:multus=>{:networkName=>"ovs-foreman"},
|
70
|
+
:name=>"ovs-foreman"}],
|
71
|
+
:terminationGracePeriodSeconds=>0,
|
72
|
+
:volumes=>[{:name=>"robin-rykert-example-com-disk-00",
|
73
|
+
:persistentVolumeClaim=>{:claimName=>"robin-rykert-example-com-claim-1"}},
|
74
|
+
{:name=>"robin-rykert-example-com-disk-01",
|
75
|
+
:persistentVolumeClaim=>{:claimName=>"robin-rykert-example-com-claim-2"}}]}}}
|
76
|
+
return result
|
77
|
+
end
|
78
|
+
|
79
|
+
update_args_olive = {:apiVersion=>"kubevirt.io/v1alpha3",
|
80
|
+
:kind=>"VirtualMachine",
|
81
|
+
:metadata=>{:creationTimestamp=>"2019-04-07T15:00:07Z",
|
82
|
+
:generation=>1,
|
83
|
+
:labels=>{:"kubevirt.io/vm"=>"olive-kempter.example.com"},
|
84
|
+
:name=>"olive-kempter.example.com",
|
85
|
+
:namespace=>"default",
|
86
|
+
:resourceVersion=>"1075555",
|
87
|
+
:selfLink=>"/apis/kubevirt.io/v1alpha3/namespaces/default/virtualmachines/olive-kempter.example.com",
|
88
|
+
:uid=>"d4dba9e4-5945-11e9-9132-525400c5a686"},
|
89
|
+
:spec=>{:running=>true,
|
90
|
+
:template=>{:metadata=>{:creationTimestamp=>nil,
|
91
|
+
:labels=>{:"kubevirt.io/vm"=>"olive-kempter.example.com"}},
|
92
|
+
:spec=>{:domain=>{:cpu=>{:cores=>1},
|
93
|
+
:devices=>{:disks=>[{:bootOrder=>1,
|
94
|
+
:disk=>{:bus=>"virtio"},
|
95
|
+
:name=>"olive-kempter-example-com-disk-00"},
|
96
|
+
{:disk=>{:bus=>"virtio"},
|
97
|
+
:name=>"olive-kempter-example-com-disk-01"}],
|
98
|
+
:interfaces=>[{:bridge=>{},
|
99
|
+
:macAddress=>"a2:a4:a2:b2:a2:b6",
|
100
|
+
:name=>"ovs-foreman"}]},
|
101
|
+
:machine=>{:type=>""},
|
102
|
+
:resources=>{:requests=>{:memory=>"1024M"}}},
|
103
|
+
:networks=>[{:multus=>{:networkName=>"ovs-foreman"},
|
104
|
+
:name=>"ovs-foreman"}],
|
105
|
+
:terminationGracePeriodSeconds=>0,
|
106
|
+
:volumes=>[{:containerDisk=>{:image=>"kubevirt/fedora-cloud-registry-disk-demo"},
|
107
|
+
:name=>"olive-kempter-example-com-disk-00"},
|
108
|
+
{:name=>"olive-kempter-example-com-disk-01",
|
109
|
+
:persistentVolumeClaim=>{:claimName=>"olive-kempter-example-com-claim-1"}}]}}}}
|
110
|
+
|
111
|
+
if update == update_args_olive
|
112
|
+
result = Kubeclient::Resource.new
|
113
|
+
result.apiVersion="kubevirt.io/v1alpha3"
|
114
|
+
result.kind="VirtualMachine"
|
115
|
+
result.metadata={:creationTimestamp=>"2019-04-07T15:00:07Z",
|
116
|
+
:generation=>2,
|
117
|
+
:labels=>{:"kubevirt.io/vm"=>"olive-kempter.example.com"},
|
118
|
+
:name=>"olive-kempter.example.com",
|
119
|
+
:namespace=>"default",
|
120
|
+
:resourceVersion=>"1075556",
|
121
|
+
:selfLink=>"/apis/kubevirt.io/v1alpha3/namespaces/default/virtualmachines/olive-kempter.example.com",
|
122
|
+
:uid=>"d4dba9e4-5945-11e9-9132-525400c5a686"}
|
123
|
+
result.spec={:running=>true,
|
124
|
+
:template=>{:metadata=>{:creationTimestamp=>nil,
|
125
|
+
:labels=>{:"kubevirt.io/vm"=>"olive-kempter.example.com"}},
|
126
|
+
:spec=>{:domain=>{:cpu=>{:cores=>1},
|
127
|
+
:devices=>{:disks=>[{:bootOrder=>1,
|
128
|
+
:disk=>{:bus=>"virtio"},
|
129
|
+
:name=>"olive-kempter-example-com-disk-00"},
|
130
|
+
{:disk=>{:bus=>"virtio"},
|
131
|
+
:name=>"olive-kempter-example-com-disk-01"}],
|
132
|
+
:interfaces=>[{:bridge=>{},
|
133
|
+
:macAddress=>"a2:a4:a2:b2:a2:b6",
|
134
|
+
:name=>"ovs-foreman"}]},
|
135
|
+
:machine=>{:type=>""},
|
136
|
+
:resources=>{:requests=>{:memory=>"1024M"}}},
|
137
|
+
:networks=>[{:multus=>{:networkName=>"ovs-foreman"},
|
138
|
+
:name=>"ovs-foreman"}],
|
139
|
+
:terminationGracePeriodSeconds=>0,
|
140
|
+
:volumes=>[{:containerDisk=>{:image=>"kubevirt/fedora-cloud-registry-disk-demo"},
|
141
|
+
:name=>"olive-kempter-example-com-disk-00"},
|
142
|
+
{:name=>"olive-kempter-example-com-disk-01",
|
143
|
+
:persistentVolumeClaim=>{:claimName=>"olive-kempter-example-com-claim-1"}}]}}}
|
144
|
+
return result
|
145
|
+
end
|
146
|
+
end
|
13
147
|
end
|
14
148
|
end
|
15
149
|
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.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Kliczewski
|
@@ -9,11 +9,12 @@ authors:
|
|
9
9
|
- Paulo Ribeiro
|
10
10
|
- Gilles Dubreuil
|
11
11
|
- Adam Grare
|
12
|
+
- Boris Odnopozov
|
12
13
|
- Wesley Beary
|
13
14
|
autorequire:
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
|
-
date: 2019-04-
|
17
|
+
date: 2019-04-08 00:00:00.000000000 Z
|
17
18
|
dependencies:
|
18
19
|
- !ruby/object:Gem::Dependency
|
19
20
|
name: minitest
|
@@ -134,6 +135,7 @@ email:
|
|
134
135
|
- plribeiro3000@gmail.com
|
135
136
|
- gilles@redhat.com
|
136
137
|
- agrare@redhat.com
|
138
|
+
- bodnopoz@redhat.com
|
137
139
|
- geemus@gmail.com
|
138
140
|
executables: []
|
139
141
|
extensions: []
|