Class: VagrantPlugins::Harddisk::Action::Creation

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-harddisk/action/creation.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ Creation

Returns a new instance of Creation.



5
6
7
8
# File 'lib/vagrant-harddisk/action/creation.rb', line 5

def initialize(app, env)
  @app = app
  @machine = env[:machine]
end

Instance Method Details

#call(env) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/vagrant-harddisk/action/creation.rb', line 10

def call(env)
  id = @machine.id

  disks = @machine.config.harddisk.disks
  unless disks.empty?
    disks.each do |name, disk|
      present = system("prlctl list --info #{id} | grep #{disk[:interface_type]}:#{disk[:position]} > /dev/null")
      unless present
        env[:ui].output("Installing hdd #{name}")
        system("prlctl set #{id} --device-add hdd --type expand --size #{disk[:size]} --position #{disk[:position]} --iface #{disk[:interface_type]}")
      end
    end
  end

  # Continue provisioning
  @app.call(env)
end