class Opsicle::Layer

Attributes

client[RW]
client[RW]
id[RW]
name[RW]

Public Class Methods

get_layers() click to toggle source
# 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) click to toggle source

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

# 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
new(client, options = {}) click to toggle source
# File lib/opsicle/layer.rb, line 9
def initialize(client, options = {})
  @client = client
  @id = options[:id]
  @name = options[:name]
end

Private Class Methods

get_info() click to toggle source

Private - Gets layer info from OpsWorks

Return - An array of layer objects

# File lib/opsicle/layer.rb, line 25
def self.get_info
  get_layers.map do |layer|
    new(client, id: layer[:layer_id], name: layer[:shortname])
  end
end

Public Instance Methods

get_instance_ids() click to toggle source

Public - Gets all the instance ids for a layer

Return - An array of instance ids

# 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