Class: Lbspec::Capture

Inherits:
Object
  • Object
show all
Defined in:
lib/lbspec/capture.rb

Overview

Lbspec::Capture reqresent of capture

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(nodes, bpf = nil, prove = nil, include_str = nil, term_sec = nil) ⇒ Capture

Returns a new instance of Capture.



12
13
14
15
16
17
18
19
20
21
# File 'lib/lbspec/capture.rb', line 12

def initialize(nodes, bpf = nil, prove = nil, include_str = nil,
               term_sec = nil)
  @nodes = nodes.respond_to?(:each) ? nodes : [nodes]
  @bpf = bpf ? bpf : ''
  @prove = prove ? prove : ''
  @include_str = include_str
  @term_sec = term_sec ? term_sec : 5
  set_initial_value
  Util.log.debug("#{self.class} initialized #{inspect}")
end

Instance Attribute Details

#outputObject (readonly)

Returns the value of attribute output.



10
11
12
# File 'lib/lbspec/capture.rb', line 10

def output
  @output
end

#resultObject (readonly)

Returns the value of attribute result.



10
11
12
# File 'lib/lbspec/capture.rb', line 10

def result
  @result
end

Class Method Details

.bpf(options = {}) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/lbspec/capture.rb', line 38

def self.bpf(options = {})
  is_first = true
  filter = ''

  options.each do |k, v|
    next unless k && v
    filter << ' and ' unless is_first
    filter << k.to_s.gsub('_', ' ') + ' ' + v.to_s
    is_first = false
  end
  filter
end

Instance Method Details

#closeObject



28
29
30
31
32
33
34
35
36
# File 'lib/lbspec/capture.rb', line 28

def close
  sleep 0.5 until capture_done?
  @threads.each do |t|
    t.kill
  end
  @ssh.each do |ssh|
    ssh.close unless ssh.closed?
  end
end

#openObject



23
24
25
26
# File 'lib/lbspec/capture.rb', line 23

def open
  @nodes.each { |node| open_node(node) }
  wait_connected
end