class Bcome::Interactive::Session
Attributes
node[R]
responses[R]
Public Class Methods
new(node, item_klass, init_data)
click to toggle source
# File lib/objects/interactive/session.rb, line 32 def initialize(node, item_klass, init_data) @item_klass = item_klass @node = node @responses = {} @init_data = init_data end
run(node, session_type, init_data = {})
click to toggle source
# File lib/objects/interactive/session.rb, line 6 def run(node, session_type, init_data = {}) session_end_message = "\ninteractive session ended\n".informational begin session_klass = session_type.is_a?(Symbol) ? session_type_to_klass[session_type] : session_type session = ::Bcome::Interactive::Session.new(node, session_klass, init_data) session.start rescue ::Bcome::Exception::InteractiveSessionHalt => e puts session_end_message rescue ::Bcome::Exception::CouldNotInitiateSshConnection => e puts 'Caught connection error #2' puts e.message.error rescue ::IRB::Abort puts session_end_message end end
session_type_to_klass()
click to toggle source
# File lib/objects/interactive/session.rb, line 22 def session_type_to_klass { interactive_ssh: ::Bcome::Interactive::SessionItem::TransparentSsh, capture_input: ::Bcome::Interactive::SessionItem::CaptureInput } end
Public Instance Methods
start()
click to toggle source
# File lib/objects/interactive/session.rb, line 39 def start print start_item.start_message if start_item.has_start_message? start_item.do end
start_item()
click to toggle source
# File lib/objects/interactive/session.rb, line 44 def start_item @start_item ||= @item_klass.new(self, @init_data) end