fog-kubevirt 0.3.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -3
  3. data/lib/fog/bin/kubevirt.rb +2 -2
  4. data/lib/fog/kubevirt.rb +1 -4
  5. data/lib/fog/{compute/kubevirt.rb → kubevirt/compute/compute.rb} +35 -184
  6. data/lib/fog/{compute/kubevirt → kubevirt/compute}/models/node.rb +3 -3
  7. data/lib/fog/{compute/kubevirt → kubevirt/compute}/models/nodes.rb +4 -4
  8. data/lib/fog/{compute/kubevirt → kubevirt/compute}/models/template.rb +2 -2
  9. data/lib/fog/{compute/kubevirt → kubevirt/compute}/models/templates.rb +4 -4
  10. data/lib/fog/kubevirt/compute/models/vm.rb +71 -0
  11. data/lib/fog/{compute/kubevirt → kubevirt/compute}/models/vminstance.rb +4 -13
  12. data/lib/fog/{compute/kubevirt → kubevirt/compute}/models/vminstances.rb +4 -4
  13. data/lib/fog/kubevirt/compute/models/vms.rb +137 -0
  14. data/lib/fog/kubevirt/compute/models/volume.rb +9 -0
  15. data/lib/fog/kubevirt/compute/models/volumes.rb +12 -0
  16. data/lib/fog/{compute/kubevirt → kubevirt/compute}/requests/create_pvc.rb +2 -2
  17. data/lib/fog/{compute/kubevirt → kubevirt/compute}/requests/create_vm.rb +2 -3
  18. data/lib/fog/{compute/kubevirt → kubevirt/compute}/requests/create_vminstance.rb +2 -2
  19. data/lib/fog/{compute/kubevirt → kubevirt/compute}/requests/delete_vm.rb +3 -3
  20. data/lib/fog/{compute/kubevirt → kubevirt/compute}/requests/delete_vminstance.rb +5 -5
  21. data/lib/fog/{compute/kubevirt → kubevirt/compute}/requests/get_node.rb +2 -2
  22. data/lib/fog/{compute/kubevirt → kubevirt/compute}/requests/get_template.rb +2 -2
  23. data/lib/fog/{compute/kubevirt → kubevirt/compute}/requests/get_vm.rb +3 -3
  24. data/lib/fog/{compute/kubevirt → kubevirt/compute}/requests/get_vminstance.rb +6 -6
  25. data/lib/fog/{compute/kubevirt → kubevirt/compute}/requests/list_nodes.rb +2 -2
  26. data/lib/fog/{compute/kubevirt → kubevirt/compute}/requests/list_templates.rb +2 -2
  27. data/lib/fog/{compute/kubevirt → kubevirt/compute}/requests/list_vminstances.rb +2 -2
  28. data/lib/fog/{compute/kubevirt → kubevirt/compute}/requests/list_vms.rb +6 -6
  29. data/lib/fog/{compute/kubevirt → kubevirt/compute}/requests/update_vm.rb +2 -2
  30. data/lib/fog/kubevirt/version.rb +1 -1
  31. metadata +39 -133
  32. data/lib/fog/compute/kubevirt/models/networkattachmentdef.rb +0 -25
  33. data/lib/fog/compute/kubevirt/models/networkattachmentdefs.rb +0 -59
  34. data/lib/fog/compute/kubevirt/models/persistentvolume.rb +0 -82
  35. data/lib/fog/compute/kubevirt/models/persistentvolumes.rb +0 -73
  36. data/lib/fog/compute/kubevirt/models/pvc.rb +0 -59
  37. data/lib/fog/compute/kubevirt/models/pvcs.rb +0 -76
  38. data/lib/fog/compute/kubevirt/models/server.rb +0 -44
  39. data/lib/fog/compute/kubevirt/models/servers.rb +0 -32
  40. data/lib/fog/compute/kubevirt/models/service.rb +0 -36
  41. data/lib/fog/compute/kubevirt/models/services.rb +0 -83
  42. data/lib/fog/compute/kubevirt/models/storageclass.rb +0 -33
  43. data/lib/fog/compute/kubevirt/models/storageclasses.rb +0 -61
  44. data/lib/fog/compute/kubevirt/models/vm.rb +0 -17
  45. data/lib/fog/compute/kubevirt/models/vm_base.rb +0 -86
  46. data/lib/fog/compute/kubevirt/models/vm_data.rb +0 -162
  47. data/lib/fog/compute/kubevirt/models/vms.rb +0 -206
  48. data/lib/fog/compute/kubevirt/models/volume.rb +0 -57
  49. data/lib/fog/compute/kubevirt/models/volumes.rb +0 -18
  50. data/lib/fog/compute/kubevirt/requests/create_networkattachmentdef.rb +0 -37
  51. data/lib/fog/compute/kubevirt/requests/create_persistentvolume.rb +0 -19
  52. data/lib/fog/compute/kubevirt/requests/create_service.rb +0 -18
  53. data/lib/fog/compute/kubevirt/requests/create_storageclass.rb +0 -18
  54. data/lib/fog/compute/kubevirt/requests/delete_networkattachmentdef.rb +0 -16
  55. data/lib/fog/compute/kubevirt/requests/delete_persistentvolume.rb +0 -16
  56. data/lib/fog/compute/kubevirt/requests/delete_pvc.rb +0 -16
  57. data/lib/fog/compute/kubevirt/requests/delete_service.rb +0 -16
  58. data/lib/fog/compute/kubevirt/requests/delete_storageclass.rb +0 -16
  59. data/lib/fog/compute/kubevirt/requests/get_networkattachmentdef.rb +0 -19
  60. data/lib/fog/compute/kubevirt/requests/get_persistentvolume.rb +0 -16
  61. data/lib/fog/compute/kubevirt/requests/get_pvc.rb +0 -16
  62. data/lib/fog/compute/kubevirt/requests/get_server.rb +0 -32
  63. data/lib/fog/compute/kubevirt/requests/get_service.rb +0 -16
  64. data/lib/fog/compute/kubevirt/requests/get_storageclass.rb +0 -16
  65. data/lib/fog/compute/kubevirt/requests/list_networkattachmentdefs.rb +0 -21
  66. data/lib/fog/compute/kubevirt/requests/list_persistentvolumes.rb +0 -22
  67. data/lib/fog/compute/kubevirt/requests/list_pvcs.rb +0 -22
  68. data/lib/fog/compute/kubevirt/requests/list_servers.rb +0 -25
  69. data/lib/fog/compute/kubevirt/requests/list_services.rb +0 -22
  70. data/lib/fog/compute/kubevirt/requests/list_storageclasses.rb +0 -22
  71. data/lib/fog/compute/kubevirt/requests/list_volumes.rb +0 -30
  72. data/spec/compute_v1alpha2_spec.rb +0 -30
  73. data/spec/create_vm_spec.rb +0 -101
  74. data/spec/fixtures/kubevirt/networkattachmentdefinition/networkattachmentdefinitions_crud.yml +0 -320
  75. data/spec/fixtures/kubevirt/persistentvolume/persistent_volumes_crud.yml +0 -316
  76. data/spec/fixtures/kubevirt/pvc/pvcs_crud.yml +0 -362
  77. data/spec/fixtures/kubevirt/service/services_crud.yml +0 -316
  78. data/spec/fixtures/kubevirt/storageclass/storageclasses_crud.yml +0 -400
  79. data/spec/fixtures/kubevirt/vm/vm_create_multi.yml +0 -459
  80. data/spec/fixtures/kubevirt/vm/vm_create_single.yml +0 -362
  81. data/spec/network_attachment_definition_v1alpha2_spec.rb +0 -28
  82. data/spec/persistent_volumes_v1alpha2_spec.rb +0 -45
  83. data/spec/pvcs_v1alpha2_spec.rb +0 -59
  84. data/spec/shared_context.rb +0 -54
  85. data/spec/spec_helper.rb +0 -10
  86. data/spec/storage_classes_v1_spec.rb +0 -46
