Class: Vagrant::Action::Builtin::Disk
- Inherits:
-
Object
- Object
- Vagrant::Action::Builtin::Disk
- Defined in:
- lib/vagrant/action/builtin/disk.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
- #get_disks(machine, env) ⇒ Object
-
#initialize(app, env) ⇒ Disk
constructor
A new instance of Disk.
- #write_disk_metadata(machine, current_disks) ⇒ Object
Constructor Details
#initialize(app, env) ⇒ Disk
Returns a new instance of Disk.
10 11 12 13 |
# File 'lib/vagrant/action/builtin/disk.rb', line 10 def initialize(app, env) @app = app @logger = Log4r::Logger.new("vagrant::action::builtin::disk") end |
Instance Method Details
#call(env) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/vagrant/action/builtin/disk.rb', line 15 def call(env) machine = env[:machine] defined_disks = get_disks(machine, env) # Call into providers machine implementation for disk management configured_disks = {} if !defined_disks.empty? if machine.provider.capability?(:configure_disks) configured_disks = machine.provider.capability(:configure_disks, defined_disks) else env[:ui].warn(I18n.t("vagrant.actions.disk.provider_unsupported", provider: machine.provider_name)) end end (machine, configured_disks) unless configured_disks.empty? # Continue On @app.call(env) end |
#get_disks(machine, env) ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/vagrant/action/builtin/disk.rb', line 44 def get_disks(machine, env) return @_disks if @_disks @_disks = [] @_disks = machine.config.vm.disks @_disks end |
#write_disk_metadata(machine, current_disks) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/vagrant/action/builtin/disk.rb', line 36 def (machine, current_disks) = machine.data_dir.join("disk_meta") @logger.debug("Writing disk metadata file to #{}") File.open(.to_s, "w+") do |file| file.write(JSON.dump(current_disks)) end end |