Class: EbDeployer::EbEnvironment
- Inherits:
-
Object
- Object
- EbDeployer::EbEnvironment
show all
- Includes:
- Utils
- Defined in:
- lib/eb_deployer/eb_environment.rb
Constant Summary
Constants included
from Utils
Utils::BACKOFF_INITIAL_SLEEP
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Utils
#backoff, #reject_nil, #symbolize_keys
Constructor Details
#initialize(app, name, eb_driver, creation_opts = {}) ⇒ EbEnvironment
Returns a new instance of EbEnvironment.
14
15
16
17
18
19
|
# File 'lib/eb_deployer/eb_environment.rb', line 14
def initialize(app, name, eb_driver, creation_opts={})
@app = app
@name = self.class.unique_ebenv_name(name, app)
@bs = eb_driver
@creation_opts = default_create_options.merge(reject_nil(creation_opts))
end
|
Instance Attribute Details
#app ⇒ Object
Returns the value of attribute app.
5
6
7
|
# File 'lib/eb_deployer/eb_environment.rb', line 5
def app
@app
end
|
#event_poller=(value) ⇒ Object
Sets the attribute event_poller
6
7
8
|
# File 'lib/eb_deployer/eb_environment.rb', line 6
def event_poller=(value)
@event_poller = value
end
|
#name ⇒ Object
Returns the value of attribute name.
5
6
7
|
# File 'lib/eb_deployer/eb_environment.rb', line 5
def name
@name
end
|
Class Method Details
.unique_ebenv_name(env_name, app_name) ⇒ Object
8
9
10
11
12
|
# File 'lib/eb_deployer/eb_environment.rb', line 8
def self.unique_ebenv_name(env_name, app_name)
raise "Environment name #{env_name} is too long, it must be under 15 chars" if env_name.size > 15
digest = Digest::SHA1.hexdigest(app_name + '-' + env_name)[0..6]
"#{env_name}-#{digest}"
end
|
Instance Method Details
#apply_settings(settings) ⇒ Object
34
35
36
37
38
39
|
# File 'lib/eb_deployer/eb_environment.rb', line 34
def apply_settings(settings)
raise "Env #{self.name} not exists for applying settings" unless @bs.environment_exists?(@app, @name)
with_polling_events(/Environment update completed successfully/i) do
@bs.update_environment_settings(@app, @name, settings)
end
end
|
#cname_prefix ⇒ Object
41
42
43
|
# File 'lib/eb_deployer/eb_environment.rb', line 41
def cname_prefix
@bs.environment_cname_prefix(@app, @name)
end
|
#deploy(version_label, settings = {}) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/eb_deployer/eb_environment.rb', line 21
def deploy(version_label, settings={})
terminate if @creation_opts[:phoenix_mode]
if @bs.environment_exists?(@app, @name)
update_eb_env(settings, version_label)
else
create_eb_env(settings, version_label)
end
smoke_test
wait_for_env_become_healthy
end
|
#log(msg) ⇒ Object
52
53
54
|
# File 'lib/eb_deployer/eb_environment.rb', line 52
def log(msg)
puts "[#{Time.now.utc}][environment:#{@name}] #{msg}"
end
|
#swap_cname_with(another) ⇒ Object
45
46
47
48
49
50
|
# File 'lib/eb_deployer/eb_environment.rb', line 45
def swap_cname_with(another)
log("Swap CNAME with env #{another.name}")
with_polling_events(/Completed swapping CNAMEs for environments/i) do
@bs.environment_swap_cname(self.app, self.name, another.name)
end
end
|
#terminate ⇒ Object
56
57
58
59
60
61
62
|
# File 'lib/eb_deployer/eb_environment.rb', line 56
def terminate
if @bs.environment_exists?(@app, @name)
with_polling_events(/terminateEnvironment completed successfully/i) do
@bs.delete_environment(@app, @name)
end
end
end
|