prism-marauder 0.6.5 → 0.6.6

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: 0e46a680ca8d16f3f1bdf889ba47d71ec61d5ac4
4
- data.tar.gz: 2dcf7840b6e84148661daf0933b43b76599ef989
3
+ metadata.gz: 7869e99e97739e5880b4bf696ee9c7ff564cd2a6
4
+ data.tar.gz: e904f328a3e474b89fee76be642792cc72dd615f
5
5
  SHA512:
6
- metadata.gz: 4572a2af3815683434558fd4461fa43007e5e68ad7de94246db56d7f0074e74dbbbd28cb30e02c948243a2111ac5eace3be65ab1c7a3ca5f2f5728d666bdc261
7
- data.tar.gz: 8fc35c8ae3c68871bd019bc9016098bd31c1b8707441fc2b56dcde3e79764f29a7b70168b48d8970bb6bc53237baddaedc01e5607154e4969207faefdb38cab7
6
+ metadata.gz: 3ef0e8d6f90b82e25f5fe0aa166e59006bd71aa2d31d76b5cfca9f9a0e5977b5a6bf3e17489c79fbce495c457d517230e0a7ec254220d14f68e0316c45fe6ba8
7
+ data.tar.gz: 5cd43337f31e4ee96e42e3e18f76143cb1fb1211730a9011d2bbc917abce587022ee85b7861838eadd62a9579a95107cc4ebb40202d2892dda60e65246b38848
@@ -118,20 +118,34 @@ def user_for_host(hostname)
118
118
  Net::SSH.configuration_for(hostname)[:user]
119
119
  end
120
120
 
121
- def display_results(matching, short, noun)
121
+ def get_field_rec(object, fieldList)
122
+ if !object || fieldList.empty?
123
+ object
124
+ else
125
+ get_field_rec(object[fieldList[0]], fieldList.drop(1))
126
+ end
127
+ end
128
+
129
+ def get_field(object, field)
130
+ get_field_rec(object, field.split('.'))
131
+ end
132
+
133
+ def display_results(matching, options, noun)
122
134
  if matching.empty?
123
135
  STDERR.puts "No #{noun} found"
136
+ else
137
+ STDERR.puts "#{matching.length} results"
138
+ field_name = options.field || 'dnsName'
139
+ if options.short
140
+ matching.map { |host| get_field(host, field_name) }.compact.each{ |value| puts value }
124
141
  else
125
- if short
126
- matching.each { |host| puts host['dnsName'] }
127
- else
128
- puts table(matching.map { |host|
129
- app = host['app'].join(',')
130
- app = host['mainclasses'].join(',') if app.length == 0
131
- [host['stage'], host['stack'], app, host['dnsName'], host['createdAt']]
132
- })
133
- end
142
+ puts table(matching.map { |host|
143
+ app = host['app'].join(',')
144
+ app = host['mainclasses'].join(',') if app.length == 0
145
+ [host['stage'], host['stack'], app, get_field(host, field_name), host['createdAt']]
146
+ })
134
147
  end
148
+ end
135
149
  end
136
150
 
137
151
  ###### COMMANDS ######
@@ -140,8 +154,9 @@ command :hosts do |c|
140
154
  c.description = 'List all hosts (hardware or instances) that match the search filter'
141
155
  c.syntax = 'marauder hosts <filter>'
142
156
  c.option '-s', '--short', 'Only return hostnames'
157
+ c.option '-f', '--field STRING', String, 'Use specified field from prism'
143
158
  c.action do |args, options|
144
- display_results(find_hosts(args), options.short, 'hosts')
159
+ display_results(find_hosts(args), options, 'hosts')
145
160
  end
146
161
  end
147
162
 
@@ -149,8 +164,9 @@ command :instances do |c|
149
164
  c.description = 'List instances that match the search filter'
150
165
  c.syntax = 'marauder instances <filter>'
151
166
  c.option '-s', '--short', 'Only return hostnames'
167
+ c.option '-f', '--field STRING', String, 'Use specified field from prism'
152
168
  c.action do |args, options|
153
- display_results(find_instances(args), options.short, 'instances')
169
+ display_results(find_instances(args), options, 'instances')
154
170
  end
155
171
  end
156
172
 
@@ -158,8 +174,9 @@ command :hardware do |c|
158
174
  c.description = 'List hardware that matches the search filter'
159
175
  c.syntax = 'marauder hardware <filter>'
160
176
  c.option '-s', '--short', 'Only return hostnames'
177
+ c.option '-f', '--field STRING', String, 'Use specified field from prism'
161
178
  c.action do |args, options|
162
- display_results(find_hardware(args), options.short, 'hardware')
179
+ display_results(find_hardware(args), options, 'hardware')
163
180
  end
164
181
  end
165
182
 
@@ -1,3 +1,3 @@
1
1
  class Marauder
2
- VERSION="0.6.5"
2
+ VERSION="0.6.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prism-marauder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.5
4
+ version: 0.6.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sébastien Cevey