Class: Bosh::Director::DeploymentPlan::AgentStateMigrator
- Defined in:
- lib/bosh/director/deployment_plan/agent_state_migrator.rb
Instance Method Summary collapse
- #get_state(instance) ⇒ Object
-
#initialize(deployment_plan, logger) ⇒ AgentStateMigrator
constructor
A new instance of AgentStateMigrator.
- #verify_state(instance, state) ⇒ Object
Constructor Details
#initialize(deployment_plan, logger) ⇒ AgentStateMigrator
Returns a new instance of AgentStateMigrator.
4 5 6 7 |
# File 'lib/bosh/director/deployment_plan/agent_state_migrator.rb', line 4 def initialize(deployment_plan, logger) @deployment_plan = deployment_plan @logger = logger end |
Instance Method Details
#get_state(instance) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/bosh/director/deployment_plan/agent_state_migrator.rb', line 9 def get_state(instance) @logger.debug("Requesting current VM state for: #{instance.agent_id}") agent = AgentClient.with_vm_credentials_and_agent_id(instance.credentials, instance.agent_id) state = agent.get_state @logger.debug("Received VM state: #{state.pretty_inspect}") verify_state(instance, state) @logger.debug('Verified VM state') state.delete('release') if state.include?('job') state['job'].delete('release') end state end |
#verify_state(instance, state) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/bosh/director/deployment_plan/agent_state_migrator.rb', line 25 def verify_state(instance, state) unless state.kind_of?(Hash) @logger.error("Invalid state for '#{instance.vm_cid}': #{state.pretty_inspect}") raise AgentInvalidStateFormat, "VM '#{instance.vm_cid}' returns invalid state: " + "expected Hash, got #{state.class}" end end |