Sha256: bbfa6c2a4eeba78f5e30589daa88f1b1655fe7fce007597ea4f0822449119ec2

Contents?: true

Size: 1.76 KB

Versions: 44

Compression:

Stored size: 1.76 KB

Contents

require 'fog/openstack/models/model'

module Fog
  module Volume
    class OpenStack
      class Volume < Fog::OpenStack::Model
        attribute :metadata
        attribute :status
        attribute :size
        attribute :volume_type, :aliases => %w(volumeType type)
        attribute :snapshot_id, :aliases => 'snapshotId'
        attribute :imageRef, :aliases => 'image_id'
        attribute :availability_zone, :aliases => 'availabilityZone'
        attribute :created_at, :aliases => 'createdAt'
        attribute :attachments
        attribute :source_volid

        def destroy
          requires :id
          service.delete_volume(id)
          true
        end

        def extend(size)
          requires :id
          service.extend_volume(id, size)
          true
        end

        def ready?
          status == 'available'
        end

        def reset_status(status)
          requires :id
          service.action(id, 'os-reset_status' => {:status => status})
        end

        def create_metadata(metadata)
          replace_metadata(metadata)
        end

        # Existing keys have values updated and new key-value pairs are created, but none are deleted
        def update_metadata(metadata)
          requires :id
          service.update_metadata(id, metadata)
          true
        end

        # All existing key-value pairs are deleted and replaced with the key-value pairs specified here
        def replace_metadata(metadata)
          requires :id
          service.replace_metadata(id, metadata)
          true
        end

        # Delete one specific key-value pair by specifying the key name
        def delete_metadata(key_name)
          requires :id
          service.delete_metadata(id, key_name)
          true
        end
      end
    end
  end
end

Version data entries

44 entries across 42 versions & 3 rubygems

Version Path
fog-openstack-0.1.31 lib/fog/volume/openstack/models/volume.rb
fog-openstack-0.3.10 lib/fog/volume/openstack/models/volume.rb
fog-openstack-0.1.30 lib/fog/volume/openstack/models/volume.rb
fog-openstack-0.1.29 lib/fog/volume/openstack/models/volume.rb
fog-openstack-0.3.9 lib/fog/volume/openstack/models/volume.rb
fog-openstack-0.1.28 lib/fog/volume/openstack/models/volume.rb
fog-openstack-0.3.8 lib/fog/volume/openstack/models/volume.rb
fog-openstack-0.3.7 lib/fog/volume/openstack/models/volume.rb
fog-openstack-0.3.6 lib/fog/volume/openstack/models/volume.rb
fog-openstack-0.3.5 lib/fog/volume/openstack/models/volume.rb
fog-openstack-0.3.4 lib/fog/volume/openstack/models/volume.rb
fog-openstack-0.3.3 lib/fog/volume/openstack/models/volume.rb
fog-openstack-0.3.2 lib/fog/volume/openstack/models/volume.rb
fog-openstack-0.3.0 lib/fog/volume/openstack/models/volume.rb
fog-openstack-0.2.4 lib/fog/volume/openstack/models/volume.rb
fog-openstack-0.2.3 lib/fog/volume/openstack/models/volume.rb
fog-openstack-0.2.2 lib/fog/volume/openstack/models/volume.rb
fog-openstack-0.2.1 lib/fog/volume/openstack/models/volume.rb
fog-openstack-0.2.0 lib/fog/volume/openstack/models/volume.rb
fog-zj-0.1.28 lib/fog/volume/openstack/models/volume.rb