Class: EY::CloudClient::Deployment
- Inherits:
-
Object
- Object
- EY::CloudClient::Deployment
- Defined in:
- lib/engineyard-cloud-client/models/deployment.rb
Class Method Summary collapse
- .api_root(app_id, environment_id) ⇒ Object
- .deploy(api, app_environment, attrs) ⇒ Object
- .get(api, app_environment, id) ⇒ Object
- .last(api, app_environment) ⇒ Object
- .load_from_response(api, app_environment, response) ⇒ Object
Instance Method Summary collapse
- #app ⇒ Object
- #config ⇒ Object
- #created_at=(cat) ⇒ Object
-
#deploy ⇒ Object
Tell EY Cloud to deploy on our behalf.
- #environment ⇒ Object
- #err ⇒ Object
- #finished ⇒ Object
- #finished? ⇒ Boolean
- #finished_at=(fat) ⇒ Object
- #migrate ⇒ Object (also: #migrate?)
- #out ⇒ Object
- #output ⇒ Object
- #sort_attributes ⇒ Object
-
#start ⇒ Object
Tell EY Cloud that you will be starting a deploy yourself.
- #timeout ⇒ Object (also: #cancel)
- #update_with_response(response) ⇒ Object
Class Method Details
.api_root(app_id, environment_id) ⇒ Object
9 10 11 |
# File 'lib/engineyard-cloud-client/models/deployment.rb', line 9 def self.api_root(app_id, environment_id) "/apps/#{app_id}/environments/#{environment_id}/deployments" end |
.deploy(api, app_environment, attrs) ⇒ Object
31 32 33 |
# File 'lib/engineyard-cloud-client/models/deployment.rb', line 31 def self.deploy(api, app_environment, attrs) Deployment.from_hash(api, attrs.merge(:app_environment => app_environment)).deploy end |
.get(api, app_environment, id) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/engineyard-cloud-client/models/deployment.rb', line 17 def self.get(api, app_environment, id) uri = api_root(app_environment.app.id, app_environment.environment.id) + "/#{id}" response = api.get(uri) load_from_response api, app_environment, response rescue EY::CloudClient::ResourceNotFound nil end |
.last(api, app_environment) ⇒ Object
13 14 15 |
# File 'lib/engineyard-cloud-client/models/deployment.rb', line 13 def self.last(api, app_environment) get(api, app_environment, 'last') end |
.load_from_response(api, app_environment, response) ⇒ Object
25 26 27 28 29 |
# File 'lib/engineyard-cloud-client/models/deployment.rb', line 25 def self.load_from_response(api, app_environment, response) dep = from_hash(api, {:app_environment => app_environment}) dep.update_with_response(response) dep end |
Instance Method Details
#app ⇒ Object
35 36 37 |
# File 'lib/engineyard-cloud-client/models/deployment.rb', line 35 def app app_environment.app end |
#config ⇒ Object
71 72 73 74 |
# File 'lib/engineyard-cloud-client/models/deployment.rb', line 71 def config return {} unless deployed_by # not started yet so not all info is here @config ||= {'input_ref' => ref, 'deployed_by' => deployed_by}.merge(extra_config) end |
#created_at=(cat) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/engineyard-cloud-client/models/deployment.rb', line 55 def created_at=(cat) if String === cat super Time.parse(cat) else super end end |
#deploy ⇒ Object
Tell EY Cloud to deploy on our behalf.
Deploy is different from start in that it triggers the deploy remotely. This is almost exactly equivalent to pressing the deploy button on the dashboard. No output will be returned.
95 96 97 98 99 100 101 102 103 |
# File 'lib/engineyard-cloud-client/models/deployment.rb', line 95 def deploy params = { :migrate => migrate, :ref => ref, } params[:serverside_version] = serverside_version if serverside_version params[:migrate_command] = migrate_command if migrate update_with_response api.post(collection_uri + "/deploy", 'deployment' => params) end |
#environment ⇒ Object
39 40 41 |
# File 'lib/engineyard-cloud-client/models/deployment.rb', line 39 def environment app_environment.environment end |
#err ⇒ Object
113 114 115 |
# File 'lib/engineyard-cloud-client/models/deployment.rb', line 113 def err output end |
#finished ⇒ Object
117 118 119 120 |
# File 'lib/engineyard-cloud-client/models/deployment.rb', line 117 def finished output.rewind put_to_api({:successful => successful, :output => output.read}) end |
#finished? ⇒ Boolean
134 135 136 |
# File 'lib/engineyard-cloud-client/models/deployment.rb', line 134 def finished? !finished_at.nil? end |
#finished_at=(fat) ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/engineyard-cloud-client/models/deployment.rb', line 63 def finished_at=(fat) if String === fat super Time.parse(fat) else super end end |
#migrate ⇒ Object Also known as: migrate?
43 44 45 |
# File 'lib/engineyard-cloud-client/models/deployment.rb', line 43 def migrate !migrate_command.nil? && !migrate_command.to_s.empty? end |
#out ⇒ Object
109 110 111 |
# File 'lib/engineyard-cloud-client/models/deployment.rb', line 109 def out output end |
#output ⇒ Object
105 106 107 |
# File 'lib/engineyard-cloud-client/models/deployment.rb', line 105 def output @output ||= StringIO.new end |
#sort_attributes ⇒ Object
143 144 145 |
# File 'lib/engineyard-cloud-client/models/deployment.rb', line 143 def sort_attributes [created_at || finished_at || Time.now] end |
#start ⇒ Object
Tell EY Cloud that you will be starting a deploy yourself.
The name for this method isn’t great. It’s a relic of how the deploy ran before it ever told EY Cloud that is was running a deploy at all.
80 81 82 83 84 85 86 87 88 |
# File 'lib/engineyard-cloud-client/models/deployment.rb', line 80 def start params = { :migrate => migrate, :ref => ref, :serverside_version => serverside_version, } params[:migrate_command] = migrate_command if migrate post_to_api(params) end |
#timeout ⇒ Object Also known as: cancel
122 123 124 125 126 127 128 129 130 131 |
# File 'lib/engineyard-cloud-client/models/deployment.rb', line 122 def timeout if finished? raise EY::CloudClient::Error, "Previous deployment is already finished. Aborting." else current_user_name = api.current_user.name self.successful = false err << "!> Marked as timed out by #{current_user_name}" finished end end |
#update_with_response(response) ⇒ Object
138 139 140 141 |
# File 'lib/engineyard-cloud-client/models/deployment.rb', line 138 def update_with_response(response) self.attributes = response['deployment'] self end |