Class: Bosh::Deployer::DeployerRenderer

Inherits:
Cli::TaskTracking::EventLogRenderer
  • Object
show all
Defined in:
lib/bosh/deployer/deployer_renderer.rb

Constant Summary collapse

DEFAULT_POLL_INTERVAL =
1

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#indexObject

Returns the value of attribute index.



3
4
5
# File 'lib/bosh/deployer/deployer_renderer.rb', line 3

def index
  @index
end

#stageObject

Returns the value of attribute stage.



3
4
5
# File 'lib/bosh/deployer/deployer_renderer.rb', line 3

def stage
  @stage
end

#totalObject

Returns the value of attribute total.



3
4
5
# File 'lib/bosh/deployer/deployer_renderer.rb', line 3

def total
  @total
end

Instance Method Details

#enter_stage(stage, total) ⇒ Object



25
26
27
28
29
# File 'lib/bosh/deployer/deployer_renderer.rb', line 25

def enter_stage(stage, total)
  @stage = stage
  @total = total
  @index = 0
end

#finish(state) ⇒ Object



20
21
22
23
# File 'lib/bosh/deployer/deployer_renderer.rb', line 20

def finish(state)
  @thread.kill
  super(state)
end

#interval_pollObject



7
8
9
# File 'lib/bosh/deployer/deployer_renderer.rb', line 7

def interval_poll
  Bosh::Cli::Config.poll_interval || DEFAULT_POLL_INTERVAL
end

#parse_event(event) ⇒ Object



31
32
33
# File 'lib/bosh/deployer/deployer_renderer.rb', line 31

def parse_event(event)
  event
end

#startObject



11
12
13
14
15
16
17
18
# File 'lib/bosh/deployer/deployer_renderer.rb', line 11

def start
  @thread = Thread.new do
    loop do
      refresh
      sleep(interval_poll)
    end
  end
end

#update(state, task) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/bosh/deployer/deployer_renderer.rb', line 35

def update(state, task)
  event = {
    'time'     => Time.now,
    'stage'    => @stage,
    'task'     => task,
    'tags'     => [],
    'index'    => @index + 1,
    'total'    => @total,
    'state'    => state.to_s,
    'progress' => state == :finished ? 100 : 0
  }

  add_event(event)

  @index += 1 if state == :finished
end