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 +4 -4
- data/lib/marauder/commands.rb +30 -13
- data/lib/marauder/marauder.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: 7869e99e97739e5880b4bf696ee9c7ff564cd2a6
|
4
|
+
data.tar.gz: e904f328a3e474b89fee76be642792cc72dd615f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ef0e8d6f90b82e25f5fe0aa166e59006bd71aa2d31d76b5cfca9f9a0e5977b5a6bf3e17489c79fbce495c457d517230e0a7ec254220d14f68e0316c45fe6ba8
|
7
|
+
data.tar.gz: 5cd43337f31e4ee96e42e3e18f76143cb1fb1211730a9011d2bbc917abce587022ee85b7861838eadd62a9579a95107cc4ebb40202d2892dda60e65246b38848
|
data/lib/marauder/commands.rb
CHANGED
@@ -118,20 +118,34 @@ def user_for_host(hostname)
|
|
118
118
|
Net::SSH.configuration_for(hostname)[:user]
|
119
119
|
end
|
120
120
|
|
121
|
-
def
|
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
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
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
|
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
|
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
|
179
|
+
display_results(find_hardware(args), options, 'hardware')
|
163
180
|
end
|
164
181
|
end
|
165
182
|
|
data/lib/marauder/marauder.rb
CHANGED