Sha256: be10ceff283f9c68445d874816873da4cd0e2c7f2dda05df2a537774c92ac8b6

Contents?: true

Size: 1.14 KB

Versions: 6

Compression:

Stored size: 1.14 KB

Contents

require 'yaml'

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

      def users
        @_users ||= Fog::Identity[:openstack].users
      end

      def tenants
        @_tenants ||= Fog::Identity[:openstack].tenants
      end

      def roles
        @_roles ||= Fog::Identity[:openstack].roles
      end

      def users_hash
        return @h if @h

        @h = {}
        users.each do |u|
          next if ignored_users.include?(u.name)
          @h[u.name] = {}
          @h[u.name]["email"] = u.email
          @h[u.name]["tenants"] = {}
          tenants.each do |t|
            r = u.roles(t.id)
            if r.size > 0
              @h[u.name]["tenants"][t.name] = r.first["name"]
            end
          end
        end
        @h
      end

      # default service users
      def ignored_users
        %w[
          neutron
          glance
          cinder
          admin
          nova_ec2
          nova
        ]
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
kaname-0.3.0 lib/kaname/resource.rb
kaname-0.2.0 lib/kaname/resource.rb
kaname-0.1.6 lib/kaname/resource.rb
kaname-0.1.5 lib/kaname/resource.rb
kaname-0.1.4 lib/kaname/resource.rb
kaname-0.1.3 lib/kaname/resource.rb