Class: Automan::Beanstalk::Terminator
- Inherits:
-
Automan::Base
- Object
- Automan::Base
- Automan::Beanstalk::Terminator
- Defined in:
- lib/automan/beanstalk/terminator.rb
Constant Summary
Constants included from Mixins::AwsCaller
Instance Attribute Summary
Attributes inherited from Automan::Base
Attributes included from Mixins::AwsCaller
#as, #cfn, #eb, #ec, #ec2, #elb, #r53, #rds, #s3
Instance Method Summary collapse
- #environment_exists?(environment_name) ⇒ Boolean
- #terminate ⇒ Object
- #terminate_environment ⇒ Object
Methods inherited from Automan::Base
add_option, #initialize, #log_options, #wait_until
Methods included from Mixins::AwsCaller
#account, #configure_aws, #looks_like_s3_path?, #parse_s3_path, #s3_object_exists?, #s3_read
Constructor Details
This class inherits a constructor from Automan::Base
Instance Method Details
#environment_exists?(environment_name) ⇒ Boolean
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/automan/beanstalk/terminator.rb', line 7 def environment_exists?(environment_name) opts = { environment_names: [ environment_name ] } response = eb.describe_environments opts unless response.successful? raise RequestFailedError "describe_environments failed: #{response.error}" end response.data[:environments].each do |e| if e[:environment_name] == environment_name logger.debug "#{environment_name} has status: #{e[:status]}" case e[:status] when 'Terminated', 'Terminating' return false else return true end end end false end |
#terminate ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/automan/beanstalk/terminator.rb', line 49 def terminate if !environment_exists?(name) logger.warn "Environment #{name} does not exist. Doing nothing." return end terminate_environment end |
#terminate_environment ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/automan/beanstalk/terminator.rb', line 35 def terminate_environment logger.info "terminating environment #{name}" opts = { environment_name: name } response = eb.terminate_environment opts unless response.successful? raise RequestFailedError "terminate_environment failed: #{response.error}" end end |