Class: Bosh::Director::InstanceUpdater::Stopper

Inherits:
Object
  • Object
show all
Defined in:
lib/bosh/director/instance_updater/stopper.rb

Instance Method Summary collapse

Constructor Details

#initialize(instance, agent_client, target_state, config, logger) ⇒ Stopper

Returns a new instance of Stopper.



3
4
5
6
7
8
9
# File 'lib/bosh/director/instance_updater/stopper.rb', line 3

def initialize(instance, agent_client, target_state, config, logger)
  @instance = instance
  @agent_client = agent_client
  @target_state = target_state
  @config = config
  @logger = logger
end

Instance Method Details

#stopObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/bosh/director/instance_updater/stopper.rb', line 11

def stop
  drain_type = shutting_down? ? 'shutdown' : 'update'

  # Apply spec might change after shutdown drain (unlike update drain)
  # because instance's VM could be reconfigured.
  # Drain script can still capture intent from non-final apply spec.
  drain_time = @agent_client.drain(drain_type, @instance.spec)

  if drain_time > 0
    sleep(drain_time)
  else
    wait_for_dynamic_drain(drain_time)
  end

  @agent_client.stop
end