Class: Cheftacular::QueueMaster
- Inherits:
-
Object
- Object
- Cheftacular::QueueMaster
- Defined in:
- lib/cheftacular/queue_master.rb
Instance Method Summary collapse
- #generate_passwords_for_each_server_hash_in_queue(server_queue = 'server_creation_queue') ⇒ Object
-
#initialize(options, config) ⇒ QueueMaster
constructor
A new instance of QueueMaster.
- #return_hash_from_queue(queue_name, hash, hash_key) ⇒ Object
- #sync_server_hash_into_queue(server_hash, server_queue = 'server_creation_queue', found_result = false) ⇒ Object
- #work_off_slack_queue ⇒ Object
Constructor Details
#initialize(options, config) ⇒ QueueMaster
Returns a new instance of QueueMaster.
4 5 6 |
# File 'lib/cheftacular/queue_master.rb', line 4 def initialize , config @options, @config = , config end |
Instance Method Details
#generate_passwords_for_each_server_hash_in_queue(server_queue = 'server_creation_queue') ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/cheftacular/queue_master.rb', line 34 def generate_passwords_for_each_server_hash_in_queue server_queue='server_creation_queue' @config[server_queue].each do |queue_hash| @config[server_queue][ @config[server_queue].index(queue_hash) ] = queue_hash.merge( { 'deploy_password' => @config['helper'].gen_pass(@config['cheftacular']['server_pass_length']) } ) end end |
#return_hash_from_queue(queue_name, hash, hash_key) ⇒ Object
42 43 44 |
# File 'lib/cheftacular/queue_master.rb', line 42 def return_hash_from_queue queue_name, hash, hash_key @config[queue_name].select { |queue_hash| queue_hash[hash_key] == hash[hash_key] }.first end |
#sync_server_hash_into_queue(server_hash, server_queue = 'server_creation_queue', found_result = false) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/cheftacular/queue_master.rb', line 18 def sync_server_hash_into_queue server_hash, server_queue='server_creation_queue', found_result=false @config[server_queue].select { |hash| hash['node_name'] == server_hash['node_name']}.each do |queue_hash| @config[server_queue][ @config[server_queue].index(queue_hash) ] = queue_hash.merge(server_hash) found_result = true end server_hash.each_pair do |key, val| server_hash[key] = '' if val.nil? end @config[server_queue] << server_hash unless found_result server_hash end |
#work_off_slack_queue ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/cheftacular/queue_master.rb', line 8 def work_off_slack_queue return true if @config['slack_queue'].empty? @config['slack_queue'].each do |slack_hash| @config['stateless_action'].slack(slack_hash[:message], slack_hash[:channel]) end @config['slack_queue'] = [] end |