Class: ZZSharedLib::Utils
- Inherits:
-
Object
- Object
- ZZSharedLib::Utils
- Defined in:
- lib/zzsharedlib/utilities.rb
Constant Summary collapse
- READY =
"ready".freeze
- ERROR =
"error".freeze
- START =
"deploying".freeze
- MAINT =
"maint".freeze
- NEVER =
"never".freeze
- RESTARTING =
"restarting".freeze
- OK_TO_DEPLOY_STATES =
[NEVER, READY, ERROR].freeze
Instance Method Summary collapse
- #check_deploy_state(instances, state_tags) ⇒ Object
-
#initialize(amazon) ⇒ Utils
constructor
A new instance of Utils.
-
#mark_deploy_state(instances, state_tag, state, keep_error_state = false) ⇒ Object
mark the deploy state of all unless already marked as errors so we don’t overwrite that state.
Constructor Details
#initialize(amazon) ⇒ Utils
Returns a new instance of Utils.
26 27 28 |
# File 'lib/zzsharedlib/utilities.rb', line 26 def initialize(amazon) @amazon = amazon end |
Instance Method Details
#check_deploy_state(instances, state_tags) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/zzsharedlib/utilities.rb', line 50 def check_deploy_state(instances, ) instances.each do |instance| inst_id = instance[:resource_id] = @amazon.(inst_id) .each do |state_tag| deploy_tag = [state_tag] if !deploy_tag.nil? && !OK_TO_DEPLOY_STATES.include?(deploy_tag) raise "One or more instances is still marked as deploying for tag key: #{state_tag}, value: #{deploy_tag}, we will not deploy again. You can use --force to override" end end end end |
#mark_deploy_state(instances, state_tag, state, keep_error_state = false) ⇒ Object
mark the deploy state of all unless already marked as errors so we don’t overwrite that state
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/zzsharedlib/utilities.rb', line 32 def mark_deploy_state(instances, state_tag, state, keep_error_state = false) to_tag = [] instances.each do |instance| inst_id = instance[:resource_id] if keep_error_state = @amazon.(inst_id) deploy_tag = [state_tag] if !deploy_tag.nil? && deploy_tag != ERROR to_tag << inst_id end else to_tag << inst_id end end @amazon.ec2.(to_tag, {state_tag => state }) @amazon. end |