class Bosh::Director::DeploymentPlan::InstanceSpec

Public Class Methods

create_empty() click to toggle source
# File lib/bosh/director/deployment_plan/instance_spec.rb, line 4
def self.create_empty
  EmptyInstanceSpec.new
end
create_from_database(spec, instance) click to toggle source
# File lib/bosh/director/deployment_plan/instance_spec.rb, line 8
def self.create_from_database(spec, instance)
  new(spec, instance)
end
create_from_instance_plan(instance_plan) click to toggle source
# File lib/bosh/director/deployment_plan/instance_spec.rb, line 12
def self.create_from_instance_plan(instance_plan)
  instance = instance_plan.instance
  deployment_name = instance.deployment_model.name
  job = instance_plan.desired_instance.job
  instance_plan = instance_plan
  dns_manager = DnsManagerProvider.create

  spec = {
    'deployment' => deployment_name,
    'job' => job.spec,
    'index' => instance.index,
    'bootstrap' => instance.bootstrap?,
    'name' => instance.job_name,
    'id' => instance.uuid,
    'az' => instance.availability_zone_name,
    'networks' => instance_plan.network_settings_hash,
    'vm_type' => job.vm_type.spec,
    'stemcell' => job.stemcell.spec,
    'env' => job.env.spec,
    'packages' => job.package_spec,
    'properties' => job.properties,
    'properties_need_filtering' => true,
    'dns_domain_name' => dns_manager.dns_domain_name,
    'links' => job.link_spec,
    'address' => instance_plan.network_settings.network_address,
    'update' => job.update_spec
  }

  if job.persistent_disk_type
    # supply both for reverse compatibility with old agent
    spec['persistent_disk'] = job.persistent_disk_type.disk_size
    # old agents will ignore this pool
    # keep disk pool for backwards compatibility
    spec['persistent_disk_pool'] = job.persistent_disk_type.spec
    spec['persistent_disk_type'] = job.persistent_disk_type.spec
  else
    spec['persistent_disk'] = 0
  end

  new(spec, instance)
end
new(full_spec, instance) click to toggle source
# File lib/bosh/director/deployment_plan/instance_spec.rb, line 54
def initialize(full_spec, instance)
  @full_spec = full_spec
  @instance = instance
end

Public Instance Methods

as_apply_spec() click to toggle source
# File lib/bosh/director/deployment_plan/instance_spec.rb, line 63
def as_apply_spec
  ApplySpec.new(full_spec).spec
end
as_template_spec() click to toggle source
# File lib/bosh/director/deployment_plan/instance_spec.rb, line 59
def as_template_spec
  TemplateSpec.new(full_spec).spec
end
full_spec() click to toggle source
# File lib/bosh/director/deployment_plan/instance_spec.rb, line 67
def full_spec
  # re-generate spec with rendered templates info
  # since job renderer sets it directly on instance
  spec = @full_spec

  if @instance.template_hashes
    spec['template_hashes'] = @instance.template_hashes
  end

  if @instance.rendered_templates_archive
    spec['rendered_templates_archive'] = @instance.rendered_templates_archive.spec
  end

  if @instance.configuration_hash
    spec['configuration_hash'] = @instance.configuration_hash
  end

  spec
end