lib/stack.rb in stack-kicker-0.0.16 vs lib/stack.rb in stack-kicker-0.0.18

- old
+ new

@@ -340,11 +340,18 @@ if config[:global_service_name].nil? Logger.error { "Defaulting to 'UNKNOWN' for config[:global_service_name]" } config[:site_template] = 'UNKNOWN' end + if config[:metadata].nil? + config[:metadata] = Hash.new + end + if config[:find_file_paths].nil? + config[:find_file_paths] = Array.new + end + if config[:node_details].nil? Logger.debug { "Initializing config[:node_details] and config[:azs]" } config[:node_details] = Hash.new config[:azs] = Array.new @@ -777,13 +784,27 @@ multipart = multipart_complete end Logger.info "Creating #{hostname} in #{node_details[hostname][:az]} with role #{role}" - # this will get put in /meta.js - metadata = { 'region' => node_details[hostname][:az], 'chef_role' => role } + # this will get put in /meta.js - should look like this: + # {"region": "az-2.region-a.geo-1", "area": "aw2", "az": "az2", "continent": "dev"} + metadata = { + 'region' => node_details[hostname][:az], + 'continent' => 'unknown', # we could infer this from the region, or default to 'dev' + 'area' => 'unknown', # we could infer this from the region-a/region-b + 'az' => node_details[hostname][:az].split('.')[0].sub(/-/, ''), + 'chef_role' => role + } + Logger.debug "Generated metadata: #{metadata}" + Logger.debug "Supplied metadata: #{config[:metadata]}" + # merge with the supplied data, which will override our generated data + + metadata.merge!(config[:metadata]) + Logger.info "Final metadata: #{metadata}" + os = Stack.connect(config, node_details[hostname][:az]) newserver = os.create_server(:name => hostname, :imageRef => config[node_details[hostname][:az]]['image_id'], :flavorRef => config['flavor_id'], :security_groups=>[role_details[:security_group]], @@ -846,13 +867,16 @@ def Stack.find_file(config, filename) # find a file, using the standard path precedence # 1) cwd # 2) stackhome + # 2) stackhome + find_file_paths # 3) gemhome/lib dirs = [ './' ] dirs.push(config[:stackhome]) - dirs.push(@@gemhome + '/lib') + config[:find_file_paths].each { |fp| dirs.push(File.join(config[:stackhome], fp)) } + dirs.push(File.join(@@gemhome, 'lib')) + dirs.flatten! Logger.debug "find_file, looking for #{filename} in #{dirs}" filename_fqp = '' dirs.each do |dir| fqp = dir + '/' + filename