Created
March 20, 2013 15:48
-
-
Save melan/5205776 to your computer and use it in GitHub Desktop.
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
def add_info(inventory) | |
inventory.each do |vmconfig| | |
if vmconfig.running? | |
vmconfig.ip_address = ip_address(vmconfig.path) | |
end | |
guestOS = runtimeConfig(vmconfig.path, 'guestOS') | |
if not guestOS.nil? | |
vmconfig.os = guestOS | |
vmconfig.icon = icon_name(vmconfig.os) | |
end | |
end | |
inventory | |
end | |
def runtimeConfig(path, var) | |
if File.exists?(path) | |
contents = File.open(path, "rb").each_line do |line| | |
parts = line.split("=") | |
if parts.length == 2 | |
lhs = parts[0].strip | |
rhs = parts[1].strip | |
if lhs == var | |
return remove_quotations(rhs) | |
end | |
end | |
end | |
end | |
nil | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment