Set vmpooler and list vm results

This commit is contained in:
Brian Cain 2014-10-29 11:43:53 -07:00
parent cafe3ee005
commit b9c43f9695
2 changed files with 13 additions and 4 deletions

View file

@ -1,11 +1,14 @@
require 'thor'
require 'net/http'
require 'uri'
require 'json'
class CLI < Thor
desc "get <OPERATING SYSTEM,...> [--withpe version]", "Gets a VM"
option :withpe
def get(os_list)
# POST -d os_list vmpooler.company.com/vm
if options[:withpe]
say "Get a #{os_list} VM here and provision with PE verison #{options[:withpe]}"
else
@ -26,11 +29,17 @@ class CLI < Thor
desc "list [PATTERN]", "List all open VMs"
def list(pattern=nil)
# HTTP GET vmpooler.company.com/vm
uri = URI.parse("#{$vmpooler_url}/vm")
response = Net::HTTP.get_response(uri)
host_res = JSON.parse(response.body)
if pattern
say "Filtering VMs based on #{pattern}"
# Filtering VMs based on pattern
else
say 'Listing open vms on vmpooler'
# list all vms
end
puts host_res
end
desc "release <HOSTNAME>", "Schedules a VM for deletion"