Class: EbDeployer::EbEnvironment
- Inherits:
-
Object
- Object
- EbDeployer::EbEnvironment
- Defined in:
- lib/eb_deployer/eb_environment.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#event_poller ⇒ Object
writeonly
Sets the attribute event_poller.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #cname_prefix ⇒ Object
- #deploy(version_label, settings = {}) ⇒ Object
-
#initialize(app, name, eb_driver, creation_opts = {}) ⇒ EbEnvironment
constructor
A new instance of EbEnvironment.
- #log(msg) ⇒ Object
- #swap_cname_with(another) ⇒ Object
- #terminate ⇒ Object
Constructor Details
#initialize(app, name, eb_driver, creation_opts = {}) ⇒ EbEnvironment
Returns a new instance of EbEnvironment.
12 13 14 15 16 17 |
# File 'lib/eb_deployer/eb_environment.rb', line 12 def initialize(app, name, eb_driver, creation_opts={}) @app = app @name = self.class.unique_ebenv_name(name, app) @bs = eb_driver @creation_opts = creation_opts end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
3 4 5 |
# File 'lib/eb_deployer/eb_environment.rb', line 3 def app @app end |
#event_poller=(value) ⇒ Object
Sets the attribute event_poller
4 5 6 |
# File 'lib/eb_deployer/eb_environment.rb', line 4 def event_poller=(value) @event_poller = value end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/eb_deployer/eb_environment.rb', line 3 def name @name end |
Class Method Details
.unique_ebenv_name(env_name, app_name) ⇒ Object
6 7 8 9 10 |
# File 'lib/eb_deployer/eb_environment.rb', line 6 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
#cname_prefix ⇒ Object
26 27 28 |
# File 'lib/eb_deployer/eb_environment.rb', line 26 def cname_prefix @bs.environment_cname_prefix(@app, @name) end |
#deploy(version_label, settings = {}) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/eb_deployer/eb_environment.rb', line 19 def deploy(version_label, settings={}) terminate if @creation_opts[:phoenix_mode] create_or_update_env(version_label, settings) smoke_test wait_for_env_become_healthy end |
#log(msg) ⇒ Object
35 36 37 |
# File 'lib/eb_deployer/eb_environment.rb', line 35 def log(msg) puts "[#{Time.now.utc}][environment:#{@name}] #{msg}" end |
#swap_cname_with(another) ⇒ Object
30 31 32 33 |
# File 'lib/eb_deployer/eb_environment.rb', line 30 def swap_cname_with(another) log("Swap CNAME with env #{another.name}") @bs.environment_swap_cname(self.app, self.name, another.name) end |
#terminate ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/eb_deployer/eb_environment.rb', line 39 def terminate if @bs.environment_exists?(@app, @name) with_polling_events(/terminateEnvironment completed successfully/i) do @bs.delete_environment(@app, @name) end end end |