@@ -22,7 +22,7 @@ def run
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 @@ def run
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 @@ def run
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]" )
0 commit comments