mirror of
https://github.com/puppetlabs/vmfloaty.git
synced 2026-01-26 05:28:40 -05:00
Set vmpooler and list vm results
This commit is contained in:
parent
cafe3ee005
commit
b9c43f9695
2 changed files with 13 additions and 4 deletions
|
|
@ -5,10 +5,10 @@ require 'vmfloaty/hosts'
|
|||
class Vmfloaty
|
||||
|
||||
def initialize(env)
|
||||
@vmpooler_url = env['VMPOOLER_URL']
|
||||
$vmpooler_url = env['VMPOOLER_URL']
|
||||
|
||||
unless @vmpooler_url
|
||||
@vmpooler_url = 'http://vcloud.delivery.puppetlabs.net/vm'
|
||||
$vmpooler_url = 'http://vcloud.delivery.puppetlabs.net'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue