Class: Bosh::Director::DeploymentPlan::CompilationConfig
- Includes:
- ValidationHelper
- Defined in:
- lib/bosh/director/deployment_plan/compilation_config.rb
Overview
Represents the deployment compilation worker configuration.
Instance Attribute Summary collapse
-
#availability_zone ⇒ Object
readonly
Returns the value of attribute availability_zone.
-
#cloud_properties ⇒ Hash
readonly
Cloud properties to use when creating VMs.
-
#env ⇒ Hash
Environment to use when creating VMs.
-
#network_name ⇒ Object
readonly
Returns the value of attribute network_name.
-
#reuse_compilation_vms ⇒ Bool
If VMs should be reused for compilation tasks.
-
#vm_type ⇒ Object
readonly
Returns the value of attribute vm_type.
-
#workers ⇒ Integer
Number of worker VMs to use.
Instance Method Summary collapse
- #availability_zone_name ⇒ Object
-
#initialize(compilation_config, azs_list, vm_types = []) ⇒ CompilationConfig
constructor
A new instance of CompilationConfig.
Methods included from ValidationHelper
Constructor Details
#initialize(compilation_config, azs_list, vm_types = []) ⇒ CompilationConfig
Returns a new instance of CompilationConfig.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/bosh/director/deployment_plan/compilation_config.rb', line 26 def initialize(compilation_config, azs_list, vm_types = []) @workers = safe_property(compilation_config, 'workers', class: Integer, min: 1) @network_name = safe_property(compilation_config, 'network', class: String) @reuse_compilation_vms = safe_property(compilation_config, 'reuse_compilation_vms', class: :boolean, optional: true) @cloud_properties = safe_property( compilation_config, 'cloud_properties', class: Hash, default: {}) @env = safe_property(compilation_config, 'env', class: Hash, optional: true, default: {}) az_name = safe_property(compilation_config, 'az', class: String, optional: true) @availability_zone = azs_list[az_name] if az_name && !az_name.empty? && @availability_zone.nil? raise Bosh::Director::CompilationConfigInvalidAvailabilityZone, "Compilation config references unknown az '#{az_name}'. Known azs are: [#{azs_list.keys.join(', ')}]" end vm_type_name = safe_property(compilation_config, 'vm_type', class: String, optional: true) if vm_type_name @vm_type = vm_types.find { |vm_type| vm_type.name == vm_type_name } if @vm_type.nil? vm_types_names = vm_types.map { |vm_type| vm_type.name } raise Bosh::Director::CompilationConfigInvalidVmType, "Compilation config references unknown vm type '#{vm_type_name}'. Known vm types are: #{vm_types_names.join(', ')}" end unless @cloud_properties.empty? raise Bosh::Director::CompilationConfigCloudPropertiesNotAllowed, "Compilation config is using vm type '#{@vm_type.name}' and should not be configuring cloud_properties." end end end |
Instance Attribute Details
#availability_zone ⇒ Object (readonly)
Returns the value of attribute availability_zone.
22 23 24 |
# File 'lib/bosh/director/deployment_plan/compilation_config.rb', line 22 def availability_zone @availability_zone end |
#cloud_properties ⇒ Hash (readonly)
Returns cloud properties to use when creating VMs. (optional).
12 13 14 |
# File 'lib/bosh/director/deployment_plan/compilation_config.rb', line 12 def cloud_properties @cloud_properties end |
#env ⇒ Hash
Returns environment to use when creating VMs. (optional).
15 16 17 |
# File 'lib/bosh/director/deployment_plan/compilation_config.rb', line 15 def env @env end |
#network_name ⇒ Object (readonly)
Returns the value of attribute network_name.
20 21 22 |
# File 'lib/bosh/director/deployment_plan/compilation_config.rb', line 20 def network_name @network_name end |
#reuse_compilation_vms ⇒ Bool
Returns if VMs should be reused for compilation tasks. (optional).
18 19 20 |
# File 'lib/bosh/director/deployment_plan/compilation_config.rb', line 18 def reuse_compilation_vms @reuse_compilation_vms end |
#vm_type ⇒ Object (readonly)
Returns the value of attribute vm_type.
24 25 26 |
# File 'lib/bosh/director/deployment_plan/compilation_config.rb', line 24 def vm_type @vm_type end |
#workers ⇒ Integer
Returns number of worker VMs to use.
9 10 11 |
# File 'lib/bosh/director/deployment_plan/compilation_config.rb', line 9 def workers @workers end |
Instance Method Details
#availability_zone_name ⇒ Object
65 66 67 |
# File 'lib/bosh/director/deployment_plan/compilation_config.rb', line 65 def availability_zone_name @availability_zone.nil? ? nil : @availability_zone.name end |