prism-marauder 0.6.6 → 0.7.0

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: 7869e99e97739e5880b4bf696ee9c7ff564cd2a6
4
- data.tar.gz: e904f328a3e474b89fee76be642792cc72dd615f
3
+ metadata.gz: b95788c5c1a2d58445a2380506338ee61d6e4020
4
+ data.tar.gz: 379964fcc377ca27aa91b624e792190a2de38e70
5
5
  SHA512:
6
- metadata.gz: 3ef0e8d6f90b82e25f5fe0aa166e59006bd71aa2d31d76b5cfca9f9a0e5977b5a6bf3e17489c79fbce495c457d517230e0a7ec254220d14f68e0316c45fe6ba8
7
- data.tar.gz: 5cd43337f31e4ee96e42e3e18f76143cb1fb1211730a9011d2bbc917abce587022ee85b7861838eadd62a9579a95107cc4ebb40202d2892dda60e65246b38848
6
+ metadata.gz: 6e6f87f8b3302a46163a9b015b7b8cb7b2c8c61f5601de5219965ca4334a048ae876d7c0b3f19683a6eb9e292290ba7667c60378479cca7971ebab2cd3b26521
7
+ data.tar.gz: 4ac5e4b0b9386a2af899bbdb920f0bef577ad4c4e0ce5dba9091bd6e7551c0b05f42ce90d6bf2aa3a18019760f2437029524556e0a6274f56bc4b520e43d19f7
@@ -109,9 +109,15 @@ def find_instances(filter)
109
109
  end
110
110
 
111
111
  def find_hardware(filter)
112
- data = prism_query('/hardware', filter)
113
- hardware = data["data"]["hardware"]
114
- token_filter(hardware, filter){ |h| [h["dnsName"], h["stage"], h["stack"]] + h["app"] }
112
+ begin
113
+ data = prism_query('/hardware', filter)
114
+ hardware = data["data"]["hardware"]
115
+ token_filter(hardware, filter){ |h| [h["dnsName"], h["stage"], h["stack"]] + h["app"] }
116
+ rescue StandardError => error
117
+ STDERR.puts 'WARNING: The prism server you are using no longer has the hardware endpoint - ignoring request'
118
+ # return an empty list
119
+ []
120
+ end
115
121
  end
116
122
 
117
123
  def user_for_host(hostname)
@@ -127,6 +133,13 @@ def get_field_rec(object, fieldList)
127
133
  end
128
134
 
129
135
  def get_field(object, field)
136
+ if field.nil?
137
+ if object['addresses']['public'].nil?
138
+ field = 'ip'
139
+ else
140
+ field = 'dnsName'
141
+ end
142
+ end
130
143
  get_field_rec(object, field.split('.'))
131
144
  end
132
145
 
@@ -135,7 +148,7 @@ def display_results(matching, options, noun)
135
148
  STDERR.puts "No #{noun} found"
136
149
  else
137
150
  STDERR.puts "#{matching.length} results"
138
- field_name = options.field || 'dnsName'
151
+ field_name = options.field || nil
139
152
  if options.short
140
153
  matching.map { |host| get_field(host, field_name) }.compact.each{ |value| puts value }
141
154
  else
@@ -151,7 +164,7 @@ end
151
164
  ###### COMMANDS ######
152
165
 
153
166
  command :hosts do |c|
154
- c.description = 'List all hosts (hardware or instances) that match the search filter'
167
+ c.description = 'List all hosts (hardware or instances) that match the search filter'
155
168
  c.syntax = 'marauder hosts <filter>'
156
169
  c.option '-s', '--short', 'Only return hostnames'
157
170
  c.option '-f', '--field STRING', String, 'Use specified field from prism'
@@ -168,17 +181,17 @@ command :instances do |c|
168
181
  c.action do |args, options|
169
182
  display_results(find_instances(args), options, 'instances')
170
183
  end
171
- end
184
+ end
172
185
 
173
186
  command :hardware do |c|
174
- c.description = 'List hardware that matches the search filter'
187
+ c.description = 'List hardware that matches the search filter'
175
188
  c.syntax = 'marauder hardware <filter>'
176
189
  c.option '-s', '--short', 'Only return hostnames'
177
190
  c.option '-f', '--field STRING', String, 'Use specified field from prism'
178
191
  c.action do |args, options|
179
192
  display_results(find_hardware(args), options, 'hardware')
180
193
  end
181
- end
194
+ end
182
195
 
183
196
  command :ssh do |c|
184
197
  c.syntax = 'marauder ssh <filter>'
@@ -221,4 +234,4 @@ command :ssh do |c|
221
234
  end
222
235
  end
223
236
 
224
- default_command :hosts
237
+ default_command :instances
@@ -1,3 +1,3 @@
1
1
  class Marauder
2
- VERSION="0.6.6"
2
+ VERSION="0.7.0"
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.6
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sébastien Cevey
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-05-12 00:00:00.000000000 Z
12
+ date: 2015-12-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: commander