def self.auto_vagrant_configuration
if find_vagrantfile
vagrant_list = `vagrant status`
list_of_vms = []
if vagrant_list != ''
vagrant_list.each_line do |line|
if match = /([\w-]+[\s]+)(created|aborted|not created|poweroff|running|saved)[\s](\(virtualbox\)|\(vmware\)|\(vmware_fusion\)|\(libvirt\))/.match(line)
list_of_vms << match[1].strip!
end
end
if list_of_vms.length == 1
@hostname = list_of_vms[0]
else
list_of_vms.each_with_index { |vm, index | puts "#{index}) #{vm}\n" }
print 'Choose a VM from the Vagrantfile: '
chosen_vm = $stdin.gets.chomp
@hostname = list_of_vms[chosen_vm.to_i]
end
else
$stderr.puts 'Vagrant status error - Check your Vagrantfile or .vagrant'
exit 1
end
else
$stderr.puts 'Vagrantfile not found in directory!'
exit 1
end
end