mirror of
https://github.com/puppetlabs/vmfloaty.git
synced 2026-01-26 05:28:40 -05:00
Add get and release to cli
This commit is contained in:
parent
85d5eda24b
commit
65f93cb519
1 changed files with 27 additions and 6 deletions
|
|
@ -7,12 +7,21 @@ class CLI < Thor
|
||||||
desc "get <OPERATING SYSTEM,...> [--withpe version]", "Gets a VM"
|
desc "get <OPERATING SYSTEM,...> [--withpe version]", "Gets a VM"
|
||||||
option :withpe
|
option :withpe
|
||||||
def get(os_list)
|
def get(os_list)
|
||||||
# POST -d os_list vmpooler.company.com/vm
|
# HTTP POST -d os_list vmpooler.company.com/vm
|
||||||
|
|
||||||
|
uri = URI.parse("#{$vmpooler_url}/vm/#{os_list.gsub(",","+")}")
|
||||||
|
http = Net::HTTP.new(uri.host, uri.port)
|
||||||
|
request = Net::HTTP::Post.new(uri.request_uri)
|
||||||
|
response = http.request(request)
|
||||||
|
|
||||||
|
host_res = JSON.parse(response.body)
|
||||||
|
|
||||||
|
puts host_res
|
||||||
|
|
||||||
if options[:withpe]
|
if options[:withpe]
|
||||||
say "Get a #{os_list} VM here and provision with PE verison #{options[:withpe]}"
|
# say "Get a #{os_list} VM here and provision with PE verison #{options[:withpe]}"
|
||||||
else
|
else
|
||||||
say "Get a #{os_list} VM here"
|
# ?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -43,10 +52,22 @@ class CLI < Thor
|
||||||
puts hosts
|
puts hosts
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "release <HOSTNAME>", "Schedules a VM for deletion"
|
desc "release [HOSTNAME,...]", "Schedules a VM for deletion"
|
||||||
def release(hostname)
|
def release(hostname_list)
|
||||||
# HTTP DELETE vmpooler.company.com/vm/#{hostname}
|
# HTTP DELETE vmpooler.company.com/vm/#{hostname}
|
||||||
# { "ok": true }
|
# { "ok": true }
|
||||||
say 'Releases a VM'
|
|
||||||
|
hostname_arr = hostname_list.split(',')
|
||||||
|
|
||||||
|
hostname_arr.each do |hostname|
|
||||||
|
say "Releasing host #{hostname}..."
|
||||||
|
uri = URI.parse("#{$vmpooler_url}/vm/#{hostname}")
|
||||||
|
http = Net::HTTP.new(uri.host, uri.port)
|
||||||
|
request = Net::HTTP::Delete.new(uri.request_uri)
|
||||||
|
response = http.request(request)
|
||||||
|
res = JSON.parse(response.body)
|
||||||
|
|
||||||
|
puts res
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue