Sha256: 46dcc1c895f5b7db5bfcd6e33ed9d1c28329d33d0197802e50d137b833cb7bb9

Contents?: true

Size: 1011 Bytes

Versions: 29

Compression:

Stored size: 1011 Bytes

Contents

require 'fog/core/model'

module Fog
  module Compute
    class HPV2
      class VolumeAttachment < Fog::Model
        identity  :id

        attribute :server_id, :aliases => 'serverId'
        attribute :volume_id, :aliases => 'volumeId'
        attribute :device

        def initialize(new_attributes = {})
          super(new_attributes)
          # server_id needs to be the same as the server from the attachments collection
          server_id = server.id if server
          self
        end

        def save
          requires :server_id, :volume_id, :device
          data = service.attach_volume(server_id, volume_id, device)
          merge_attributes(data.body['volumeAttachment'])
          true
        end

        def destroy
          requires :server_id, :volume_id
          service.detach_volume(server_id, volume_id)
          true
        end
        alias_method :detach, :destroy

        private
        def server
          collection.server
        end
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 4 rubygems

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