Class: RightScale::AuditStub

Inherits:
Object
  • Object
show all
Includes:
RightSupport::Ruby::EasySingleton
Defined in:
lib/instance/cook/audit_stub.rb

Overview

Provides access to RightLink agent audit methods

Instance Method Summary collapse

Instance Method Details

#append_error(text, options = nil) ⇒ Object

Append error message to current audit section. A special marker will be prepended to each line of audit to indicate that error message is not some output. Message will be line-wrapped.

Parameters

text(String)

Error text to append to audit entry

Return

true

Always return true



114
115
116
# File 'lib/instance/cook/audit_stub.rb', line 114

def append_error(text, options = nil)
  send_command(:audit_append_error, text, options)
end

#append_info(text, options = nil) ⇒ Object

Append info text to current audit section. A special marker will be prepended to each line of audit to indicate that text is not some output. Text will be line-wrapped.

Parameters

text(String)

Informational text to append to audit entry

options(String)

Optional, must be one of RightScale::EventCategories::CATEGORIES

Return

true

Always return true



102
103
104
# File 'lib/instance/cook/audit_stub.rb', line 102

def append_info(text, options = nil)
  send_command(:audit_append_info, text, options)
end

#append_output(text, options = nil) ⇒ Object

Append output to current audit section

Parameters

text(String)

Output to append to audit entry

Return

true

Always return true



89
90
91
# File 'lib/instance/cook/audit_stub.rb', line 89

def append_output(text, options = nil)
  send_command(:audit_append_output, text, options)
end

#create_new_section(title, options = nil) ⇒ Object

Start new audit section

Parameters

title(String)

Title of new audit section, will replace audit status as well

options(String)

Optional, must be one of RightScale::EventCategories::CATEGORIES

Return

true

Always return true



78
79
80
# File 'lib/instance/cook/audit_stub.rb', line 78

def create_new_section(title, options = nil)
  send_command(:audit_create_new_section, title, options)
end

#init(options) ⇒ Object

Initialize command protocol, call prior to calling any instance method

Parameters

options

Command server listen port

options

Command protocol cookie

Return

true

Always return true



38
39
40
41
# File 'lib/instance/cook/audit_stub.rb', line 38

def init(options)
  @agent_connection = EM.connect('127.0.0.1', options[:listen_port], AgentConnection, options[:cookie], options[:thread_name])
  true
end

#stop(&callback) ⇒ Object

Stop command client, wait for all pending commands to finish prior to calling given callback

Block

called once all pending commands have completed



48
49
50
51
52
53
54
55
56
# File 'lib/instance/cook/audit_stub.rb', line 48

def stop(&callback)
  if @agent_connection
    # allow any pending audits to be sent prior to stopping agent connection
    # by placing stop on the end of the next_tick queue.
    EM.next_tick { @agent_connection.stop(&callback) }
  else
    callback.call
  end
end

#update_status(status, options = nil) ⇒ Object

Update audit summary

Parameters

status(String)

New audit entry status

options(String)

Optional, must be one of RightScale::EventCategories::CATEGORIES

Return

true

Always return true



66
67
68
# File 'lib/instance/cook/audit_stub.rb', line 66

def update_status(status, options = nil)
  send_command(:audit_update_status, status, options)
end