vmfloaty 0.2.16 → 0.2.17

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1a1ad61f6bedb9c15e1b21bc4f2dd15318cf9303
4
- data.tar.gz: ab8a768ccf3e445dec61240b1e03ea50f2f14958
3
+ metadata.gz: b8849ed21080f1589fd4f70e59c9f1ce14fcf914
4
+ data.tar.gz: 5db00fc0a141cab894f92322a271fe6245774264
5
5
  SHA512:
6
- metadata.gz: 5ed7675e01385ec0b5d1339fc5a5d3392ef28b5eae58ebd8cc26f9f4956e2679d0fc9af3267f58482cbf6b92acd5ecc1d0db8d1441e85be1141037fe9d23e0f3
7
- data.tar.gz: 2bbbc795099999f7c0a076d748f42f7f757842822f15a7217892dbe68e2046fbb7847c79a9f62470498783042d915d92839c7801130af0914903835c0dd96cc2
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 3 vms', 'floaty get centos=3 debian --user brian --url http://vmpooler.example.com'
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
- os_list = Pooler.list(verbose, url, filter)
83
- puts os_list
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]")
@@ -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
- puts "- #{vm}"
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
@@ -1,6 +1,6 @@
1
1
 
2
2
  class Version
3
- @version = '0.2.16'
3
+ @version = '0.2.17'
4
4
 
5
5
  def self.get
6
6
  @version
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vmfloaty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.16
4
+ version: 0.2.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Cain