Class: Vcloud::Launcher::Preamble

Inherits:
Object
  • Object
show all
Defined in:
lib/vcloud/launcher/preamble.rb

Defined Under Namespace

Classes: MissingConfigurationError, MissingTemplateError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(vapp_name, vm_config) ⇒ Preamble

Returns a new instance of Preamble.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/vcloud/launcher/preamble.rb', line 11

def initialize(vapp_name, vm_config)
  @vapp_name        = vapp_name
  bootstrap_config  = vm_config[:bootstrap]

  raise MissingConfigurationError if bootstrap_config.nil?

  @script_path = bootstrap_config.fetch(:script_path, nil)
  raise MissingTemplateError unless @script_path

  # Missing vars is acceptable - noop template.
  @preamble_vars = bootstrap_config.fetch(:vars, {})
  extra_disks    = vm_config.fetch(:extra_disks, {})

  @preamble_vars.merge!(extra_disks: extra_disks)

  @script_post_processor = bootstrap_config.fetch(:script_post_processor, nil)
end

Instance Attribute Details

#preamble_varsObject (readonly)

Returns the value of attribute preamble_vars.



9
10
11
# File 'lib/vcloud/launcher/preamble.rb', line 9

def preamble_vars
  @preamble_vars
end

#script_pathObject (readonly)

Returns the value of attribute script_path.



9
10
11
# File 'lib/vcloud/launcher/preamble.rb', line 9

def script_path
  @script_path
end

Instance Method Details

#generateObject



29
30
31
# File 'lib/vcloud/launcher/preamble.rb', line 29

def generate
  @script_post_processor ? post_process_erb_output : interpolated_preamble
end

#interpolated_preambleObject



33
34
35
# File 'lib/vcloud/launcher/preamble.rb', line 33

def interpolated_preamble
  @interpolated_preamble = interpolate_erb_file
end