Class: OAS::LogCollector::Source
- Inherits:
-
Object
- Object
- OAS::LogCollector::Source
- Defined in:
- lib/oas/log_collector/source.rb
Defined Under Namespace
Classes: Error
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #download(files) ⇒ Object
- #find(path, options = {}) ⇒ Object
-
#initialize(host, user, port = 22) ⇒ Source
constructor
A new instance of Source.
Constructor Details
#initialize(host, user, port = 22) ⇒ Source
Returns a new instance of Source.
12 13 14 |
# File 'lib/oas/log_collector/source.rb', line 12 def initialize(host, user, port = 22) @host, @user, @port = host, user, port end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
10 11 12 |
# File 'lib/oas/log_collector/source.rb', line 10 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
10 11 12 |
# File 'lib/oas/log_collector/source.rb', line 10 def port @port end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
10 11 12 |
# File 'lib/oas/log_collector/source.rb', line 10 def user @user end |
Instance Method Details
#download(files) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/oas/log_collector/source.rb', line 27 def download(files) Net::SCP.start(host, user, :port => port) do |scp| files.each do |remote_path, dest_path| FileUtils.mkdir_p(File.dirname(dest_path)) scp.download!(remote_path, dest_path, :preserve => true) end end end |
#find(path, options = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/oas/log_collector/source.rb', line 16 def find(path, = {}) out = '' ssh = Net::SSH.start(host, user, :port => port) ssh.exec!(build_find(path, )) do |channel, stream, data| raise Error.new(data) if stream == :stderr out << data end ssh.close out.split("\n") end |