Module: Vagrant::Ext::Driver::DriverOverrides

Defined in:
lib/vagrant/ext/driver/driver_overrides.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/vagrant/ext/driver/driver_overrides.rb', line 5

def self.included(base)
  base.class_eval do

    # Public - Support passing in a category
    # of vms to list.
    #
    # Currently supported options:
    # vms - All vms, regardless of status
    # runningvms - Only running vms
    #
    # This method can be used to query the state of all vms.
    # In the case of https://github.com/joshmcarthur/urchin,
    # it is used to query for a list of VMs to display
    def read_vms(type = :vms)
      results = []
      execute("list", type.to_s, :retryable => true).split("\n").each do |line|
        if vm = line[/^".+?" \{(.+?)\}$/, 1]
          results << vm
        end
      end

      results
    end
  end
end