Class: Orch::Bamboo
- Inherits:
-
Object
- Object
- Orch::Bamboo
- Defined in:
- lib/bamboo.rb
Instance Method Summary collapse
- #delete(url_list, app_id) ⇒ Object
- #deploy(url_list, app_id, bamboo_spec) ⇒ Object
-
#initialize(options) ⇒ Bamboo
constructor
A new instance of Bamboo.
- #verify(url_list, app_id, spec) ⇒ Object
Constructor Details
#initialize(options) ⇒ Bamboo
Returns a new instance of Bamboo.
16 17 |
# File 'lib/bamboo.rb', line 16 def initialize() end |
Instance Method Details
#delete(url_list, app_id) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/bamboo.rb', line 42 def delete(url_list, app_id) if url_list.nil? exit_with_msg "bamboo_url not defined" end response = http_delete(url_list, "/api/services/#{app_id}", JSON_HEADERS) if response.code != 200.to_s puts "Response #{response.code} #{response.}: #{response.body}" end return response end |
#deploy(url_list, app_id, bamboo_spec) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/bamboo.rb', line 19 def deploy(url_list, app_id, bamboo_spec) if url_list.nil? exit_with_msg "bamboo_url not defined" end # Create the real json bamboo_json = {} bamboo_json["id"] = (app_id[0] == '/') ? app_id : ("/" + app_id) bamboo_json["acl"] = bamboo_spec["acl"] # curl -i -X PUT -d '{"id":"/ExampleAppGroup/app1", "acl":"path_beg -i /group/app-1"}' http://localhost:8000/api/services//ExampleAppGroup/app1 # {"/adam-web-dev":{"Id":"/adam-web-dev","Acl":"hdr(host) -i adam-web-dev.ypec.int.yp.com" response = http_put(url_list, "/api/services/#{app_id}", bamboo_json.to_json, JSON_HEADERS) if response.code == 200.to_s puts "successfully created bamboo spec for marathon job: #{app_id}" else puts "Response #{response.code} #{response.}: #{response.body}" end return response end |
#verify(url_list, app_id, spec) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/bamboo.rb', line 56 def verify(url_list, app_id, spec) if url_list.nil? puts "no bamboo_url - can not verify with server" return end # TODO: will this work or do I need to parse through all services like chronos response = http_get(url_list, "/api/services", JSON_HEADERS) if response.code != 200.to_s puts "Response #{response.code} #{response.}: #{response.body}" foundDiffs = true end allJobs = Hashie::Mash.new(JSON.parse(response.body)) # Bamboo api only returns all items jobFound = false allJobs.each do |key, job| if key == app_id jobFound = true # Bamboo returns keys with different case then you send them! # Right now the only field to compar is Acl so we only check it by hand if spec["acl"] != job["Acl"] printf "difference for field: acl\n" printf " spec: #{spec["acl"]}\n" printf " server: #{job["Acl"]}\n" foundDiffs = true end end end if !jobFound puts "bamboo spec for marathon job \"#{app_id}\" not currently deployed" foundDiffs = true end # TODO: handle error codes better? return foundDiffs end |