Class: Vcloud::DiskLauncher::DiskLaunch

Inherits:
Object
  • Object
show all
Defined in:
lib/vcloud/disk_launcher/disk_launch.rb

Instance Method Summary collapse

Constructor Details

#initializevoid

Initializes instance variables.



8
9
10
# File 'lib/vcloud/disk_launcher/disk_launch.rb', line 8

def initialize
  @config_loader = Vcloud::Core::ConfigLoader.new
end

Instance Method Details

#run(config_file = nil) ⇒ void

This method returns an undefined value.

Parses a configuration file and provisions the networks it defines.

Parameters:

  • config_file (String) (defaults to: nil)

    Path to a YAML or JSON-formatted configuration file



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/vcloud/disk_launcher/disk_launch.rb', line 16

def run(config_file = nil)
  config = @config_loader.load_config(config_file, Vcloud::DiskLauncher::Schema::DISK_LAUNCH)

  config[:independent_disks].each do |disk_config|
    name = disk_config[:name]
    vdc_name = disk_config[:vdc_name]
    size = disk_config[:size]
    begin
      disk = Vcloud::Core::IndependentDisk.create(
        Vcloud::Core::Vdc.get_by_name(vdc_name),
        name,
        size
      )
    rescue Vcloud::Core::IndependentDisk::DiskAlreadyExistsException
      Vcloud::Core.logger.info(
        "Disk '#{name}' already exists in vDC '#{vdc_name}'. Skipping"
      )
      next
    end
    Vcloud::Core.logger.info(
      "Created disk '#{name}' in vDC #{vdc_name} successfully. (id: #{disk.id})"
    )
  end

end