marathon-template 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/marathon-template/deploy.rb +28 -24
- data/lib/marathon_template.rb +1 -2
- 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: bdd4964070763e5f45f9584f345eaa18876a94f5
|
4
|
+
data.tar.gz: 69f321dcd4e861f6b393f34637a922ce959b9066
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59bfa4c3a5c882ce24ad9531a919d4f07fc8d55dbee9e3e68e91f85f27054b405322976586b535179f3223a979c8a768c1733f7d70b986a03812a365394a3864
|
7
|
+
data.tar.gz: 5e4d4c3d3ccbde1bb1ec70e9c0d7de49826605b16797c609dc4f6af7904d7dccf71331ed1abfa0bbf9bc3625935a8416e9657ee42b2c4ad0e3d45f676b047a9f
|
@@ -128,34 +128,38 @@ module Marathon_template
|
|
128
128
|
end
|
129
129
|
|
130
130
|
def self.get_servers(app_name)
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
131
|
+
begin
|
132
|
+
LOG.info "Getting host and port assignments for #{app_name}..."
|
133
|
+
marathon_app = "#{CONFIG[:marathon]}/v2/apps/#{app_name}"
|
134
|
+
encoded_uri = URI.encode(marathon_app.to_s)
|
135
|
+
uri = URI.parse(encoded_uri)
|
136
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
137
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
138
|
+
response = http.request(request)
|
138
139
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
# if task['ports'].length == 1
|
147
|
-
#+ LOG.info "Found host #{task['host']} and port #{task['ports']}"
|
148
|
-
# return_hash[i] = { task['host'] => task['port'] }
|
149
|
-
# return_array << "#{task['host']}:#{task['ports'][1]}"
|
150
|
-
|
151
|
-
else
|
152
|
-
if response.code == '404'
|
153
|
-
abort LOG.error "Failed connecting to #{marathon_app}, response code: #{response.code}\n Are you sure the app #{app_name} exists?"
|
140
|
+
if response.code == '200'
|
141
|
+
return_hash = Hash.new
|
142
|
+
json = JSON.parse(response.body)
|
143
|
+
tasks = json['app']['tasks']
|
144
|
+
tasks.each_with_index do |task, i|
|
145
|
+
LOG.info "Found host #{task['host']} and port #{task['ports']}"
|
146
|
+
return_hash["#{task['host']}_#{i}"] = task['ports']
|
147
|
+
# if task['ports'].length == 1
|
148
|
+
#+ LOG.info "Found host #{task['host']} and port #{task['ports']}"
|
149
|
+
# return_hash[i] = { task['host'] => task['port'] }
|
150
|
+
# return_array << "#{task['host']}:#{task['ports'][1]}"
|
151
|
+
end
|
154
152
|
else
|
155
|
-
|
153
|
+
if response.code == '404'
|
154
|
+
abort LOG.error "Failed connecting to #{marathon_app}, response code: #{response.code}\n Are you sure the app #{app_name} exists?"
|
155
|
+
else
|
156
|
+
abort LOG.error "Failed connecting to #{marathon_app}, response code: #{response.code}"
|
157
|
+
end
|
156
158
|
end
|
159
|
+
return_hash
|
160
|
+
rescue Exception => e
|
161
|
+
e.message
|
157
162
|
end
|
158
|
-
return_hash
|
159
163
|
end
|
160
164
|
|
161
165
|
def self.test_haproxy_dir
|
data/lib/marathon_template.rb
CHANGED