class EY::CloudClient::Deployment
Public Class Methods
api_root(app_id, environment_id)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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
Public Instance Methods
app()
click to toggle source
# File lib/engineyard-cloud-client/models/deployment.rb, line 35 def app app_environment.app end
config()
click to toggle source
# 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)
click to toggle source
Calls superclass method
# 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()
click to toggle source
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.
# 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()
click to toggle source
# File lib/engineyard-cloud-client/models/deployment.rb, line 39 def environment app_environment.environment end
err()
click to toggle source
# File lib/engineyard-cloud-client/models/deployment.rb, line 113 def err output end
finished()
click to toggle source
# File lib/engineyard-cloud-client/models/deployment.rb, line 117 def finished output.rewind put_to_api({:successful => successful, :output => output.read}) end
finished?()
click to toggle source
# File lib/engineyard-cloud-client/models/deployment.rb, line 134 def finished? !finished_at.nil? end
finished_at=(fat)
click to toggle source
Calls superclass method
# 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()
click to toggle source
# File lib/engineyard-cloud-client/models/deployment.rb, line 43 def migrate !migrate_command.nil? && !migrate_command.to_s.empty? end
Also aliased as: migrate?
out()
click to toggle source
# File lib/engineyard-cloud-client/models/deployment.rb, line 109 def out output end
output()
click to toggle source
# File lib/engineyard-cloud-client/models/deployment.rb, line 105 def output @output ||= StringIO.new end
sort_attributes()
click to toggle source
# File lib/engineyard-cloud-client/models/deployment.rb, line 143 def sort_attributes [created_at || finished_at || Time.now] end
start()
click to toggle source
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.
# 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()
click to toggle source
# 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
Also aliased as: cancel
update_with_response(response)
click to toggle source
# File lib/engineyard-cloud-client/models/deployment.rb, line 138 def update_with_response(response) self.attributes = response['deployment'] self end
Private Instance Methods
collection_uri()
click to toggle source
# File lib/engineyard-cloud-client/models/deployment.rb, line 157 def collection_uri self.class.api_root(app.id, environment.id) end
member_uri(path = nil)
click to toggle source
# File lib/engineyard-cloud-client/models/deployment.rb, line 161 def member_uri(path = nil) collection_uri + "/#{id}#{path}" end
post_to_api(params)
click to toggle source
# File lib/engineyard-cloud-client/models/deployment.rb, line 149 def post_to_api(params) update_with_response api.post(collection_uri, 'deployment' => params) end
put_to_api(params)
click to toggle source
# File lib/engineyard-cloud-client/models/deployment.rb, line 153 def put_to_api(params) update_with_response api.put(member_uri("/finished"), 'deployment' => params) end