Created
March 3, 2015 22:28
-
-
Save dpb587/aa09f87fa2ce16ee37c0 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
#!/usr/bin/env ruby | |
require 'yaml' | |
lastvm = nil | |
vms = {} | |
vmsraw = `cd #{ARGV[0]} && bosh vms #{ARGV[1]}` | |
vmsraw.scan(/^\|\s([^\|]+)\s+\|\s([^\|]+)\s+\|\s([^\|]+)\s+\|\s([^\|]+)\s+\|$/) do | match | | |
thisvm = match[0].strip | |
if '' == thisvm then | |
vms[lastvm][:ip] = match[3].strip | |
else | |
vms[thisvm] = { | |
:pool => match[2].strip, | |
:ip => match[3].strip, | |
} | |
lastvm = thisvm | |
end | |
end | |
manifest = `cd #{ARGV[0]} && bosh download manifest #{ARGV[1]}` | |
puts '<project>' | |
manifest['jobs'].each do | job | | |
jobtemplates = job['templates'].map do | template | | |
template['name'] | |
end | |
for index in 0..(job['instances'] - 1) | |
name = "#{job['name']}/#{index}" | |
puts " <node name=\"#{name}\" hostname=\"#{vms[name][:ip]}\" username=\"vcap\" tags=\"#{jobtemplates.join(', ')}\">" | |
#puts " <attribute name=\"sudo-command-enabled\" value=\"true\"/>" | |
#puts " <attribute name=\"sudo-password-option\" value=\"option.sshKeyPassphrase\"/>" | |
puts " <attribute name=\"bosh:resource-pool\" value=\"#{vms[name][:pool]}\"/>" | |
puts " </node>" | |
end | |
end | |
puts "</project>" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment