Skip to content

Commit 678f425

Browse files
committed
state command lists
1 parent d0a4c01 commit 678f425

1 file changed

Lines changed: 18 additions & 26 deletions

File tree

app/lib/routes/services.rb

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -114,27 +114,24 @@ def inventory_hosts
114114

115115
def self.registered(app)
116116
app.get '/json/ui/state' do
117-
resp = []
118-
ui_hosts.each do |host|
119-
resp << get_url_json("#{host}/state.json")
117+
resp = ui_hosts.map do |host|
118+
get_url("#{host}/state.json")
120119
end
121120
resp = get_url("#{ui_host}/state.json") if resp.empty?
122121
resp.to_json
123122
end
124123

125124
app.get '/json/ui/audit-replic' do
126-
resp = []
127-
ui_hosts.each do |host|
128-
resp << get_url_json("#{host}/state-audit-replic.json")
125+
resp = ui_hosts.map do |host|
126+
get_url("#{host}/state-audit-replic.json")
129127
end
130128
resp = get_url("#{ui_host}/state-audit-replic.json") if resp.empty?
131129
resp.to_json
132130
end
133131

134132
app.get '/json/ingest/state' do
135-
resp = []
136-
ingest_hosts.each do |host|
137-
resp << get_url_json("#{host}/state?t=json")
133+
resp = ingest_hosts.map do |host|
134+
get_url("#{host}/state?t=json")
138135
end
139136
resp = get_url("#{ingest_host}/state?t=json") if resp.empty?
140137
resp.to_json
@@ -145,9 +142,8 @@ def self.registered(app)
145142
end
146143

147144
app.get '/json/store/state' do
148-
resp = []
149-
store_hosts.each do |host|
150-
resp << get_url_json("#{host}/state?t=json")
145+
resp = store_hosts.map do |host|
146+
get_url("#{host}/state?t=json")
151147
end
152148
resp = get_url("#{store_host}/state?t=json") if resp.empty?
153149
resp.to_json
@@ -170,9 +166,8 @@ def self.registered(app)
170166
end
171167

172168
app.get '/json/inventory/state' do
173-
resp = []
174-
inventory_hosts.each do |host|
175-
resp << get_url_json("#{host}/state?t=json")
169+
resp = inventory_hosts.map do |host|
170+
get_url("#{host}/state?t=json")
176171
end
177172
resp = get_url("#{inventory_host}/state?t=json") if resp.empty?
178173
resp.to_json
@@ -215,9 +210,8 @@ def self.registered(app)
215210
end
216211

217212
app.get '/json/audit/state' do
218-
resp = []
219-
audit_hosts.each do |host|
220-
resp << get_url_json("#{host}/state?t=json")
213+
resp = audit_hosts.map do |host|
214+
get_url("#{host}/state?t=json")
221215
end
222216
resp = get_url("#{audit_host}/state?t=json") if resp.empty?
223217
resp.to_json
@@ -261,13 +255,12 @@ def self.registered(app)
261255

262256
app.get '/json/replic/state' do
263257
# Per David, replic uses status instead of state
264-
resp = []
265-
replic_hosts.each do |host|
266-
resp << get_url_json("#{host}/status=json")
258+
resp = replic_hosts.map do |host|
259+
get_url("#{host}/status?t=json")
267260
end
268-
resp = get_url("#{replic_host}/status=json") if resp.empty?
261+
resp = get_url("#{replic_host}/status?t=json") if resp.empty?
269262
resp.to_json
270-
end
263+
end
271264

272265
app.get '/json/replic/tag' do
273266
get_url("#{replic_host}/#{BUILD_TAG_ENDPOINT}")
@@ -306,9 +299,8 @@ def self.registered(app)
306299
end
307300

308301
app.get '/json/access/state' do
309-
resp = []
310-
access_hosts.each do |host|
311-
resp << get_url_json("#{host}/state?t=json")
302+
resp = access_hosts.map do |host|
303+
get_url("#{host}/state?t=json")
312304
end
313305
resp = get_url("#{access_host}/state?t=json") if resp.empty?
314306
resp.to_json

0 commit comments

Comments
 (0)