class MCG::Data
Attributes
data[R]
tasks[R]
Public Class Methods
new(marathon_url)
click to toggle source
# File lib/mcg/data.rb, line 11 def initialize(marathon_url) @marathon_url = marathon_url @data = nil @tasks = nil end
Public Instance Methods
get()
click to toggle source
# File lib/mcg/data.rb, line 17 def get uri = URI.parse(@marathon_url + '/v2/tasks') http = Net::HTTP.new(uri.host, uri.port) req = Net::HTTP::Get.new(uri.path, initheader = {'Accept' =>'application/json'}) resp = http.request(req) @data = JSON.parse(resp.body) order_task end
order_task()
click to toggle source
# File lib/mcg/data.rb, line 26 def order_task @tasks = Hash.new { |h, k| h[k] = [] } @data["tasks"].each do |task| fqdn = task["appId"][/\/([^\/]+)\//, 1] task["ports"].each do |port| @tasks[fqdn] << { :host => task["host"], :port => port } end end end