Class: Vagrant::ShowInfo::Command
- Inherits:
-
Object
- Object
- Vagrant::ShowInfo::Command
- Defined in:
- lib/vagrant-commit/command.rb
Instance Method Summary collapse
Instance Method Details
#execute ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/vagrant-commit/command.rb', line 83 def execute machines = {} with_target_vms() do |machine| machine_name = machine.name.to_s machines[machine_name] = get_machine_info(machine) end if machines.length == 1 answer = machines.values[0] else answer = machines end answer = JSON.pretty_generate(answer) @env.ui.info(answer) end |
#get_machine_info(machine) ⇒ Object
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/vagrant-commit/command.rb', line 72 def get_machine_info(machine) collection = Vagrant::BoxCollection.new(@env.boxes_path) machine_name = machine.name.to_s box = collection.find(machine_name, :libvirt, "> 0") { data_dir: machine.data_dir, boxes_path: @env.boxes_path, # volumes: get_volumes(machine), } end |
#get_volumes(machine) ⇒ Object
65 66 67 68 69 70 |
# File 'lib/vagrant-commit/command.rb', line 65 def get_volumes(machine) server = machine.provider.driver.connection.servers.get(machine.id.to_s) server.volumes.map do |vol| `sudo qemu-img info #{vol.path} --force | grep 'backing file:' | cut -d ':' -f2`.chomp end end |