Class: RightScale::ShutdownRequestProxy

Inherits:
Object
  • Object
show all
Includes:
ShutdownRequestMixin
Defined in:
lib/instance/cook/shutdown_request_proxy.rb

Overview

Proxy for a remote shutdown request state.

Defined Under Namespace

Classes: ShutdownQueryFailed

Constant Summary

Constants included from ShutdownRequestMixin

RightScale::ShutdownRequestMixin::CONTINUE, RightScale::ShutdownRequestMixin::LEVELS, RightScale::ShutdownRequestMixin::REBOOT, RightScale::ShutdownRequestMixin::STOP, RightScale::ShutdownRequestMixin::TERMINATE

Class Method Summary collapse

Methods included from ShutdownRequestMixin

#continue?, #immediately!, #immediately?, #level, #level=, #to_s

Class Method Details

.init(command_client) ⇒ Object

Class initializer.

Return

always true



37
38
39
40
# File 'lib/instance/cook/shutdown_request_proxy.rb', line 37

def self.init(command_client)
  @@command_client = command_client
  true
end

.instanceObject

Factory method

Return

(ShutdownRequestProxy)

the proxy instance for this class



46
47
48
49
50
51
52
53
# File 'lib/instance/cook/shutdown_request_proxy.rb', line 46

def self.instance
  # note that we never want the proxy to use a cached instance of the
  # shutdown state as RightScripts and command-line actions can change the
  # state without directly notifying the proxy.
  result = send_shutdown_request(:name => :get_shutdown_request)
  raise ShutdownQueryFailed.new("Unable to retrieve state of shutdown request from parent process.") unless result
  return result
end

.submit(request) ⇒ Object

Submits a new shutdown request state which may be superceded by a previous, higher-priority shutdown level.

Parameters

request(String)

shutdown level

request(Boolean)

shutdown immediacy or nil

Returns

result(ShutdownRequestProxy)

the updated shutdown request state



64
65
66
67
68
69
70
# File 'lib/instance/cook/shutdown_request_proxy.rb', line 64

def self.submit(request)
  level = request[:kind] || request[:level]
  immediately = !!request[:immediately]
  result = send_shutdown_request(:name => :set_shutdown_request, :level => level, :immediately => immediately)
  raise ShutdownQueryFailed.new("Unable to set state of shutdown request on parent process.") unless result
  return result
end