@@ -1,57 +0,0 @@
1
- require 'fog/compute/kubevirt/models/pvc'
2
-
3
- module Fog
4
- module Compute
5
- class Kubevirt
6
- # Volumes represents volumes exist on kubevirt for vms:
7
- # If volume is attached to a VM by disk, it will contain the attachment properties
8
- # Disk Attachment properties are: boot_order and bus (when avaiable).
9
- # If the volume isn't attached to any VM, it will contain name, type and info.
10
- # When the volume type is persistentVolumeClaim, it will contain also the claim entity
11
- # In order to create a new volume, user have to create a Claim when wishes to use PVC
12
- # by using the pvcs collection.
13
- class Volume < Fog::Model
14
- identity :name
15
-
16
- # values: containerDisk, persistentVolumeClaim, emptyDisk,
17
- # ephemeral, cloudInitNoCloud, hostDisk, secret,
18
- # dataVolume, serviceAccount, configMap
19
- attribute :type
20
-
21
- # specific piece of information per volume type
22
- # for containerDisk - contains the image
23
- # for persistentVolumeClaim - contains the claim name
24
- attribute :info
25
-
26
- # holds the pvc entity if its type is persistentVolumeClaim
27
- attribute :pvc
28
-
29
- # Hash that holds volume type specific configurations, used for adding volume for a vm
30
- # The set of config properties may change from type to type, see documentation for the supported
31
- # keys of each volume type:
32
- # https://kubevirt.io/user-guide/docs/latest/creating-virtual-machines/disks-and-volumes.html#volumes
33
- attribute :config
34
-
35
- # Disk attachment properties, relevant when volumes are fetched via the vm:
36
-
37
- # the order (integer) of the device during boot sequence
38
- attribute :boot_order
39
-
40
- # detemines how the disk will be presented to the guest OS if available, supported values are:
41
- # virtio, sata or scsi. See https://kubevirt.io/api-reference/master/definitions.html#_v1_disktarget
42
- attribute :bus
43
-
44
- def persisted?
45
- !name.nil?
46
- end
47
-
48
- def self.parse(object, disk)
49
- byebug
50
- volume = parse_object(object)
51
- volume[:boot_order] = object[:bootOrder]
52
- volume
53
- end
54
- end
55
- end
56
- end
57
- end
@@ -1,18 +0,0 @@
1
- require 'fog/core/collection'
2
- require 'fog/compute/kubevirt/models/volume'
3
-
4
- module Fog
5
- module Compute
6
- class Kubevirt
7
- class Volumes < Fog::Collection
8
- model Fog::Compute::Kubevirt::Volume
9
-
10
- attr_accessor :vm
11
-
12
- def all(vm_name = nil)
13
- service.list_volumes(vm_name)
14
- end
15
- end
16
- end
17
- end
18
- end
@@ -1,37 +0,0 @@
1
- module Fog
2
- module Compute
3
- class Kubevirt
4
- class Real
5
- include Shared
6
-
7
- # creates netwrork attachment definition object
8
- # @param net_att[Hash] contains the following elements:
9
- # metadata[Hash]: the net-attachment-def metadata:
10
- # name[String]: the netwrork attachment definition definition
11
- # spec[Hash]: the specification of the attachment, contains:config
12
- # config[string]: the configuration of the attachment, i.e.
13
- # '{ :cniVersion => "0.3.1", :type => "ovs", :bridge => "red" }'
14
- # Example of net_att:
15
- # metadata: {
16
- # name: "ovs-red"},
17
- # spec: {
18
- # config: '{ cni_version: "0.3.1", type: "ovs", bridge: "red" }'
19
- # }
20
- def create_networkattachmentdef(net_att)
21
- if net_att.dig(:metadata, :namespace).nil?
22
- net_att = deep_merge!(net_att, metadata: { namespace: @namespace })
23
- end
24
- kube_net_client.create_network_attachment_definition(net_att)
25
- rescue ::Fog::Kubevirt::Errors::ClientError => err
26
- log.warn(err)
27
- raise ::Fog::Kubevirt::Errors::AlreadyExistsError
28
- end
29
- end
30
-
31
- class Mock
32
- def create_networkattachmentdef(_net_att_def)
33
- end
34
- end
35
- end
36
- end
37
- end
@@ -1,19 +0,0 @@
1
- module Fog
2
- module Compute
3
- class Kubevirt
4
- class Real
5
- def create_persistentvolume(volume)
6
- kube_client.create_persistent_volume(volume)
7
- rescue ::Fog::Kubevirt::Errors::ClientError => err
8
- log.warn(err)
9
- raise ::Fog::Kubevirt::Errors::AlreadyExistsError
10
- end
11
- end
12
-
13
- class Mock
14
- def create_persistentvolume(volume)
15
- end
16
- end
17
- end
18
- end
19
- end
@@ -1,18 +0,0 @@
1
- module Fog
2
- module Compute
3
- class Kubevirt
4
- class Real
5
- def create_service(srv)
6
- kube_client.create_service(srv)
7
- rescue ::Fog::Kubevirt::Errors::ClientError => err
8
- log.warn(err)
9
- raise ::Fog::Kubevirt::Errors::AlreadyExistsError
10
- end
11
- end
12
-
13
- class Mock
14
- def create_service(srv); end
15
- end
16
- end
17
- end
18
- end
@@ -1,18 +0,0 @@
1
- module Fog
2
- module Compute
3
- class Kubevirt
4
- class Real
5
- def create_storageclass(storageclass)
6
- kube_storage_client.create_storage_class(storageclass)
7
- rescue ::Fog::Kubevirt::Errors::ClientError => err
8
- log.warn(err)
9
- raise ::Fog::Kubevirt::Errors::AlreadyExistsError
10
- end
11
- end
12
-
13
- class Mock
14
- def create_storage_class(attrs); end
15
- end
16
- end
17
- end
18
- end
@@ -1,16 +0,0 @@
1
- module Fog
2
- module Compute
3
- class Kubevirt
4
- class Real
5
- def delete_networkattachmentdef(name, namespace)
6
- kube_net_client.delete_network_attachment_definition(name, namespace)
7
- end
8
- end
9
-
10
- class Mock
11
- def delete_networkattachmentdef(_name, _namespace)
12
- end
13
- end
14
- end
15
- end
16
- end
@@ -1,16 +0,0 @@
1
- module Fog
2
- module Compute
3
- class Kubevirt
4
- class Real
5
- def delete_persistentvolume(name)
6
- kube_client.delete_persistent_volume(name)
7
- end
8
- end
9
-
10
- class Mock
11
- def delete_persistentvolume(name)
12
- end
13
- end
14
- end
15
- end
16
- end
@@ -1,16 +0,0 @@
1
- module Fog
2
- module Compute
3
- class Kubevirt
4
- class Real
5
- def delete_pvc(name)
6
- kube_client.delete_persistent_volume_claim(name, namespace)
7
- end
8
- end
9
-
10
- class Mock
11
- def delete_pvc(name)
12
- end
13
- end
14
- end
15
- end
16
- end
@@ -1,16 +0,0 @@
1
- module Fog
2
- module Compute
3
- class Kubevirt
4
- class Real
5
- def delete_service(name, namespace)
6
- kube_client.delete_service(name, namespace)
7
- end
8
- end
9
-
10
- class Mock
11
- def delete_service(name)
12
- end
13
- end
14
- end
15
- end
16
- end
@@ -1,16 +0,0 @@
1
- module Fog
2
- module Compute
3
- class Kubevirt
4
- class Real
5
- def delete_storageclass(name)
6
- kube_storage_client.delete_storage_class(name)
7
- end
8
- end
9
-
10
- class Mock
11
- def delete_storage_class(name)
12
- end
13
- end
14
- end
15
- end
16
- end
@@ -1,19 +0,0 @@
1
- require 'recursive_open_struct'
2
-
3
- module Fog
4
- module Compute
5
- class Kubevirt
6
- class Real
7
- def get_networkattachmentdef(name)
8
- net_attach_def = kube_net_client.get_network_attachment_definition(name, @namespace)
9
- Networkattachmentdef.parse object_to_hash(net_attach_def)
10
- end
11
- end
12
-
13
- class Mock
14
- def get_networkattachmentdef(name)
15
- end
16
- end
17
- end
18
- end
19
- end
@@ -1,16 +0,0 @@
1
- module Fog
2
- module Compute
3
- class Kubevirt
4
- class Real
5
- def get_persistentvolume(name)
6
- Persistentvolume.parse object_to_hash(kube_client.get_persistent_volume(name))
7
- end
8
- end
9
-
10
- class Mock
11
- def get_persistentvolume(name)
12
- end
13
- end
14
- end
15
- end
16
- end
@@ -1,16 +0,0 @@
1
- module Fog
2
- module Compute
3
- class Kubevirt
4
- class Real
5
- def get_pvc(name)
6
- Pvc.parse object_to_hash(kube_client.get_persistent_volume_claim(name, @namespace))
7
- end
8
- end
9
-
10
- class Mock
11
- def get_pvc(name)
12
- end
13
- end
14
- end
15
- end
16
- end
@@ -1,32 +0,0 @@
1
- module Fog
2
- module Compute
3
- class Kubevirt
4
- class Real
5
- def get_server(name)
6
- vm = get_raw_vm(name)
7
- populate_runtime_info(vm)
8
- Server.parse vm
9
- end
10
-
11
- # Updates a given VM raw entity with vm instance info if exists
12
- #
13
- # @param vm [Hash] A hash with vm raw data.
14
- def populate_runtime_info(vm)
15
- vmi = get_vminstance(vm[:metadata][:name])
16
- vm[:ip_address] = vmi[:ip_address]
17
- vm[:node_name] = vmi[:node_name]
18
- vm[:phase] = vmi[:status]
19
- vm
20
- rescue
21
- # do nothing if vmi doesn't exist
22
- end
23
- end
24
-
25
- class Mock
26
- # TODO provide implementation
27
- def get_server(name)
28
- end
29
- end
30
- end
31
- end
32
- end
@@ -1,16 +0,0 @@
1
- module Fog
2
- module Compute
3
- class Kubevirt
4
- class Real
5
- def get_service(name)
6
- Service.parse object_to_hash(kube_client.get_service(name, @namespace))
7
- end
8
- end
9
-
10
- class Mock
11
- def get_service(name)
12
- end
13
- end
14
- end
15
- end
16
- end
@@ -1,16 +0,0 @@
1
- module Fog
2
- module Compute
3
- class Kubevirt
4
- class Real
5
- def get_storageclass(name)
6
- Storageclass.parse object_to_hash(kube_storage_client.get_storage_class(name))
7
- end
8
- end
9
-
10
- class Mock
11
- def get_storage_class(name)
12
- end
13
- end
14
- end
15
- end
16
- end
@@ -1,21 +0,0 @@
1
- module Fog
2
- module Compute
3
- class Kubevirt
4
- class Real
5
- def list_networkattachmentdefs(_filters = {})
6
- netdefs = kube_net_client.get_network_attachment_definitions
7
- entities = netdefs.map do |kubevirt_obj|
8
- Networkattachmentdef.parse object_to_hash(kubevirt_obj)
9
- end
10
- EntityCollection.new(netdefs.kind, netdefs.resourceVersion, entities)
11
- end
12
- end
13
-
14
- class Mock
15
- # TODO provide implementation
16
- def list_networkattachmentdefs(_filters = {})
17
- end
18
- end
19
- end
20
- end
21
- end
@@ -1,22 +0,0 @@
1
- require 'recursive_open_struct'
2
-
3
- module Fog
4
- module Compute
5
- class Kubevirt
6
- class Real
7
- def list_persistentvolumes(_filters = {})
8
- volumes = kube_client.get_persistent_volumes()
9
- entities = volumes.map do |kubevirt_obj|
10
- Persistentvolume.parse object_to_hash(kubevirt_obj)
11
- end
12
- EntityCollection.new(volumes.kind, volumes.resourceVersion, entities)
13
- end
14
- end
15
-
16
- class Mock
17
- def list_persistentvolumes(_filters = {})
18
- end
19
- end
20
- end
21
- end
22
- end
@@ -1,22 +0,0 @@
1
- require 'recursive_open_struct'
2
-
3
- module Fog
4
- module Compute
5
- class Kubevirt
6
- class Real
7
- def list_pvcs(_filters = {})
8
- pvcs = kube_client.get_persistent_volume_claims(namespace: @namespace)
9
- entities = pvcs.map do |kubevirt_obj|
10
- Pvc.parse object_to_hash(kubevirt_obj)
11
- end
12
- EntityCollection.new(pvcs.kind, pvcs.resourceVersion, entities)
13
- end
14
- end
15
-
16
- class Mock
17
- def list_pvcs(_filters = {})
18
- end
19
- end
20
- end
21
- end
22
- end