Class: Fog::Kubevirt::Compute::Persistentvolumes
- Inherits:
-
Collection
- Object
- Collection
- Fog::Kubevirt::Compute::Persistentvolumes
- Defined in:
- lib/fog/kubevirt/compute/models/persistentvolumes.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 volume using provided paramters: :name [String] - name of a volume :labels [Hash] - a hash of key,values representing the labels :storage_class [String] - the storage class name of the volume :capacity [String] - The capacity of the storage if applied :accessModes [Arr] - the access modes for the volume, values are specified here: https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes :type [String] - the type of the storage :config [Hash] - storage specific configuration to be applied for the volume correlated to the args.
- #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/persistentvolumes.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/persistentvolumes.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/persistentvolumes.rb', line 12 def all(filters = {}) volumes = service.list_persistentvolumes(filters) @kind = volumes.kind @resource_version = volumes.resource_version load volumes end |
#create(args = {}) ⇒ Object
Creates a volume using provided paramters: :name [String] - name of a volume :labels [Hash] - a hash of key,values representing the labels :storage_class [String] - the storage class name of the volume :capacity [String] - The capacity of the storage if applied :accessModes [Arr] - the access modes for the volume, values are specified here:
https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes
:type [String] - the type of the storage :config [Hash] - storage specific configuration to be applied for the volume correlated to the args
34 35 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 |
# File 'lib/fog/kubevirt/compute/models/persistentvolumes.rb', line 34 def create(args = {}) name = args[:name] labels = args[:labels] # type is required if args[:type].nil? || args[:type].empty? raise ::Fog::Kubevirt::Errors::ValidationError "Type of storage can not be empty" end volume = { :apiVersion => "v1", :kind => "PersistentVolume", :metadata => { :name => name }, :spec => { :storageClassName => args[:storage_class] } } volume[:metadata][:labels] = labels if labels volume[:spec][:capacity] = { :storage => args[:capacity] } if args[:capacity] volume[:spec][:accessModes] = args[:access_modes] if args[:access_modes] volume[:spec][args[:type].to_sym] = args[:config] service.create_persistentvolume(volume) end |
#delete(name) ⇒ Object
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/fog/kubevirt/compute/models/persistentvolumes.rb', line 65 def delete(name) begin volume = get(name) rescue ::Fog::Kubevirt::Errors::ClientError # the volume doesn't exist volume = nil end service.delete_persistentvolume(name) unless volume.nil? end |
#get(name) ⇒ Object
19 20 21 |
# File 'lib/fog/kubevirt/compute/models/persistentvolumes.rb', line 19 def get(name) new service.get_persistentvolume(name) end |