Skip to content

Instantly share code, notes, and snippets.

@petems
Created July 3, 2013 10:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save petems/5916844 to your computer and use it in GitHub Desktop.
Save petems/5916844 to your computer and use it in GitHub Desktop.
Get all VM's from Vagrantfile
if File.exists?("Vagrantfile")
vagrant_status = `vagrant status`
if vagrant_status != ''
vagrant_status.each_line do |line|
if match = /([a-z]+[\s]+)(created|not created|poweroff|running|saved)[\s](\(virtualbox\)|\(vmware\))/.match(line)
puts match[1].strip!
end
end
else
$stderr.puts "Vagrant status error - Check your Vagrantfile or .vagrant folder"
exit 1
end
else
$stderr.puts "Vagrantfile not found in directory!"
exit 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment