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
26
|
# 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]
@use_external_ips = !!args[:external]
@entry = Entry.new :name => @name
end
|
Instance Method Details
#attributes ⇒ Object
150
151
152
|
# File 'lib/simple_deploy/stack.rb', line 150
def attributes
stack_reader.attributes
end
|
#create(args) ⇒ Object
28
29
30
31
32
33
34
35
36
|
# File 'lib/simple_deploy/stack.rb', line 28
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
82
83
84
|
# File 'lib/simple_deploy/stack.rb', line 82
def deploy(force = false)
deployment.execute force
end
|
#destroy ⇒ Object
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
# File 'lib/simple_deploy/stack.rb', line 94
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
111
112
113
|
# File 'lib/simple_deploy/stack.rb', line 111
def events(limit)
stack_reader.events limit
end
|
#execute(args) ⇒ Object
86
87
88
|
# File 'lib/simple_deploy/stack.rb', line 86
def execute(args)
executer.execute args
end
|
#exists? ⇒ Boolean
143
144
145
146
147
148
|
# File 'lib/simple_deploy/stack.rb', line 143
def exists?
status
true
rescue Exceptions::UnknownStack
false
end
|
#in_progress_update(args) ⇒ Object
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/simple_deploy/stack.rb', line 65
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
123
124
125
126
127
128
129
|
# File 'lib/simple_deploy/stack.rb', line 123
def instances
stack_reader.instances.map do |instance|
instance['instancesSet'].map do |info|
determine_ip_address(info)
end
end.flatten.compact
end
|
#outputs ⇒ Object
115
116
117
|
# File 'lib/simple_deploy/stack.rb', line 115
def outputs
stack_reader.outputs
end
|
#parameters ⇒ Object
154
155
156
|
# File 'lib/simple_deploy/stack.rb', line 154
def parameters
stack_reader.parameters
end
|
#raw_instances ⇒ Object
131
132
133
|
# File 'lib/simple_deploy/stack.rb', line 131
def raw_instances
stack_reader.instances
end
|
#resources ⇒ Object
119
120
121
|
# File 'lib/simple_deploy/stack.rb', line 119
def resources
stack_reader.resources
end
|
#ssh ⇒ Object
90
91
92
|
# File 'lib/simple_deploy/stack.rb', line 90
def ssh
deployment.ssh
end
|
#status ⇒ Object
135
136
137
|
# File 'lib/simple_deploy/stack.rb', line 135
def status
stack_reader.status
end
|
#template ⇒ Object
158
159
160
|
# File 'lib/simple_deploy/stack.rb', line 158
def template
stack_reader.template
end
|
#update(args) ⇒ Object
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
63
|
# File 'lib/simple_deploy/stack.rb', line 38
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
139
140
141
|
# File 'lib/simple_deploy/stack.rb', line 139
def wait_for_stable
stack_status.wait_for_stable
end
|