Sha256: f8b8b6eaa78945b534c45442d90c9f7e8f1c215cb6fbdf3ef3d4f47e09815d47

Contents?: true

Size: 1.59 KB

Versions: 1

Compression:

Stored size: 1.59 KB

Contents

#
# Author:: Alessio Rocchi (<alessio.rocchi@staff.aruba.it>)
# © Copyright ArubaCloud.
#
# LICENSE: MIT (http://opensource.org/licenses/MIT)
#

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

module Fog
  module Compute
    class ArubaCloud
      class Real
        # Reinitialize a Smart VM
        # @param id [String] the id of the virtual machine to reinitialize
        # @return response [Excon::Response]
        def reinitialize_vm(id)
          body = self.body('SetEnqueueReinitializeServer').merge({
                                                                     :ServerId => id
                                                                 })
          options = {
              :http_method => :post,
              :method => 'GetServers',
              :body => Fog::JSON.encode(body)
          }
          response = nil
          time = Benchmark.realtime {
            response = request(options)
          }
          Fog::Logger.debug("SetEnqueueReinitializeServer time: #{time}")
          if response['Success']
            response
          else
            raise Fog::ArubaCloud::Errors::RequestError
          end
        end # reinitialize_vm
      end # Real

      class Mock
        def reinitialize_vm(id)
          response = Excon::Response.new
          response.status = 200
          response.body = {
              'ExceptionInfo' => nil,
              'ResultCode' => 0,
              'ResultMessage' => nil,
              'Success' => true
          }
          response.body
        end # reinitialize_vm
      end # Mock

    end # ArubaCloud
  end # Compute
end # Fog

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fog-arubacloud-0.0.3 lib/fog/arubacloud/requests/compute/reinitialize_vm.rb