Sha256: 9e5b772672f171101f98eae3edd98899d836a0ca0f8e7d03b7b6a087e17b309f

Contents?: true

Size: 1.47 KB

Versions: 1

Compression:

Stored size: 1.47 KB

Contents

# coding: utf-8
#
# Author:: Dangleterre Michaël
# © Copyright ArubaCloud.
#
# LICENSE: MIT (http://opensource.org/licenses/MIT)
#

require 'fog/arubacloud/service'
require 'fog/arubacloud/error'
require 'benchmark'


module Fog
  module ArubaCloud
    class Compute
      class Real
        # Delete a snapshot on a VM
        def delete_snapshot(id)
          body = self.body('SetEnqueueServerSnapshot').merge(
            {
              :ServerId => id ,  :SnapshotOperation => Fog::ArubaCloud::Compute::SNAPOPTYPE["Delete"]
            }
          )
          response = nil
          time = Benchmark.realtime {
            response = request(body , 'SetEnqueueServerSnapshot', 'Error while attempting to delete a snapshot.')
          }
          Fog::Logger.debug("SetEnqueueServerSnapshot time: #{time}")
          if response['Success']
            response_ext = response.merge( {  "Req" => "Delete" , "Id" => id })
            response_ext
          else
            raise Fog::ArubaCloud::Errors::RequestError.new(response)
          end
        end #Delete
      end #Real

      class Mock
        def delete_snapshot
          response = Excon::Response.new
          response.status = 200
          response.body = {
              'ExceptionInfo' => nil,
              'ResultCode' => 0,
              'ResultMessage' => nil,
              'Success' => true
          }
          response.body
        end #delete snapshot
      end # Mock

    end # Compute
  end # ArubaCloud
end # Fog

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fog-arubacloud-0.0.6 lib/fog/arubacloud/compute/requests/delete_snapshot.rb