Sha256: 83a96d7532276c3fa605b29d64bb653369cdbf70607f58ac0fe79ec210afa5d0

Contents?: true

Size: 679 Bytes

Versions: 5

Compression:

Stored size: 679 Bytes

Contents

require 'yaml'

module Kaname
  class Resource
    class << self
      def yaml(filename = 'keystone.yml')
        if File.exists?(filename)
          @_yaml ||= expand_all_tenants(YAML.load_file(filename))
        end
      end

      private

      def expand_all_tenants _yaml
        list_tenants = Kaname::Adapter::ReadOnly.new.list_tenants

        _yaml.each do |username, config|
          next unless config['all_tenants']
          tenants = list_tenants.map{|tenant| [tenant.name, config['all_tenants']]}
          config['tenants'] = Hash[*tenants.flatten].merge(config['tenants'] || {})
          config.delete('all_tenants')
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
kaname-0.6.2 lib/kaname/resource.rb
kaname-0.6.1 lib/kaname/resource.rb
kaname-0.6.0 lib/kaname/resource.rb
kaname-0.5.2 lib/kaname/resource.rb
kaname-0.5.1 lib/kaname/resource.rb