mirror of
https://github.com/puppetlabs/vmfloaty.git
synced 2026-01-26 05:28:40 -05:00
Simplify how floaty gets vms
Instead of building a json hash for each requested vm, sub the host strings commas with + and append it to the request url.
This commit is contained in:
parent
7fb07a9a69
commit
9fc9820120
2 changed files with 15 additions and 14 deletions
|
|
@ -19,22 +19,15 @@ class Pooler
|
|||
end
|
||||
|
||||
def self.retrieve(verbose, os_type, token, url)
|
||||
os = os_type.split(',')
|
||||
conn = Http.get_conn_with_token(verbose, url, token)
|
||||
os_body = {}
|
||||
|
||||
os.each do |os_type|
|
||||
unless os_body.has_key?(os_type)
|
||||
os_body[os_type] = 1
|
||||
else
|
||||
os_body[os_type] += 1
|
||||
end
|
||||
os = os_type.gsub(',','+')
|
||||
if token.nil?
|
||||
conn = Http.get_conn(verbose, url)
|
||||
else
|
||||
conn = Http.get_conn_with_token(verbose, url, token)
|
||||
conn.headers['X-AUTH-TOKEN']
|
||||
end
|
||||
|
||||
response = conn.post do |req|
|
||||
req.url '/vm'
|
||||
req.body = os_body
|
||||
end
|
||||
response = conn.post "/vm/#{os}"
|
||||
|
||||
res_body = JSON.parse(response.body)
|
||||
res_body
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue