Method: Fog::Kubevirt::Compute::Persistentvolumes#create
- Defined in:
- lib/fog/kubevirt/compute/models/persistentvolumes.rb
#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
to the args[:type]
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 |