Class: Dumbwaiter::Layer
- Inherits:
-
Object
- Object
- Dumbwaiter::Layer
- Defined in:
- lib/dumbwaiter/layer.rb
Defined Under Namespace
Classes: NotFound
Instance Attribute Summary collapse
-
#opsworks ⇒ Object
readonly
Returns the value of attribute opsworks.
-
#opsworks_layer ⇒ Object
readonly
Returns the value of attribute opsworks_layer.
-
#stack ⇒ Object
readonly
Returns the value of attribute stack.
Class Method Summary collapse
- .all(stack, opsworks = Aws::OpsWorks::Client.new(region: "us-east-1")) ⇒ Object
- .find(stack, layer_name, opsworks = Aws::OpsWorks::Client.new(region: "us-east-1")) ⇒ Object
Instance Method Summary collapse
- #custom_recipes ⇒ Object
- #id ⇒ Object
-
#initialize(stack, opsworks_layer, opsworks = Aws::OpsWorks::Client.new(region: "us-east-1")) ⇒ Layer
constructor
A new instance of Layer.
- #instances ⇒ Object
- #run_recipe(*recipes) ⇒ Object
- #shortname ⇒ Object
- #update_custom_recipes(event_name, runlist) ⇒ Object
Constructor Details
#initialize(stack, opsworks_layer, opsworks = Aws::OpsWorks::Client.new(region: "us-east-1")) ⇒ Layer
Returns a new instance of Layer.
18 19 20 21 22 |
# 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 |
Instance Attribute Details
#opsworks ⇒ Object (readonly)
Returns the value of attribute opsworks.
4 5 6 |
# File 'lib/dumbwaiter/layer.rb', line 4 def opsworks @opsworks end |
#opsworks_layer ⇒ Object (readonly)
Returns the value of attribute opsworks_layer.
4 5 6 |
# File 'lib/dumbwaiter/layer.rb', line 4 def opsworks_layer @opsworks_layer end |
#stack ⇒ Object (readonly)
Returns the value of attribute stack.
4 5 6 |
# File 'lib/dumbwaiter/layer.rb', line 4 def stack @stack end |
Class Method Details
.all(stack, opsworks = Aws::OpsWorks::Client.new(region: "us-east-1")) ⇒ Object
8 9 10 |
# 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")) ⇒ Object
12 13 14 15 16 |
# 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 |
Instance Method Details
#custom_recipes ⇒ Object
43 44 45 |
# File 'lib/dumbwaiter/layer.rb', line 43 def custom_recipes opsworks_layer.custom_recipes.to_hash end |
#id ⇒ Object
24 25 26 |
# File 'lib/dumbwaiter/layer.rb', line 24 def id opsworks_layer.layer_id end |
#instances ⇒ Object
54 55 56 |
# File 'lib/dumbwaiter/layer.rb', line 54 def instances @instances ||= Dumbwaiter::Instance.all(self, opsworks) end |
#run_recipe(*recipes) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# 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 ⇒ Object
28 29 30 |
# File 'lib/dumbwaiter/layer.rb', line 28 def shortname opsworks_layer.shortname end |
#update_custom_recipes(event_name, runlist) ⇒ Object
47 48 49 50 51 52 |
# 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 |