Class: Bosh::Director::DeploymentPlan::InstanceRepository
- Defined in:
- lib/bosh/director/deployment_plan/instance_repository.rb
Instance Method Summary collapse
- #create(desired_instance, index) ⇒ Object
- #fetch_existing(existing_instance_model, existing_instance_state, job, index, deployment) ⇒ Object
-
#initialize(network_reservation_repostory, logger) ⇒ InstanceRepository
constructor
A new instance of InstanceRepository.
Constructor Details
#initialize(network_reservation_repostory, logger) ⇒ InstanceRepository
Returns a new instance of InstanceRepository.
3 4 5 6 |
# File 'lib/bosh/director/deployment_plan/instance_repository.rb', line 3 def initialize(network_reservation_repostory, logger) @network_reservation_repository = network_reservation_repostory @logger = logger end |
Instance Method Details
#create(desired_instance, index) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/bosh/director/deployment_plan/instance_repository.rb', line 22 def create(desired_instance, index) @logger.debug("Creating new desired instance for: #{desired_instance.inspect}") instance = Instance.create_from_job(desired_instance.job, index, 'started', desired_instance.deployment.model, nil, desired_instance.az, @logger) instance.bind_new_instance_model instance end |
#fetch_existing(existing_instance_model, existing_instance_state, job, index, deployment) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/bosh/director/deployment_plan/instance_repository.rb', line 8 def fetch_existing(existing_instance_model, existing_instance_state, job, index, deployment) @logger.debug("Fetching existing instance for: #{existing_instance_model.inspect}") # if state was not specified in manifest, use saved state job_state = job.state_for_instance(existing_instance_model) || existing_instance_model.state @logger.debug("Job instance states: #{job.instance_states}, found: #{job.state_for_instance(existing_instance_model)}, state: #{job_state}") instance = Instance.create_from_job(job, index, job_state, deployment.model, existing_instance_state, existing_instance_model.availability_zone, @logger) instance.bind_existing_instance_model(existing_instance_model) existing_network_reservations = @network_reservation_repository.fetch_network_reservations(existing_instance_model, existing_instance_state) instance.bind_existing_reservations(existing_network_reservations) instance end |