Created
July 3, 2013 10:14
-
-
Save petems/5916844 to your computer and use it in GitHub Desktop.
Get all VM's from Vagrantfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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