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,73 +0,0 @@
1
- require 'fog/core/collection'
2
- require 'fog/compute/kubevirt/models/persistentvolume'
3
-
4
- module Fog
5
- module Compute
6
- class Kubevirt
7
- class Persistentvolumes < Fog::Collection
8
- attr_reader :kind, :resource_version
9
-
10
- model Fog::Compute::Kubevirt::Persistentvolume
11
-
12
- def all(filters = {})
13
- volumes = service.list_persistentvolumes(filters)
14
- @kind = volumes.kind
15
- @resource_version = volumes.resource_version
16
- load volumes
17
- end
18
-
19
- def get(name)
20
- new service.get_persistentvolume(name)
21
- end
22
-
23
- # Creates a volume using provided paramters:
24
- # :name [String] - name of a volume
25
- # :labels [Hash] - a hash of key,values representing the labels
26
- # :storage_class [String] - the storage class name of the volume
27
- # :capacity [String] - The capacity of the storage if applied
28
- # :accessModes [Arr] - the access modes for the volume, values are specified here:
29
- # https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes
30
- # :type [String] - the type of the storage
31
- # :config [Hash] - storage specific configuration to be applied for the volume
32
- # correlated to the args[:type]
33
- # @param [Hash] attributes containing details about volume to be created.
34
- def create(args = {})
35
- name = args[:name]
36
- labels = args[:labels]
37
-
38
- volume = {
39
- :apiVersion => "v1",
40
- :kind => "PersistentVolume",
41
- :metadata => {
42
- :name => name
43
- },
44
- :spec => {
45
- :storageClassName => args[:storage_class]
46
- }
47
- }
48
-
49
- volume[:metadata][:labels] = labels if labels
50
- volume[:spec][:capacity] = {
51
- :storage => args[:capacity]
52
- } if args[:capacity]
53
-
54
- volume[:spec][:accessModes] = args[:access_modes] if args[:access_modes]
55
- volume[:spec][args[:type].to_sym] = args[:config] if args[:type]
56
-
57
- service.create_persistentvolume(volume)
58
- end
59
-
60
- def delete(name)
61
- begin
62
- volume = get(name)
63
- rescue ::Fog::Kubevirt::Errors::ClientError
64
- # the volume doesn't exist
65
- volume = nil
66
- end
67
-
68
- service.delete_persistentvolume(name) unless volume.nil?
69
- end
70
- end
71
- end
72
- end
73
- end
@@ -1,59 +0,0 @@
1
- module Fog
2
- module Compute
3
- class Kubevirt
4
- class Pvc < Fog::Model
5
- # Metadata
6
- identity :name
7
- attribute :resource_version, :aliases => 'metadata_resource_version'
8
- attribute :uid, :aliases => 'metadata_uid'
9
- attribute :namespace, :aliases => 'metadata_namespace'
10
-
11
- # Spec
12
- attribute :access_modes, :aliases => 'spec_access_modes'
13
- attribute :storage_class, :aliases => 'spec_storage_class'
14
- attribute :volume_mode, :aliases => 'spec_volume_mode'
15
- attribute :volume_name, :aliases => 'spec_volume_name'
16
-
17
- # Spec - selector
18
- attribute :match_expressions, :aliases => 'spec_match_expressions'
19
- attribute :match_labels, :aliases => 'spec_match_labels'
20
-
21
- # Spec - resources
22
- attribute :limits, :aliases => 'spec_limits'
23
- attribute :requests, :aliases => 'spec_requests'
24
-
25
- # Status
26
- attribute :phase, :aliases => 'status_phase'
27
- attribute :reason, :aliases => 'status_reason'
28
- attribute :message, :aliases => 'status_message'
29
-
30
- def self.parse(object)
31
- metadata = object[:metadata]
32
- spec = object[:spec]
33
- status = object[:status]
34
-
35
- {
36
- :name => metadata[:name],
37
- :resource_version => metadata[:resourceVersion],
38
- :uid => metadata[:uid],
39
- :namespace => metadata[:namespace],
40
-
41
- :access_modes => spec[:accessModes],
42
- :storage_class => spec[:storageClassName],
43
- :volume_mode => spec[:volumeMode],
44
- :volume_name => spec[:volumeName],
45
-
46
- :match_expressions => spec.dig(:selector, :matchExpressions),
47
- :match_labels => spec.dig(:selector, :matchLabels),
48
- :limits => spec.dig(:resources, :limits),
49
- :requests => spec.dig(:resources, :requests),
50
-
51
- :phase => status[:phase],
52
- :reason => status[:reason],
53
- :message => status[:message]
54
- }
55
- end
56
- end
57
- end
58
- end
59
- end
@@ -1,76 +0,0 @@
1
- require 'fog/core/collection'
2
- require 'fog/compute/kubevirt/models/pvc'
3
-
4
- module Fog
5
- module Compute
6
- class Kubevirt
7
- class Pvcs < Fog::Collection
8
- attr_reader :kind, :resource_version
9
-
10
- model Fog::Compute::Kubevirt::Pvc
11
-
12
- def all(filters = {})
13
- pvcs = service.list_pvcs(filters)
14
- @kind = pvcs.kind
15
- @resource_version = pvcs.resource_version
16
- load pvcs
17
- end
18
-
19
- def get(name)
20
- new service.get_pvc(name)
21
- end
22
-
23
- # Creates a pvc using provided paramters:
24
- # https://kubernetes.io/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims
25
- # :name [String] - name of a pvc
26
- # :namespace [String] - the namespace of the PVC, should be the same as POD's pvc
27
- # :storage_class [String] - the storage class name of the pvc
28
- # :volume_name [String] - The volume name to
29
- # :volume_mode [String] - Filesystem or block device
30
- # :accessModes [Arr] - the access modes for the volume, values are specified here:
31
- # :requests [Hash] - the request for storage resource, i.e. { :storage => "20Gi" }
32
- # :limits [Hash] - the maximum amount of storage to consume, i.e. { :storage => "20Gi" }
33
- # :match_labels [Hash] - label query over volumes for binding
34
- # :match_expressions [Hash] - list of label selector requirements
35
- # @param [Hash] attributes containing details about pvc to be created.
36
- def create(args = {})
37
- name = args[:name]
38
-
39
- pvc = {
40
- :apiVersion => "v1",
41
- :kind => "PersistentVolumeClaim",
42
- :metadata => {
43
- :name => name,
44
- :namespace => args[:namespace]
45
- },
46
- :spec => {
47
- :storageClassName => args[:storage_class],
48
- :resources => {},
49
- :selector => {},
50
- }
51
- }
52
-
53
- pvc[:spec][:resources].merge!(:requests => args[:requests]) if args[:requests]
54
- pvc[:spec][:resources].merge!(:limits => args[:limits]) if args[:limits]
55
- pvc[:spec][:selector].merge!(:matchLabels => args[:match_labels]) if args[:match_labels]
56
- pvc[:spec][:selector].merge!(:matchExpressions => args[:match_expressions]) if args[:match_expressions]
57
- pvc[:spec][:accessModes] = args[:access_modes] if args[:access_modes]
58
- pvc[:spec][:volumeMode] = args[:volume_mode] if args[:volume_mode]
59
- pvc[:spec][:volumeName] = args[:volume_name] if args[:volume_name]
60
- service.create_pvc(pvc)
61
- end
62
-
63
- def delete(name)
64
- begin
65
- pvc = get(name)
66
- rescue ::Fog::Kubevirt::Errors::ClientError
67
- # the pvc doesn't exist
68
- pvc = nil
69
- end
70
-
71
- service.delete_pvc(name) unless pvc.nil?
72
- end
73
- end
74
- end
75
- end
76
- end
@@ -1,44 +0,0 @@
1
- require 'fog/compute/models/server'
2
- require 'fog/compute/kubevirt/models/vm_base'
3
-
4
- module Fog
5
- module Compute
6
- class Kubevirt
7
- class Server < Fog::Compute::Server
8
- include Shared
9
- include VmAction
10
- extend VmBase
11
- define_properties
12
-
13
- attribute :state, :aliases => 'phase'
14
- attribute :ip_address
15
- attribute :node_name
16
-
17
- def destroy(options = {})
18
- stop(options)
19
- service.delete_vm(name, namespace)
20
- end
21
-
22
- # TODO: Once IP Addresses are reported to any networks, we should consider also
23
- # the availabity of it (by extending the condition with !ip_address.empty?)
24
- def ready?
25
- running?(status) && running?(state)
26
- end
27
-
28
- def self.parse(object)
29
- server = parse_object(object)
30
- server[:state] = object[:phase]
31
- server[:node_name] = object[:node_name]
32
- server[:ip_address] = object[:ip_address]
33
- server
34
- end
35
-
36
- private
37
-
38
- def running?(status)
39
- !status.nil? && 'running'.casecmp(status).zero?
40
- end
41
- end
42
- end
43
- end
44
- end
@@ -1,32 +0,0 @@
1
- require 'fog/core/collection'
2
- require 'fog/compute/kubevirt/models/server'
3
-
4
- module Fog
5
- module Compute
6
- class Kubevirt
7
- class Servers < Fog::Collection
8
- attr_reader :kind, :resource_version
9
-
10
- model Fog::Compute::Kubevirt::Server
11
-
12
- def all(filters = {})
13
- servers = service.list_servers(filters)
14
- @kind = servers.kind
15
- @resource_version = servers.resource_version
16
- load servers
17
- end
18
-
19
- def get(id)
20
- new service.get_server(id)
21
- end
22
-
23
- def bootstrap(new_attributes = {})
24
- server = create(new_attributes)
25
- server.wait_for { stopped? }
26
- server.start
27
- server
28
- end
29
- end
30
- end
31
- end
32
- end
@@ -1,36 +0,0 @@
1
- module Fog
2
- module Compute
3
- class Kubevirt
4
- class Service < Fog::Model
5
- identity :name
6
-
7
- attribute :namespace, :aliases => 'metadata_namespace'
8
- attribute :resource_version, :aliases => 'metadata_resource_version'
9
- attribute :cluster_ip, :aliases => 'spec_cluster_ip'
10
- attribute :node_port, :aliases => 'spec_ports_node_port'
11
- attribute :port, :aliases => 'spec_ports_port'
12
- attribute :target_port, :aliases => 'spec_ports_target_port'
13
- attribute :selector, :aliases => 'spec_selector'
14
-
15
- def self.parse(object)
16
- metadata = object[:metadata]
17
- spec = object[:spec]
18
- ports = spec[:ports][0]
19
- selector = spec[:selector]
20
- srv = {
21
- :namespace => metadata[:namespace],
22
- :name => metadata[:name],
23
- :resource_version => metadata[:resourceVersion],
24
- :cluster_ip => spec[:clusterIP],
25
- :node_port => ports[:nodePort],
26
- :port => ports[:port],
27
- :target_port => ports[:target_port],
28
- }
29
- srv[:selector] = selector[:special] unless selector.nil?
30
-
31
- srv
32
- end
33
- end
34
- end
35
- end
36
- end
@@ -1,83 +0,0 @@
1
- require 'fog/core/collection'
2
- require 'fog/compute/kubevirt/models/service'
3
-
4
- module Fog
5
- module Compute
6
- class Kubevirt
7
- class Services < Fog::Collection
8
- attr_reader :kind, :resource_version
9
-
10
- model Fog::Compute::Kubevirt::Service
11
-
12
- def all(filters = {})
13
- begin
14
- srvs = service.list_services(filters)
15
- rescue ::Fog::Kubevirt::Errors::ClientError
16
- # we assume that we get 404
17
- srvs = []
18
- end
19
- @kind = srvs.kind
20
- @resource_version = srvs.resource_version
21
- load srvs
22
- end
23
-
24
- def get(name)
25
- new service.get_service(name)
26
- end
27
-
28
- # Creates a service using provided paramters:
29
- # :name [String] - name of a service
30
- # :port [int] - a port which will be exposed on node and cluster
31
- # :target_port [int] - a vmi port which will be forwarded
32
- # :vmi_name [String] - name of a vmi to be selected
33
- # :service_type [String] - service type used to create service
34
- #
35
- # @param [Hash] attributes containing details about service to be
36
- # created.
37
- def create(args = {})
38
- port = args[:port]
39
- name = args[:name]
40
- target_port = args[:target_port]
41
- vmi_name = args[:vmi_name]
42
- service_type = args[:service_type]
43
-
44
- srv = {
45
- :apiVersion => "v1",
46
- :kind => "Service",
47
- :metadata => {
48
- :name => name,
49
- :namespace => service.namespace
50
- },
51
- :spec => {
52
- :externalTrafficPolicy => "Cluster",
53
- :ports => [
54
- {:nodePort => port,
55
- :port => port,
56
- :protocol => "TCP",
57
- :targetPort => target_port
58
- }
59
- ],
60
- :selector => {
61
- :"kubevirt.io/vm" => vmi_name
62
- },
63
- :type => service_type
64
- }
65
- }
66
-
67
- service.create_service(srv)
68
- end
69
-
70
- def delete(name)
71
- begin
72
- srv = get(name)
73
- rescue ::Fog::Kubevirt::Errors::ClientError
74
- # the service doesn't exist
75
- srv = nil
76
- end
77
-
78
- service.delete_service(name, service.namespace) unless srv.nil?
79
- end
80
- end
81
- end
82
- end
83
- end
@@ -1,33 +0,0 @@
1
- module Fog
2
- module Compute
3
- class Kubevirt
4
- class Storageclass < Fog::Model
5
- # Metadata
6
- identity :name
7
- attribute :resource_version, :aliases => 'metadata_resource_version'
8
- attribute :uid, :aliases => 'metadata_uid'
9
-
10
- attribute :mount_options
11
- attribute :parameters
12
- attribute :provisioner
13
- attribute :reclaim_policy
14
- attribute :volume_binding_mode
15
-
16
- def self.parse(object)
17
- metadata = object[:metadata]
18
- {
19
- :name => metadata[:name],
20
- :resource_version => metadata[:resourceVersion],
21
- :uid => metadata[:uid],
22
-
23
- :parameters => object[:parameters],
24
- :mount_options => object[:mountOptions],
25
- :provisioner => object[:provisioner],
26
- :reclaim_policy => object[:reclaimPolicy],
27
- :volume_binding_mode => object[:volumeBindingMode]
28
- }
29
- end
30
- end
31
- end
32
- end
33
- end