Class: Fog::Kubevirt::Compute::Persistentvolume

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/kubevirt/compute/models/persistentvolume.rb

Class Method Summary collapse

Class Method Details

.detect_type(spec) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/fog/kubevirt/compute/models/persistentvolume.rb', line 49

def self.detect_type(spec)
    type = ''
    type = 'awsElasticBlockStore' if spec.keys.include?(:awsElasticBlockStore)
    type = 'azureDisk' if spec.keys.include?(:azureDisk)
    type = 'azureFile' if spec.keys.include?(:azureFile)
    type = 'cephfs' if spec.keys.include?(:cephfs)
    type = 'configMap' if spec.keys.include?(:configMap)
    type = 'csi' if spec.keys.include?(:csi)
    type = 'downwardAPI' if spec.keys.include?(:downwardAPI)
    type = 'emptyDir' if spec.keys.include?(:emptyDir)
    type = 'fc' if spec.keys.include?(:fc)
    type = 'flexVolume' if spec.keys.include?(:flexVolume)
    type = 'flocker' if spec.keys.include?(:flocker)
    type = 'gcePersistentDisk' if spec.keys.include?(:gcePersistentDisk)
    type = 'glusterfs' if spec.keys.include?(:glusterfs)
    type = 'hostPath' if spec.keys.include?(:hostPath)
    type = 'iscsi' if spec.keys.include?(:iscsi)
    type = 'local' if spec.keys.include?(:local)
    type = 'nfs' if spec.keys.include?(:nfs)
    type = 'persistentVolumeClaim' if spec.keys.include?(:persistentVolumeClaim)
    type = 'projected' if spec.keys.include?(:projected)
    type = 'portworxVolume' if spec.keys.include?(:portworxVolume)
    type = 'quobyte' if spec.keys.include?(:quobyte)
    type = 'rbd' if spec.keys.include?(:rbd)
    type = 'scaleIO' if spec.keys.include?(:scaleIO)
    type = 'secret' if spec.keys.include?(:secret)
    type = 'storageos' if spec.keys.include?(:storageos)
    type = 'vsphereVolume' if spec.keys.include?(:vsphereVolume)
    type
end

.parse(object) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/fog/kubevirt/compute/models/persistentvolume.rb', line 23

def self.parse(object)
   = object[:metadata]
  spec = object[:spec]
  status = object[:status]
  type = detect_type(spec)

  {
    :name             => [:name],
    :resource_version => [:resourceVersion],
    :uid              => [:uid],
    :annotations      => [:annotations],
    :labels           => [:labels],
    :access_modes     => spec[:accessModes],
    :mount_options    => spec[:mountOptions],
    :reclaim_policy   => spec[:persistentVolumeReclaimPolicy],
    :storage_class    => spec[:storageClassName],
    :capacity         => spec.dig(:capacity, :storage),
    :claim_ref        => spec[:claimRef],
    :type             => type,
    :config           => spec[type&.to_sym],
    :phase            => status[:phase],
    :reason           => status[:reason],
    :message          => status[:message]
  }
end