Class: SimpleDeploy::Stack
- Inherits:
-
Object
- Object
- SimpleDeploy::Stack
show all
- Defined in:
- lib/simple_deploy/stack.rb,
lib/simple_deploy/stack/ssh.rb,
lib/simple_deploy/stack/execute.rb,
lib/simple_deploy/stack/deployment.rb,
lib/simple_deploy/stack/output_mapper.rb,
lib/simple_deploy/stack/deployment/status.rb
Defined Under Namespace
Classes: Deployment, Execute, OutputMapper, SSH
Instance Method Summary
collapse
Constructor Details
#initialize(args) ⇒ Stack
Returns a new instance of Stack.
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/simple_deploy/stack.rb', line 16
def initialize(args)
@environment = args[:environment]
@name = args[:name]
@config = SimpleDeploy.config
@logger = SimpleDeploy.logger
@use_internal_ips = !!args[:internal]
@entry = Entry.new :name => @name
end
|
Instance Method Details
#attributes ⇒ Object
153
154
155
|
# File 'lib/simple_deploy/stack.rb', line 153
def attributes
stack_reader.attributes
end
|
#create(args) ⇒ Object
27
28
29
30
31
32
33
34
35
|
# File 'lib/simple_deploy/stack.rb', line 27
def create(args)
attributes = stack_attribute_formatter.updated_attributes args[:attributes]
@template_file = args[:template]
@entry.set_attributes attributes
stack_creator.create
@entry.save
end
|
#deploy(force = false) ⇒ Object
81
82
83
|
# File 'lib/simple_deploy/stack.rb', line 81
def deploy(force = false)
deployment.execute force
end
|
#destroy ⇒ Object
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
# File 'lib/simple_deploy/stack.rb', line 93
def destroy
unless exists?
@logger.error "#{@name} does not exist"
return false
end
if attributes['protection'] != 'on'
stack_destroyer.destroy
@entry.delete_attributes
@logger.info "#{@name} destroyed."
true
else
@logger.warn "#{@name} could not be destroyed because it is protected. Run the protect subcommand to unprotect it"
false
end
end
|
#events(limit) ⇒ Object
110
111
112
|
# File 'lib/simple_deploy/stack.rb', line 110
def events(limit)
stack_reader.events limit
end
|
#execute(args) ⇒ Object
85
86
87
|
# File 'lib/simple_deploy/stack.rb', line 85
def execute(args)
executer.execute args
end
|
#exists? ⇒ Boolean
146
147
148
149
150
151
|
# File 'lib/simple_deploy/stack.rb', line 146
def exists?
status
true
rescue Exceptions::UnknownStack
false
end
|
#in_progress_update(args) ⇒ Object
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/simple_deploy/stack.rb', line 64
def in_progress_update(args)
if args[:caller].kind_of? Stack::Deployment::Status
@logger.info "Updating #{@name}."
attributes = stack_attribute_formatter.updated_attributes args[:attributes]
@template_body = args[:template_body] || template
@entry.set_attributes attributes
stack_updater.update_stack attributes
@logger.info "Update complete for #{@name}."
@entry.save
true
else
false
end
end
|
#instances ⇒ Object
122
123
124
125
126
127
128
129
130
131
132
|
# File 'lib/simple_deploy/stack.rb', line 122
def instances
stack_reader.instances.map do |instance|
instance['instancesSet'].map do |info|
if info['vpcId'] || @use_internal_ips
info['privateIpAddress']
else
info['ipAddress']
end
end
end.flatten.compact
end
|
#outputs ⇒ Object
114
115
116
|
# File 'lib/simple_deploy/stack.rb', line 114
def outputs
stack_reader.outputs
end
|
#parameters ⇒ Object
157
158
159
|
# File 'lib/simple_deploy/stack.rb', line 157
def parameters
stack_reader.parameters
end
|
#raw_instances ⇒ Object
134
135
136
|
# File 'lib/simple_deploy/stack.rb', line 134
def raw_instances
stack_reader.instances
end
|
#resources ⇒ Object
118
119
120
|
# File 'lib/simple_deploy/stack.rb', line 118
def resources
stack_reader.resources
end
|
#ssh ⇒ Object
89
90
91
|
# File 'lib/simple_deploy/stack.rb', line 89
def ssh
deployment.ssh
end
|
#status ⇒ Object
138
139
140
|
# File 'lib/simple_deploy/stack.rb', line 138
def status
stack_reader.status
end
|
#template ⇒ Object
161
162
163
|
# File 'lib/simple_deploy/stack.rb', line 161
def template
stack_reader.template
end
|
#update(args) ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/simple_deploy/stack.rb', line 37
def update(args)
if !deployment.clear_for_deployment? && args[:force]
deployment.clear_deployment_lock true
Backoff.exp_periods do |p|
sleep p
break if deployment.clear_for_deployment?
end
end
if deployment.clear_for_deployment?
@logger.info "Updating #{@name}."
attributes = stack_attribute_formatter.updated_attributes args[:attributes]
@template_body = args[:template_body] || template
@entry.set_attributes attributes
stack_updater.update_stack attributes
@logger.info "Update complete for #{@name}."
@entry.save
true
else
@logger.info "Not clear to update."
false
end
end
|
#wait_for_stable ⇒ Object
142
143
144
|
# File 'lib/simple_deploy/stack.rb', line 142
def wait_for_stable
stack_status.wait_for_stable
end
|