Sha256: 647adb322610627eb247b37f9f2acf7121849237c8e09b320f72d80de6cdfefe

Contents?: true

Size: 1.63 KB

Versions: 30

Compression:

Stored size: 1.63 KB

Contents

require 'fog/cloudsigma/nested_model'

module Fog
  module Compute
    class CloudSigma
      class Volume < Fog::CloudSigma::CloudsigmaModel
        identity :uuid

        attribute :status, :type => :string
        attribute :jobs
        attribute :name, :type => :string
        attribute :tags
        attribute :media, :type => :string
        attribute :mounted_on
        attribute :owner
        attribute :meta
        attribute :allow_multimount, :type => :boolean
        attribute :licenses
        attribute :affinities, :type => :array
        attribute :size, :type => :integer
        attribute :resource_uri, :type => :string

        def save
          if persisted?
            update
          else
            create
          end
        end

        def create
          requires :name, :size, :media
          data = attributes

          response = service.create_volume(data)
          new_attributes = response.body['objects'].first
          merge_attributes(new_attributes)
        end

        def update
          requires :identity, :name, :size, :media

          data = attributes()

          response = service.update_volume(identity, data)
          new_attributes = response.body
          merge_attributes(new_attributes)
        end

        def destroy
          requires :identity

          service.delete_volume(identity)

          true
        end

        alias_method :delete, :destroy

        def clone(clone_params={})
          requires :identity
          response = service.clone_volume(identity, clone_params)

          self.class.new(response.body['objects'].first)
        end
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 4 rubygems

Version Path
fog-1.38.0 lib/fog/cloudsigma/models/volume.rb
fog-1.37.0 lib/fog/cloudsigma/models/volume.rb
fog-1.36.0 lib/fog/cloudsigma/models/volume.rb
fog-1.35.0 lib/fog/cloudsigma/models/volume.rb
fog-2.0.0.pre.0 lib/fog/cloudsigma/models/volume.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-1.32.0/lib/fog/cloudsigma/models/volume.rb
fog-1.34.0 lib/fog/cloudsigma/models/volume.rb
fog-1.33.0 lib/fog/cloudsigma/models/volume.rb
fog-1.32.0 lib/fog/cloudsigma/models/volume.rb
fog-1.31.0 lib/fog/cloudsigma/models/volume.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-1.22.1/lib/fog/cloudsigma/models/volume.rb
fog-1.30.0 lib/fog/cloudsigma/models/volume.rb
fog-1.29.0 lib/fog/cloudsigma/models/volume.rb
fog-1.28.0 lib/fog/cloudsigma/models/volume.rb
fog-1.27.0 lib/fog/cloudsigma/models/volume.rb
fog-1.26.0 lib/fog/cloudsigma/models/volume.rb
fog-1.25.0 lib/fog/cloudsigma/models/volume.rb
nsidc-fog-1.24.1 lib/fog/cloudsigma/models/volume.rb
fog-1.24.0 lib/fog/cloudsigma/models/volume.rb
ns-fog-1.22.11 lib/fog/cloudsigma/models/volume.rb