2015-11-03 11:46:54 +03:00
|
|
|
require 'db/mongo/models/stack/stack_base'
|
|
|
|
|
|
2015-03-06 12:20:30 +03:00
|
|
|
module Devops
|
|
|
|
|
module Model
|
|
|
|
|
class StackEc2 < StackBase
|
2015-08-04 12:40:08 +03:00
|
|
|
|
2016-02-24 21:26:44 +03:00
|
|
|
def initialize attrs={}
|
|
|
|
|
super
|
2015-11-03 11:46:54 +03:00
|
|
|
self.provider = 'ec2'
|
2015-08-04 12:40:08 +03:00
|
|
|
end
|
|
|
|
|
|
2015-11-17 18:08:38 +03:00
|
|
|
def update_in_cloud!(params)
|
2015-11-18 22:45:39 +03:00
|
|
|
parameters = params.keep_if do |key|
|
|
|
|
|
%w(Parameters TemplateBody TemplateURL Capabilities).include?(key)
|
2015-11-17 18:08:38 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
provider_instance.update_stack(self, parameters)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# We should improve this functionality: stack will be rollbacked
|
|
|
|
|
# if there are errors during stack_template changing, so we should track
|
|
|
|
|
# that process and persist changes only in case of success.
|
|
|
|
|
def change_stack_template!(stack_template)
|
|
|
|
|
self.stack_template = stack_template
|
|
|
|
|
update_in_cloud!('TemplateBody' => template_body)
|
|
|
|
|
Devops::Db.connector.stack_update(self)
|
|
|
|
|
end
|
|
|
|
|
|
2015-03-06 12:20:30 +03:00
|
|
|
end
|
|
|
|
|
end
|
2015-02-12 13:01:05 +03:00
|
|
|
end
|