class Dumbwaiter::Layer

Attributes

opsworks[R]
opsworks_layer[R]
stack[R]

Public Class Methods

all(stack, opsworks = Aws::OpsWorks::Client.new(region: "us-east-1")) click to toggle source
# File lib/dumbwaiter/layer.rb, line 8
def self.all(stack, opsworks = Aws::OpsWorks::Client.new(region: "us-east-1"))
  opsworks.describe_layers(stack_id: stack.id).layers.map { |layer| new(stack, layer, opsworks) }
end
find(stack, layer_name, opsworks = Aws::OpsWorks::Client.new(region: "us-east-1")) click to toggle source
# File lib/dumbwaiter/layer.rb, line 12
def self.find(stack, layer_name, opsworks = Aws::OpsWorks::Client.new(region: "us-east-1"))
  layer = all(stack, opsworks).detect { |layer| layer.shortname == layer_name }
  raise NotFound.new("No layer found with name #{layer_name}") if layer.nil?
  layer
end
new(stack, opsworks_layer, opsworks = Aws::OpsWorks::Client.new(region: "us-east-1")) click to toggle source
# File lib/dumbwaiter/layer.rb, line 18
def initialize(stack, opsworks_layer, opsworks = Aws::OpsWorks::Client.new(region: "us-east-1"))
  @stack = stack
  @opsworks_layer = opsworks_layer
  @opsworks = opsworks
end

Public Instance Methods

custom_recipes() click to toggle source
# File lib/dumbwaiter/layer.rb, line 43
def custom_recipes
  opsworks_layer.custom_recipes.to_hash
end
id() click to toggle source
# File lib/dumbwaiter/layer.rb, line 24
def id
  opsworks_layer.layer_id
end
instances() click to toggle source
# File lib/dumbwaiter/layer.rb, line 54
def instances
  @instances ||= Dumbwaiter::Instance.all(self, opsworks)
end
run_recipe(*recipes) click to toggle source
# File lib/dumbwaiter/layer.rb, line 32
def run_recipe(*recipes)
  opsworks.create_deployment(
    stack_id: stack.id,
    instance_ids: instances.map(&:id),
    command: {
      name: "execute_recipes",
      args: {recipes: recipes}
    }
  )
end
shortname() click to toggle source
# File lib/dumbwaiter/layer.rb, line 28
def shortname
  opsworks_layer.shortname
end
update_custom_recipes(event_name, runlist) click to toggle source
# File lib/dumbwaiter/layer.rb, line 47
def update_custom_recipes(event_name, runlist)
  opsworks.update_layer(
    layer_id: id,
    custom_recipes: custom_recipes.merge(event_name => runlist)
  )
end