This repository has been archived by the owner on Nov 2, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Demitri Swan
committed
Jun 12, 2015
1 parent
e75f332
commit 249444b
Showing
3 changed files
with
43 additions
and
37 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,46 @@ | ||
#!/usr/bin/env ruby | ||
|
||
module Vbinfo | ||
class Command | ||
include Vbinfo::Helpers | ||
# Helper functions | ||
module Helpers | ||
# Return an array of vm IDs for the vagrant project in the | ||
# current directory | ||
def ids | ||
i = [] | ||
Find.find("#{ENV['PWD']}/.vagrant") do |item| | ||
if File.file?(item) and File.basename(item) == 'id' | ||
id = File.open(item).read | ||
i << id | ||
end | ||
end | ||
return i | ||
end | ||
|
||
# Print detailed info for the given VM ID | ||
def get_info(id) | ||
# Fail if vboxmanage does not exist in the path | ||
check = Mixlib::ShellOut.new("which vboxmanage") | ||
check.run_command | ||
if check.stdout.empty? | ||
assert Vagrant::Errors::VagrantError::CommandUnavailable, file: 'vboxmanage' | ||
exit 1 | ||
end | ||
# Return the output | ||
output = Mixlib::ShellOut.new("vboxmanage showvminfo #{id}") | ||
output.run_command | ||
return output.stdout | ||
end | ||
end | ||
|
||
class Command | ||
include Helpers | ||
# Print detailed information for each Virtualbox VM associated with | ||
# the project in the current directory | ||
def execute | ||
ids.each do |id| | ||
get_info(id) | ||
puts "#{get_info(id).to_s}\n\n" | ||
end | ||
exit 0 | ||
end | ||
|
||
end | ||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
#!/usr/bin/env ruby | ||
|
||
module Vbinfo | ||
VERSION = "0.0.1" | ||
end |
This file contains 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