Class: Bosh::Director::DeploymentPlan::CloudPlanner

Inherits:
Object
  • Object
show all
Defined in:
lib/bosh/director/deployment_plan/planner.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ CloudPlanner

Returns a new instance of CloudPlanner.



299
300
301
302
303
304
305
306
307
308
309
310
# File 'lib/bosh/director/deployment_plan/planner.rb', line 299

def initialize(options)
  @networks = self.class.index_by_name(options.fetch(:networks))
  @global_network_resolver = options.fetch(:global_network_resolver)
  @resource_pools = self.class.index_by_name(options.fetch(:resource_pools))
  @vm_types = self.class.index_by_name(options.fetch(:vm_types, {}))
  @vm_extensions = self.class.index_by_name(options.fetch(:vm_extensions, {}))
  @disk_types = self.class.index_by_name(options.fetch(:disk_types))
  @availability_zones = options.fetch(:availability_zones_list)
  @compilation = options.fetch(:compilation)
  @ip_provider_factory = options.fetch(:ip_provider_factory)
  @logger = options.fetch(:logger)
end

Instance Attribute Details

#compilationObject

Returns the value of attribute compilation.



297
298
299
# File 'lib/bosh/director/deployment_plan/planner.rb', line 297

def compilation
  @compilation
end

Class Method Details

.index_by_name(collection) ⇒ Object



389
390
391
392
393
# File 'lib/bosh/director/deployment_plan/planner.rb', line 389

def self.index_by_name(collection)
  collection.inject({}) do |index, item|
    index.merge(item.name => item)
  end
end

Instance Method Details

#add_resource_pool(resource_pool) ⇒ Object



365
366
367
# File 'lib/bosh/director/deployment_plan/planner.rb', line 365

def add_resource_pool(resource_pool)
  @resource_pools[resource_pool.name] = resource_pool
end

#availability_zone(name) ⇒ Object



329
330
331
# File 'lib/bosh/director/deployment_plan/planner.rb', line 329

def availability_zone(name)
  @availability_zones[name]
end

#availability_zonesObject



333
334
335
# File 'lib/bosh/director/deployment_plan/planner.rb', line 333

def availability_zones
  @availability_zones.values
end

#deleted_network(name) ⇒ Object



320
321
322
323
324
325
326
327
# File 'lib/bosh/director/deployment_plan/planner.rb', line 320

def deleted_network(name)
  ManualNetwork.parse(
    {'subnets' => [], 'name' => name},
    [],
    @global_network_resolver,
    @logger
  )
end

#disk_type(name) ⇒ Object



385
386
387
# File 'lib/bosh/director/deployment_plan/planner.rb', line 385

def disk_type(name)
  @disk_types[name]
end

#disk_typesObject



377
378
379
# File 'lib/bosh/director/deployment_plan/planner.rb', line 377

def disk_types
  @disk_types.values
end

#ip_providerObject



312
313
314
# File 'lib/bosh/director/deployment_plan/planner.rb', line 312

def ip_provider
  @ip_provider ||= @ip_provider_factory.new_ip_provider(@networks)
end

#modelObject



316
317
318
# File 'lib/bosh/director/deployment_plan/planner.rb', line 316

def model
  nil
end

#network(name) ⇒ Object



373
374
375
# File 'lib/bosh/director/deployment_plan/planner.rb', line 373

def network(name)
  @networks[name]
end

#networksObject



369
370
371
# File 'lib/bosh/director/deployment_plan/planner.rb', line 369

def networks
  @networks.values
end

#resource_pool(name) ⇒ Object



341
342
343
# File 'lib/bosh/director/deployment_plan/planner.rb', line 341

def resource_pool(name)
  @resource_pools[name]
end

#resource_poolsObject



337
338
339
# File 'lib/bosh/director/deployment_plan/planner.rb', line 337

def resource_pools
  @resource_pools.values
end

#using_global_networking?Boolean

Returns:

  • (Boolean)


381
382
383
# File 'lib/bosh/director/deployment_plan/planner.rb', line 381

def using_global_networking?
  false
end

#vm_extension(name) ⇒ Object



357
358
359
360
361
362
363
# File 'lib/bosh/director/deployment_plan/planner.rb', line 357

def vm_extension(name)
  unless @vm_extensions.has_key?(name)
    raise "The vm_extension '#{name}' has not been configured in cloud-config."
  end

  @vm_extensions[name]
end

#vm_extensionsObject



353
354
355
# File 'lib/bosh/director/deployment_plan/planner.rb', line 353

def vm_extensions
  @vm_extensions.values
end

#vm_type(name) ⇒ Object



349
350
351
# File 'lib/bosh/director/deployment_plan/planner.rb', line 349

def vm_type(name)
  @vm_types[name]
end

#vm_typesObject



345
346
347
# File 'lib/bosh/director/deployment_plan/planner.rb', line 345

def vm_types
  @vm_types.values
end