Class: Fog::Kubevirt::Compute::Pvcs
- Inherits:
-
Collection
- Object
- Collection
- Fog::Kubevirt::Compute::Pvcs
- Defined in:
- lib/fog/kubevirt/compute/models/pvcs.rb
Instance Attribute Summary collapse
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#resource_version ⇒ Object
readonly
Returns the value of attribute resource_version.
Instance Method Summary collapse
- #all(filters = {}) ⇒ Object
-
#create(args = {}) ⇒ Object
Creates a pvc using provided paramters: kubernetes.io/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims :name [String] - name of a pvc :namespace [String] - the namespace of the PVC, should be the same as POD’s pvc :storage_class [String] - the storage class name of the pvc :volume_name [String] - The volume name to :volume_mode [String] - Filesystem or block device :accessModes [Arr] - the access modes for the volume, values are specified here: :requests [Hash] - the request for storage resource, i.e.
- #delete(name) ⇒ Object
- #get(name) ⇒ Object
Instance Attribute Details
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
8 9 10 |
# File 'lib/fog/kubevirt/compute/models/pvcs.rb', line 8 def kind @kind end |
#resource_version ⇒ Object (readonly)
Returns the value of attribute resource_version.
8 9 10 |
# File 'lib/fog/kubevirt/compute/models/pvcs.rb', line 8 def resource_version @resource_version end |
Instance Method Details
#all(filters = {}) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/fog/kubevirt/compute/models/pvcs.rb', line 12 def all(filters = {}) pvcs = service.list_pvcs(filters) @kind = pvcs.kind @resource_version = pvcs.resource_version load pvcs end |
#create(args = {}) ⇒ Object
Creates a pvc using provided paramters: kubernetes.io/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims :name [String] - name of a pvc :namespace [String] - the namespace of the PVC, should be the same as POD’s pvc :storage_class [String] - the storage class name of the pvc :volume_name [String] - The volume name to :volume_mode [String] - Filesystem or block device :accessModes [Arr] - the access modes for the volume, values are specified here: :requests [Hash] - the request for storage resource, i.e. { :storage => “20Gi” } :limits [Hash] - the maximum amount of storage to consume, i.e. { :storage => “20Gi” } :match_labels [Hash] - label query over volumes for binding :match_expressions [Hash] - list of label selector requirements
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/fog/kubevirt/compute/models/pvcs.rb', line 36 def create(args = {}) name = args[:name] pvc = { :apiVersion => "v1", :kind => "PersistentVolumeClaim", :metadata => { :name => name, :namespace => args[:namespace] }, :spec => { :storageClassName => args[:storage_class], :resources => {} } } pvc[:spec][:resources].merge!(:requests => args[:requests]) if args[:requests] pvc[:spec][:resources].merge!(:limits => args[:limits]) if args[:limits] if args[:match_labels] || args[:match_expressions] pvc[:spec][:selector] = {} pvc[:spec][:selector].merge!(:matchLabels => args[:match_labels]) if args[:match_labels] pvc[:spec][:selector].merge!(:matchExpressions => args[:match_expressions]) if args[:match_expressions] end pvc[:spec][:accessModes] = args[:access_modes] if args[:access_modes] pvc[:spec][:volumeMode] = args[:volume_mode] if args[:volume_mode] pvc[:spec][:volumeName] = args[:volume_name] if args[:volume_name] service.create_pvc(pvc) end |
#delete(name) ⇒ Object
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/fog/kubevirt/compute/models/pvcs.rb', line 67 def delete(name) begin pvc = get(name) rescue ::Fog::Kubevirt::Errors::ClientError # the pvc doesn't exist pvc = nil end service.delete_pvc(name) unless pvc.nil? end |
#get(name) ⇒ Object
19 20 21 |
# File 'lib/fog/kubevirt/compute/models/pvcs.rb', line 19 def get(name) new service.get_pvc(name) end |