Class: Vagrant::Disksize::Action::ResizeDisk

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant/disksize/actions.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ ResizeDisk

NOTE - size is represented in MB throughout this class, for ease of using with VirtualBox



9
10
11
12
13
14
15
16
17
# File 'lib/vagrant/disksize/actions.rb', line 9

def initialize(app, env)
  @app = app
  @machine = env[:machine]
  @enabled = true
  if @machine.provider.to_s !~ /VirtualBox/
    @enabled = false
    env[:ui].error "The vagrant-disksize plugin only supports VirtualBox at present. Disk size will not be changed."
  end
end

Instance Method Details

#call(env) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/vagrant/disksize/actions.rb', line 19

def call(env)
  # Resize disk itself before boot
  if @enabled
    requested_size = @machine.config.disksize.size
    if requested_size
      ensure_disk_resizable(env)
      resize_disk(env, requested_size)
    end
  end

  # Allow middleware chain to continue so VM is booted
  @app.call(env)

  # TODO Possibly resize partition and filesystem here if needed
end