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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1e29c955ccac0d990fe433cc84608b6f31523a36
4
- data.tar.gz: f577be40ab909f87099ae0f9dbfddd81ec557bff
3
+ metadata.gz: bdd4964070763e5f45f9584f345eaa18876a94f5
4
+ data.tar.gz: 69f321dcd4e861f6b393f34637a922ce959b9066
5
5
  SHA512:
6
- metadata.gz: cf3c95ba818005ead994c87a6868b372cecb3d89561e965e472e7903cb26ca464feb6f2145a803333f57fbc817601b2a042888c66fbd25af9a365c3620ecf273
7
- data.tar.gz: ceb3beca0075f8c45da804ce0a434871f0d2b5fed6cf8ef21f6967e51d3284b19b5d7182c847dfe5adf31857bd6be4a6692153a83418eea3f87578559a4f134f
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
- LOG.info "Getting host and port assignments for #{app_name}..."
132
- marathon_app = "#{CONFIG[:marathon]}/v2/apps/#{app_name}"
133
- encoded_uri = URI.encode(marathon_app.to_s)
134
- uri = URI.parse(encoded_uri)
135
- http = Net::HTTP.new(uri.host, uri.port)
136
- request = Net::HTTP::Get.new(uri.request_uri)
137
- response = http.request(request)
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
- if response.code == '200'
140
- return_hash = Hash.new
141
- json = JSON.parse(response.body)
142
- tasks = json['app']['tasks']
143
- tasks.each_with_index do |task, i|
144
- LOG.info "Found host #{task['host']} and port #{task['ports']}"
145
- return_hash["#{task['host']}_#{i}"] = task['ports']
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
- end
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
- abort LOG.error "Failed connecting to #{marathon_app}, response code: #{response.code}"
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
@@ -41,7 +41,6 @@ module Marathon_template
41
41
  Marathon_template::Cron.add
42
42
 
43
43
  rescue Exception => e
44
- puts e.backtrace
45
- puts e.message
44
+ puts "marathon-template failed to execute."
46
45
  end
47
46
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: marathon-template
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Malnick