Class: VagrantPlugins::Linode::Services::VolumeManager

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-linode/services/volume_manager.rb

Instance Method Summary collapse

Constructor Details

#initialize(machine, api, logger) ⇒ VolumeManager

Returns a new instance of VolumeManager.



7
8
9
10
11
# File 'lib/vagrant-linode/services/volume_manager.rb', line 7

def initialize(machine, api, logger)
  @machine = machine
  @volumes_api = api
  @logger = logger
end

Instance Method Details

#performObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/vagrant-linode/services/volume_manager.rb', line 13

def perform
  volume_definitions.each do |volume|
    raise Errors::VolumeLabelMissing if volume[:label].to_s.empty?

    volume_name = "#{@machine.name}_#{volume[:label]}"

    remote_volume = remote_volumes.find { |v| v.label == volume_name }
    if remote_volume
      attach_volume(remote_volume)
    else
      create_and_attach_volume(volume_name, volume[:size])
    end
  end
end