Class: Vagrant::Persist::Provisioner
- Inherits:
-
Object
- Object
- Vagrant::Persist::Provisioner
- Defined in:
- lib/vagrant/persist/provisioner.rb
Instance Attribute Summary collapse
-
#new_disk ⇒ Object
readonly
Returns the value of attribute new_disk.
Instance Method Summary collapse
Instance Attribute Details
#new_disk ⇒ Object (readonly)
Returns the value of attribute new_disk.
5 6 7 |
# File 'lib/vagrant/persist/provisioner.rb', line 5 def new_disk @new_disk end |
Instance Method Details
#cleanup ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/vagrant/persist/provisioner.rb', line 38 def cleanup puts 'persist --> cleanup' puts 'persist --> detaching storage' machine.communicate.execute 'sudo umount /dev/sdb || true' puts `VBoxManage storageattach #{machine.id} --storagectl SATAController --port 1 --device 0 --type hdd --medium none` puts 'persist <--' end |
#configure(root_config) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/vagrant/persist/provisioner.rb', line 7 def configure(root_config) puts 'persist --> configure' if File.exists? config.path puts "persist --> #{config.path} found." else puts "persist --> #{config.path} does not exist, creating..." puts `VBoxManage createmedium disk --filename #{config.path} --format VDI --size #{config.size * 1024}` @new_disk = true end puts `VBoxManage storagectl #{machine.id} --name SATAController --portcount 2` puts 'persist <--' end |
#provision ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/vagrant/persist/provisioner.rb', line 20 def provision puts 'persist --> provision' puts 'persist --> attaching storage' puts `VBoxManage storageattach #{machine.id} --storagectl SATAController --port 1 --device 0 --type hdd --medium #{config.path}` sleep 1 if new_disk puts 'persist --> new disk, formatting...' machine.communicate.execute 'echo y | sudo mkfs.ext4 /dev/sdb' end puts 'persist --> mounting...' machine.communicate.execute "sudo mkdir #{config.mount}" machine.communicate.execute "sudo mount /dev/sdb #{config.mount}" if new_disk && config.user machine.communicate.execute "sudo chown #{config.user} #{config.mount}" end puts 'persist <--' end |