Class: Bosh::Director::DeploymentPlan::Planner
- Includes:
- Bosh::Director::DnsHelper, ValidationHelper
- Defined in:
- lib/bosh/director/deployment_plan/planner.rb
Constant Summary
Constants included from Bosh::Director::DnsHelper
Bosh::Director::DnsHelper::SOA, Bosh::Director::DnsHelper::TTL_4H, Bosh::Director::DnsHelper::TTL_5M
Instance Attribute Summary collapse
-
#canonical_name ⇒ String
readonly
Deployment canonical name (for DNS).
-
#compilation ⇒ Bosh::Director::DeploymentPlan::CompilationConfig
Resource pool and other configuration for compilation workers.
-
#dns_domain ⇒ Object
Returns the value of attribute dns_domain.
-
#job_rename ⇒ Object
readonly
Returns the value of attribute job_rename.
-
#jobs ⇒ Array<Bosh::Director::DeploymentPlan::Job>
readonly
All jobs in the deployment.
-
#model ⇒ Models::Deployment
readonly
Deployment DB model.
-
#name ⇒ String
readonly
Deployment name.
-
#properties ⇒ Object
Returns the value of attribute properties.
-
#recreate ⇒ Boolean
readonly
Indicates whether VMs should be recreated.
-
#unneeded_instances ⇒ Object
Job instances from the old manifest that are not in the new manifest.
-
#unneeded_vms ⇒ Object
VMs from the old manifest that are not in the new manifest.
-
#update ⇒ Bosh::Director::DeploymentPlan::UpdateConfig
Default job update configuration.
Class Method Summary collapse
Instance Method Summary collapse
-
#add_job(job) ⇒ Object
Adds a job by name.
-
#add_network(network) ⇒ Object
Adds a network by name.
-
#add_release(release) ⇒ Object
Adds a release by name.
-
#add_resource_pool(resource_pool) ⇒ Object
Adds a resource pool by name.
-
#bind_model ⇒ void
Looks up deployment model in DB or creates one if needed.
-
#delete_instance(instance) ⇒ Object
Adds instance to deletion queue.
-
#delete_vm(vm) ⇒ Object
Adds a VM to deletion queue.
-
#initialize(name, options = {}) ⇒ Planner
constructor
A new instance of Planner.
-
#job(name) ⇒ Bosh::Director::DeploymentPlan::Job
Returns a named job.
- #jobs_starting_on_deploy ⇒ Object
-
#network(name) ⇒ Bosh::Director::DeploymentPlan::Network
Returns a named network.
-
#networks ⇒ Array<Bosh::Director::DeploymentPlan::Network>
Returns all networks in a deployment plan.
-
#release(name) ⇒ Bosh::Director::DeploymentPlan::ReleaseVersion
Returns a named release.
-
#releases ⇒ Array<Bosh::Director::DeploymentPlan::ReleaseVersion>
Returns all releases in a deployment plan.
- #rename_in_progress? ⇒ Boolean
-
#resource_pool(name) ⇒ Bosh::Director::DeploymentPlan::ResourcePool
Returns a named resource pool spec.
-
#resource_pools ⇒ Array<Bosh::Director::DeploymentPlan::ResourcePool>
Returns all resource pools in a deployment plan.
-
#vms ⇒ Array<Models::Vm>
Returns a list of VMs in the deployment (according to DB).
Methods included from ValidationHelper
Methods included from Bosh::Director::DnsHelper
#add_default_dns_server, #canonical, #default_dns_server, #delete_dns_records, #delete_empty_domain, #dns_domain_name, #dns_ns_record, #dns_servers, #invalid_dns, #reverse_domain, #reverse_host, #update_dns_a_record, #update_dns_ptr_record
Constructor Details
#initialize(name, options = {}) ⇒ Planner
Returns a new instance of Planner.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/bosh/director/deployment_plan/planner.rb', line 60 def initialize(name, = {}) raise ArgumentError, 'name must not be nil' unless name @name = name @model = nil @properties = {} @releases = {} @networks = {} @networks_canonical_name_index = Set.new @resource_pools = {} @jobs = [] @jobs_name_index = {} @jobs_canonical_name_index = Set.new @unneeded_vms = [] @unneeded_instances = [] @dns_domain = nil @job_rename = safe_property(, 'job_rename', :class => Hash, :default => {}) @recreate = !!['recreate'] end |
Instance Attribute Details
#canonical_name ⇒ String (readonly)
Returns Deployment canonical name (for DNS).
15 16 17 |
# File 'lib/bosh/director/deployment_plan/planner.rb', line 15 def canonical_name @canonical_name end |
#compilation ⇒ Bosh::Director::DeploymentPlan::CompilationConfig
Returns Resource pool and other configuration for compilation workers.
24 25 26 |
# File 'lib/bosh/director/deployment_plan/planner.rb', line 24 def compilation @compilation end |
#dns_domain ⇒ Object
Returns the value of attribute dns_domain.
40 41 42 |
# File 'lib/bosh/director/deployment_plan/planner.rb', line 40 def dns_domain @dns_domain end |
#job_rename ⇒ Object (readonly)
Returns the value of attribute job_rename.
42 43 44 |
# File 'lib/bosh/director/deployment_plan/planner.rb', line 42 def job_rename @job_rename end |
#jobs ⇒ Array<Bosh::Director::DeploymentPlan::Job> (readonly)
Returns All jobs in the deployment.
32 33 34 |
# File 'lib/bosh/director/deployment_plan/planner.rb', line 32 def jobs @jobs end |
#model ⇒ Models::Deployment (readonly)
Returns Deployment DB model.
18 19 20 |
# File 'lib/bosh/director/deployment_plan/planner.rb', line 18 def model @model end |
#name ⇒ String (readonly)
Returns Deployment name.
12 13 14 |
# File 'lib/bosh/director/deployment_plan/planner.rb', line 12 def name @name end |
#properties ⇒ Object
Returns the value of attribute properties.
20 21 22 |
# File 'lib/bosh/director/deployment_plan/planner.rb', line 20 def properties @properties end |
#recreate ⇒ Boolean (readonly)
Returns Indicates whether VMs should be recreated.
45 46 47 |
# File 'lib/bosh/director/deployment_plan/planner.rb', line 45 def recreate @recreate end |
#unneeded_instances ⇒ Object
Job instances from the old manifest that are not in the new manifest
35 36 37 |
# File 'lib/bosh/director/deployment_plan/planner.rb', line 35 def unneeded_instances @unneeded_instances end |
#unneeded_vms ⇒ Object
VMs from the old manifest that are not in the new manifest
38 39 40 |
# File 'lib/bosh/director/deployment_plan/planner.rb', line 38 def unneeded_vms @unneeded_vms end |
#update ⇒ Bosh::Director::DeploymentPlan::UpdateConfig
Returns Default job update configuration.
28 29 30 |
# File 'lib/bosh/director/deployment_plan/planner.rb', line 28 def update @update end |
Class Method Details
.parse(manifest, options, event_log, logger) ⇒ Bosh::Director::DeploymentPlan::Planner
55 56 57 58 |
# File 'lib/bosh/director/deployment_plan/planner.rb', line 55 def self.parse(manifest, , event_log, logger) parser = DeploymentSpecParser.new(event_log, logger) parser.parse(manifest, ) end |
Instance Method Details
#add_job(job) ⇒ Object
Adds a job by name
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
# File 'lib/bosh/director/deployment_plan/planner.rb', line 212 def add_job(job) if rename_in_progress? && @job_rename['old_name'] == job.name raise DeploymentRenamedJobNameStillUsed, "Renamed job `#{job.name}' is still referenced in " + 'deployment manifest' end if @jobs_canonical_name_index.include?(job.canonical_name) raise DeploymentCanonicalJobNameTaken, "Invalid job name `#{job.name}', canonical name already taken" end @jobs << job @jobs_name_index[job.name] = job @jobs_canonical_name_index << job.canonical_name end |
#add_network(network) ⇒ Object
Adds a network by name
125 126 127 128 129 130 131 132 133 134 |
# File 'lib/bosh/director/deployment_plan/planner.rb', line 125 def add_network(network) if @networks_canonical_name_index.include?(network.canonical_name) raise DeploymentCanonicalNetworkNameTaken, "Invalid network name `#{network.name}', " + 'canonical name already taken' end @networks[network.name] = network @networks_canonical_name_index << network.canonical_name end |
#add_release(release) ⇒ Object
Adds a release by name
174 175 176 177 178 179 180 |
# File 'lib/bosh/director/deployment_plan/planner.rb', line 174 def add_release(release) if @releases.has_key?(release.name) raise DeploymentDuplicateReleaseName, "Duplicate release name `#{release.name}'" end @releases[release.name] = release end |
#add_resource_pool(resource_pool) ⇒ Object
Adds a resource pool by name
151 152 153 154 155 156 157 |
# File 'lib/bosh/director/deployment_plan/planner.rb', line 151 def add_resource_pool(resource_pool) if @resource_pools[resource_pool.name] raise DeploymentDuplicateResourcePoolName, "Duplicate resource pool name `#{resource_pool.name}'" end @resource_pools[resource_pool.name] = resource_pool end |
#bind_model ⇒ void
This method returns an undefined value.
Looks up deployment model in DB or creates one if needed
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/bosh/director/deployment_plan/planner.rb', line 92 def bind_model attrs = {:name => @name} Models::Deployment.db.transaction do deployment = Models::Deployment.find(attrs) # Canonical uniqueness is not enforced in the DB if deployment.nil? Models::Deployment.each do |other| if canonical(other.name) == canonical_name raise DeploymentCanonicalNameTaken, "Invalid deployment name `#{@name}', " + 'canonical name already taken' end end deployment = Models::Deployment.create(attrs) end @model = deployment end end |
#delete_instance(instance) ⇒ Object
Adds instance to deletion queue
202 203 204 205 206 207 208 |
# File 'lib/bosh/director/deployment_plan/planner.rb', line 202 def delete_instance(instance) if @jobs_name_index.has_key?(instance.job) @jobs_name_index[instance.job].unneeded_instances << instance else @unneeded_instances << instance end end |
#delete_vm(vm) ⇒ Object
Adds a VM to deletion queue
196 197 198 |
# File 'lib/bosh/director/deployment_plan/planner.rb', line 196 def delete_vm(vm) @unneeded_vms << vm end |
#job(name) ⇒ Bosh::Director::DeploymentPlan::Job
Returns a named job
232 233 234 |
# File 'lib/bosh/director/deployment_plan/planner.rb', line 232 def job(name) @jobs_name_index[name] end |
#jobs_starting_on_deploy ⇒ Object
236 237 238 |
# File 'lib/bosh/director/deployment_plan/planner.rb', line 236 def jobs_starting_on_deploy @jobs.select(&:starts_on_deploy?) end |
#network(name) ⇒ Bosh::Director::DeploymentPlan::Network
Returns a named network
145 146 147 |
# File 'lib/bosh/director/deployment_plan/planner.rb', line 145 def network(name) @networks[name] end |
#networks ⇒ Array<Bosh::Director::DeploymentPlan::Network>
Returns all networks in a deployment plan
138 139 140 |
# File 'lib/bosh/director/deployment_plan/planner.rb', line 138 def networks @networks.values end |
#release(name) ⇒ Bosh::Director::DeploymentPlan::ReleaseVersion
Returns a named release
190 191 192 |
# File 'lib/bosh/director/deployment_plan/planner.rb', line 190 def release(name) @releases[name] end |
#releases ⇒ Array<Bosh::Director::DeploymentPlan::ReleaseVersion>
Returns all releases in a deployment plan
184 185 186 |
# File 'lib/bosh/director/deployment_plan/planner.rb', line 184 def releases @releases.values end |
#rename_in_progress? ⇒ Boolean
240 241 242 |
# File 'lib/bosh/director/deployment_plan/planner.rb', line 240 def rename_in_progress? @job_rename['old_name'] && @job_rename['new_name'] end |
#resource_pool(name) ⇒ Bosh::Director::DeploymentPlan::ResourcePool
Returns a named resource pool spec
168 169 170 |
# File 'lib/bosh/director/deployment_plan/planner.rb', line 168 def resource_pool(name) @resource_pools[name] end |
#resource_pools ⇒ Array<Bosh::Director::DeploymentPlan::ResourcePool>
Returns all resource pools in a deployment plan
161 162 163 |
# File 'lib/bosh/director/deployment_plan/planner.rb', line 161 def resource_pools @resource_pools.values end |
#vms ⇒ Array<Models::Vm>
Returns a list of VMs in the deployment (according to DB)
116 117 118 119 120 121 |
# File 'lib/bosh/director/deployment_plan/planner.rb', line 116 def vms if @model.nil? raise DirectorError, "Can't get VMs list, deployment model is unbound" end @model.vms end |