Class: Opsicle::Layer
- Inherits:
-
Object
- Object
- Opsicle::Layer
- Defined in:
- lib/opsicle/layer.rb
Class Attribute Summary collapse
-
.client ⇒ Object
Returns the value of attribute client.
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
- .get_layers ⇒ Object
-
.instance_ids(client, layers) ⇒ Object
Public - gets all the layer ids for the given layers.
Instance Method Summary collapse
-
#get_instance_ids ⇒ Object
Public - Gets all the instance ids for a layer.
-
#initialize(client, options = {}) ⇒ Layer
constructor
A new instance of Layer.
Constructor Details
#initialize(client, options = {}) ⇒ Layer
Returns a new instance of Layer.
9 10 11 12 13 |
# File 'lib/opsicle/layer.rb', line 9 def initialize(client, = {}) @client = client @id = [:id] @name = [:name] end |
Class Attribute Details
.client ⇒ Object
Returns the value of attribute client.
6 7 8 |
# File 'lib/opsicle/layer.rb', line 6 def client @client end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
4 5 6 |
# File 'lib/opsicle/layer.rb', line 4 def client @client end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/opsicle/layer.rb', line 4 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/opsicle/layer.rb', line 4 def name @name end |
Class Method Details
.get_layers ⇒ Object
32 33 34 |
# File 'lib/opsicle/layer.rb', line 32 def self.get_layers client.api_call('describe_layers', stack_id: client.config.opsworks_config[:stack_id])[:layers] end |
.instance_ids(client, layers) ⇒ Object
Public - gets all the layer ids for the given layers
client - a new Client layers - an array of layer shortnames
Return - An array of instance ids belonging to the input layers
41 42 43 44 |
# File 'lib/opsicle/layer.rb', line 41 def self.instance_ids(client, layers) @client = client get_info.map{ |layer| layer.get_instance_ids if layers.include?(layer.name) }.flatten.compact.uniq end |
Instance Method Details
#get_instance_ids ⇒ Object
Public - Gets all the instance ids for a layer
Return - An array of instance ids
18 19 20 |
# File 'lib/opsicle/layer.rb', line 18 def get_instance_ids client.api_call('describe_instances', layer_id: id)[:instances].map{ |s| s[:instance_id] } end |