Class: OpsWorks::Stack

Inherits:
Resource show all
Defined in:
lib/opsworks/stack.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

account, client, #initialize

Constructor Details

This class inherits a constructor from OpsWorks::Resource

Instance Attribute Details

#idObject

Returns the value of attribute id.



7
8
9
# File 'lib/opsworks/stack.rb', line 7

def id
  @id
end

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/opsworks/stack.rb', line 7

def name
  @name
end

Class Method Details

.activeObject



15
16
17
# File 'lib/opsworks/stack.rb', line 15

def self.active
  all.select(&:active?)
end

.allObject



9
10
11
12
13
# File 'lib/opsworks/stack.rb', line 9

def self.all
  client.describe_stacks.data[:stacks].map do |hash|
    new(id: hash[:stack_id], name: hash[:name])
  end
end

.find_by_name(name) ⇒ Object



19
20
21
# File 'lib/opsworks/stack.rb', line 19

def self.find_by_name(name)
  all.find { |stack| stack.name == name }
end

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/opsworks/stack.rb', line 53

def active?
  instances.any?(&:online?)
end

#appsObject



23
24
25
# File 'lib/opsworks/stack.rb', line 23

def apps
  @apps ||= initialize_apps
end

#deploy_app(app) ⇒ Object



48
49
50
51
# File 'lib/opsworks/stack.rb', line 48

def deploy_app(app)
  fail 'App not found' unless app && app.id
  create_deployment(app_id: app.id, command: { name: 'deploy' })
end

#execute_recipe(recipe) ⇒ Object



39
40
41
42
43
44
45
46
# File 'lib/opsworks/stack.rb', line 39

def execute_recipe(recipe)
  create_deployment(
    command: {
      name: 'execute_recipes',
      args: { 'recipes' => [recipe] }
    }
  )
end

#find_app_by_name(name) ⇒ Object



27
28
29
# File 'lib/opsworks/stack.rb', line 27

def find_app_by_name(name)
  apps.find { |app| app.name == name }
end

#instancesObject



31
32
33
# File 'lib/opsworks/stack.rb', line 31

def instances
  @instances ||= initialize_instances
end

#update_custom_cookbooksObject



35
36
37
# File 'lib/opsworks/stack.rb', line 35

def update_custom_cookbooks
  create_deployment(command: { name: 'update_custom_cookbooks' })
end