vmfloaty 0.2.16 → 0.2.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/vmfloaty.rb +26 -4
- data/lib/vmfloaty/utils.rb +10 -2
- data/lib/vmfloaty/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8849ed21080f1589fd4f70e59c9f1ce14fcf914
|
4
|
+
data.tar.gz: 5db00fc0a141cab894f92322a271fe6245774264
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5048f063419586c37e31a41bc2b1a747afc0e42125c9ddcd2abacb8eaeb2e01a7b9efa6ba672bb6591f3f740712d2c32a938cd4afa57c47166202486e43b3b1
|
7
|
+
data.tar.gz: 2a0bdc61b773e2d3797defe336dda52f0f42c7e949c80c89a8ff2c51691f50351d9a713ac909ad3f6ed00b5a7eea329c6bcf65b2470602252875a1aa8b870243
|
data/lib/vmfloaty.rb
CHANGED
@@ -22,7 +22,7 @@ class Vmfloaty
|
|
22
22
|
c.syntax = 'floaty get os_type1=x ox_type2=y ...'
|
23
23
|
c.summary = 'Gets a vm or vms based on the os flag'
|
24
24
|
c.description = ''
|
25
|
-
c.example 'Gets
|
25
|
+
c.example 'Gets a few vms', 'floaty get centos=3 debian --user brian --url http://vmpooler.example.com'
|
26
26
|
c.option '--verbose', 'Enables verbose output'
|
27
27
|
c.option '--user STRING', String, 'User to authenticate with'
|
28
28
|
c.option '--url STRING', String, 'URL of vmpooler'
|
@@ -73,14 +73,36 @@ class Vmfloaty
|
|
73
73
|
c.description = ''
|
74
74
|
c.example 'Filter the list on centos', 'floaty list centos --url http://vmpooler.example.com'
|
75
75
|
c.option '--verbose', 'Enables verbose output'
|
76
|
+
c.option '--active', 'Prints information about active vms for a given token'
|
77
|
+
c.option '--token STRING', String, 'Token for vmpooler'
|
76
78
|
c.option '--url STRING', String, 'URL of vmpooler'
|
77
79
|
c.action do |args, options|
|
78
80
|
verbose = options.verbose || config['verbose']
|
79
81
|
filter = args[0]
|
80
82
|
url = options.url ||= config['url']
|
83
|
+
token = options.token || config['token']
|
84
|
+
active = options.active
|
85
|
+
|
86
|
+
if active
|
87
|
+
# list active vms
|
88
|
+
status = Auth.token_status(verbose, url, token)
|
89
|
+
# print vms
|
90
|
+
vms = status[token]['vms']
|
91
|
+
if vms.nil?
|
92
|
+
STDERR.puts "You have no running vms"
|
93
|
+
exit 0
|
94
|
+
end
|
95
|
+
|
96
|
+
running_vms = vms['running']
|
81
97
|
|
82
|
-
|
83
|
-
|
98
|
+
if ! running_vms.nil?
|
99
|
+
Utils.prettyprint_hosts(running_vms, verbose, url)
|
100
|
+
end
|
101
|
+
else
|
102
|
+
# list available vms from pooler
|
103
|
+
os_list = Pooler.list(verbose, url, filter)
|
104
|
+
puts os_list
|
105
|
+
end
|
84
106
|
end
|
85
107
|
end
|
86
108
|
|
@@ -159,7 +181,7 @@ class Vmfloaty
|
|
159
181
|
running_vms = vms['running']
|
160
182
|
|
161
183
|
if ! running_vms.nil?
|
162
|
-
Utils.prettyprint_hosts(running_vms)
|
184
|
+
Utils.prettyprint_hosts(running_vms, verbose, url)
|
163
185
|
# query y/n
|
164
186
|
puts ""
|
165
187
|
ans = agree("Delete all VMs associated with token #{token}? [y/N]")
|
data/lib/vmfloaty/utils.rb
CHANGED
@@ -41,10 +41,18 @@ class Utils
|
|
41
41
|
os_types
|
42
42
|
end
|
43
43
|
|
44
|
-
def self.prettyprint_hosts(hosts)
|
44
|
+
def self.prettyprint_hosts(hosts, verbose, url)
|
45
45
|
puts "Running VMs:"
|
46
46
|
hosts.each do |vm|
|
47
|
-
|
47
|
+
vm_info = Pooler.query(verbose, url, vm)
|
48
|
+
if vm_info['ok']
|
49
|
+
domain = vm_info[vm]['domain']
|
50
|
+
template = vm_info[vm]['template']
|
51
|
+
lifetime = vm_info[vm]['lifetime']
|
52
|
+
running = vm_info[vm]['running']
|
53
|
+
|
54
|
+
puts "- #{vm}.#{domain} (#{template}, #{running}/#{lifetime} hours)"
|
55
|
+
end
|
48
56
|
end
|
49
57
|
end
|
50
58
|
end
|
data/lib/vmfloaty/version.rb
CHANGED