Sha256: c6feb66c4b33d2f1d1a8ed6f9c9e9bcd5bc02cd9c2cc5cf98569b783c1009fb5

Contents?: true

Size: 1.51 KB

Versions: 1

Compression:

Stored size: 1.51 KB

Contents

module Fog
  module Compute
    class ProfitBricks
      class Real
        # This will force a hard reboot of the server.
        # Do not use this method if you want to gracefully reboot the machine.
        # This is the equivalent of powering off the machine and turning it back on
        #
        # ==== Parameters
        # * datacenter_id<~String> - UUID of the data center
        # * server_id<~String>      - UUID of the virtual server
        #
        # ==== Returns
        # * response<~Excon::Response> - No response parameters
        #   (HTTP/1.1 202 Accepted)
        #
        # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#reboot-a-server]
        def reboot_server(datacenter_id, server_id)
          request(
              :expects => [202],
              :method  => 'POST',
              :path    => "/datacenters/#{datacenter_id}/servers/#{server_id}/reboot"
          )
        rescue => error
          Fog::Errors::NotFound.new(error)
        end
      end

      class Mock
        def reboot_server(datacenter_id, server_id)
          if server = self.data[:servers]['items'].find {
              |attrib| attrib['datacenter_id'] == datacenter_id && attrib['id'] == server_id
          }
          else
            raise Fog::Errors::NotFound.new(
                'The requested server resource could not be found'
            )
          end

          response        = Excon::Response.new
          response.status = 202
          response
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fog-profitbricks-2.0.1 lib/fog/profitbricks/requests/compute/reboot_server.rb