Class: Chef::Provider::ServerCollection

Inherits:
Chef::Provider show all
Defined in:
lib/chef/providers/server_collection_provider.rb

Overview

ServerCollection chef provider. Allows retrieving a set of servers by tags

Instance Method Summary collapse

Constructor Details

#initialize(node, resource, collection = nil, definitions = {}, cookbook_loader = nil) ⇒ ServerCollection

Initialize condition variable used to synchronize chef and EM threads



32
33
34
# File 'lib/chef/providers/server_collection_provider.rb', line 32

def initialize(node, resource, collection=nil, definitions={}, cookbook_loader=nil)
  super(node, resource)
end

Instance Method Details

#action_loadObject

Get the tagged servers synchronously

Return

true

Always return true



48
49
50
51
52
53
54
55
56
57
# File 'lib/chef/providers/server_collection_provider.rb', line 48

def action_load
  node.set[:server_collection] ||= {}
  node.set[:server_collection][@new_resource.name] = {}
  return unless @new_resource.tags && !@new_resource.tags.empty?

  result = RightScale::Cook.instance.query_tags(@new_resource.tags, @new_resource.agent_ids, @new_resource.timeout)
  collection = result.inject({}) { |res, (k, v)| res[k] = v['tags']; res }
  node.set[:server_collection][@new_resource.name] = collection
  true
end

#load_current_resourceObject

This provider doesn’t actually change any state on the server

Return

true

Always return true



40
41
42
# File 'lib/chef/providers/server_collection_provider.rb', line 40

def load_current_resource
  true
end