Sha256: 9d7ce6ff8b42b8b8884ecf5b99db79058eed07ed12e674a40113518ea482e789

Contents?: true

Size: 1.12 KB

Versions: 9

Compression:

Stored size: 1.12 KB

Contents

module Fog
  module Compute
    class QingCloud
      class Real


        # Detach an  EBS volume from a running instance
        #
        # {API Reference}[https://docs.qingcloud.com/api/volume/detach_volumes.html]
        def detach_volumes(server_id, volume_id)
          args = {
            'action'   => 'DetachVolumes',
            'instance'    => server_id
          }.merge Fog::QingCloud.indexed_param('volumes', volume_id)
          request(args)
        end

      end

      class Mock

        def detach_volumes(server_id, volume_id)
          response = Excon::Response.new
          response.status = 200

          raise Fog::QingCloud::Errors::NotFound, "server #{server_id} not found" unless self.data[:instances][server_id]
          
          [*volume_id].each do |vid|
             self.data[:instances][server_id]['volume_ids'].delete(vid)
             self.data[:volumes][vid]['instance'] = {}
          end
          response.body = {
            'action' => 'DetachVolumesResponse',
            'job_id' => Fog::QingCloud::Mock.job_id,
            'ret_code' => 0
          }
        end

      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ns-fog-1.22.11 lib/fog/qingcloud/requests/compute/detach_volumes.rb
ns-fog-1.22.10 lib/fog/qingcloud/requests/compute/detach_volumes.rb
ns-fog-1.22.9 lib/fog/qingcloud/requests/compute/detach_volumes.rb
ns-fog-1.22.8 lib/fog/qingcloud/requests/compute/detach_volumes.rb
ns-fog-1.22.7 lib/fog/qingcloud/requests/compute/detach_volumes.rb
ns-fog-1.22.6 lib/fog/qingcloud/requests/compute/detach_volumes.rb
ns-fog-1.22.4 lib/fog/qingcloud/requests/compute/detach_volumes.rb
ns-fog-1.22.3 lib/fog/qingcloud/requests/compute/detach_volumes.rb
ns-fog-1.22.2 lib/fog/qingcloud/requests/compute/detach_volumes.rb