Class: Bosh::Director::InstanceUpdater::NetworkUpdater::PrepareNetworkChangeStrategy

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

Overview

Older agents only support prepare_network_change

Instance Method Summary collapse

Constructor Details

#initialize(agent_client, network_settings, logger) ⇒ PrepareNetworkChangeStrategy

Returns a new instance of PrepareNetworkChangeStrategy.



78
79
80
81
82
# File 'lib/bosh/director/instance_updater/network_updater.rb', line 78

def initialize(agent_client, network_settings, logger)
  @agent_client = agent_client
  @network_settings = network_settings
  @logger = logger
end

Instance Method Details

#after_configure_networksObject



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/bosh/director/instance_updater/network_updater.rb', line 88

def after_configure_networks
  # Some CPIs might power off and then power on vm to reconfigure network adapters,
  # so Director needs to wait for agent to become responsive
  @logger.info('Waiting for agent to become responsive')
  @agent_client.wait_until_ready

  # Once CPI has configured the vm and stored the new network settings at the registry,
  # we restart the agent via a 'prepare_network_change' message in order for the agent
  # to pick up the new network settings.
  @agent_client.prepare_network_change(@network_settings)

  # Since current implementation of prepare_network_change is to kill the agent
  # we need to wait until the agent is ready. However, we want to avoid
  # talking to the old agent, so we need to wait for it to die.
  @logger.info('Sleeping after prepare_network_change message')
  sleep(5)

  @logger.info('Waiting for agent to become responsive')
  @agent_client.wait_until_ready
end

#before_configure_networksObject



84
85
86
# File 'lib/bosh/director/instance_updater/network_updater.rb', line 84

def before_configure_networks
  true
end