mirror of
https://github.com/puppetlabs/vmfloaty.git
synced 2026-01-26 13:28:42 -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
|
class Vmfloaty
|
||||||
|
|
||||||
def initialize(env)
|
def initialize(env)
|
||||||
@vmpooler_url = env['VMPOOLER_URL']
|
$vmpooler_url = env['VMPOOLER_URL']
|
||||||
|
|
||||||
unless @vmpooler_url
|
unless @vmpooler_url
|
||||||
@vmpooler_url = 'http://vcloud.delivery.puppetlabs.net/vm'
|
$vmpooler_url = 'http://vcloud.delivery.puppetlabs.net'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,14 @@
|
||||||
require 'thor'
|
require 'thor'
|
||||||
require 'net/http'
|
require 'net/http'
|
||||||
|
require 'uri'
|
||||||
|
require 'json'
|
||||||
|
|
||||||
class CLI < Thor
|
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
|
# POST -d os_list vmpooler.company.com/vm
|
||||||
|
|
||||||
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
|
||||||
|
|
@ -26,11 +29,17 @@ class CLI < Thor
|
||||||
desc "list [PATTERN]", "List all open VMs"
|
desc "list [PATTERN]", "List all open VMs"
|
||||||
def list(pattern=nil)
|
def list(pattern=nil)
|
||||||
# HTTP GET vmpooler.company.com/vm
|
# 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
|
if pattern
|
||||||
say "Filtering VMs based on #{pattern}"
|
# Filtering VMs based on pattern
|
||||||
else
|
else
|
||||||
say 'Listing open vms on vmpooler'
|
# list all vms
|
||||||
end
|
end
|
||||||
|
|
||||||
|
puts host_res
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "release <HOSTNAME>", "Schedules a VM for deletion"
|
desc "release <HOSTNAME>", "Schedules a VM for deletion"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue