Class: Automan::Beanstalk::Application

Inherits:
Automan::Base show all
Defined in:
lib/automan/beanstalk/application.rb

Constant Summary

Constants included from Mixins::AwsCaller

Mixins::AwsCaller::S3_PROTO

Instance Attribute Summary

Attributes inherited from Automan::Base

#logger, #wait

Attributes included from Mixins::AwsCaller

#as, #cfn, #eb, #ec, #ec2, #elb, #r53, #rds, #s3

Instance Method Summary collapse

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

#application_exists?Boolean

Returns:

  • (Boolean)


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/automan/beanstalk/application.rb', line 7

def application_exists?
  opts = {
    application_names: [ name ]
  }

  response = eb.describe_applications opts

  unless response.successful?
    raise RequestFailedError, "describe_applications failed: #{response.error}"
  end

  response.data[:applications].each do |app|
    if app[:application_name] == name
      return true
    end
  end

  return false
end

#createObject



55
56
57
58
59
60
61
62
# File 'lib/automan/beanstalk/application.rb', line 55

def create
  log_options
  if application_exists?
    logger.warn "Application #{name} already exists. Doing nothing."
    return
  end
  create_application
end

#create_applicationObject



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/automan/beanstalk/application.rb', line 27

def create_application
  logger.info "creating application #{name}"

  opts = {
    application_name: name
  }

  response = eb.create_application opts

  unless response.successful?
    raise RequestFailedError, "create_application failed: #{response.error}"
  end
end

#deleteObject



64
65
66
67
68
69
70
71
# File 'lib/automan/beanstalk/application.rb', line 64

def delete
  log_options
  if !application_exists?
    logger.warn "Application #{name} does not exist. Doing nothing."
    return
  end
  delete_application
end

#delete_applicationObject



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/automan/beanstalk/application.rb', line 41

def delete_application
  logger.info "deleting application #{name}"

  opts = {
    application_name: name
  }

  response = eb.delete_application opts

  unless response.successful?
    raise RequestFailedError, "delete_application failed: #{response.error}"
  end
end