This file is indexed.

/usr/share/puppet/modules.available/glance/lib/puppet/provider/glance.rb is in puppet-module-glance 9.4.0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
# Since there's only one glance type for now,
# this probably could have all gone in the provider file.
# But maybe this is good long-term.
require 'puppet/util/inifile'
require 'puppet/provider/openstack'
require 'puppet/provider/openstack/auth'
require 'puppet/provider/openstack/credentials'
class Puppet::Provider::Glance < Puppet::Provider::Openstack

  extend Puppet::Provider::Openstack::Auth

  def self.request(service, action, properties=nil)
    begin
      super
    rescue Puppet::Error::OpenstackAuthInputError => error
      glance_request(service, action, error, properties)
    end
  end

  def self.glance_request(service, action, error, properties=nil)
    @credentials.username = glance_credentials['username']
    @credentials.password = glance_credentials['password']
    @credentials.project_name = glance_credentials['project_name']
    @credentials.auth_url = auth_endpoint
    raise error unless @credentials.set?
    Puppet::Provider::Openstack.request(service, action, properties, @credentials)
  end

  def self.glance_credentials
    @glance_credentials ||= get_glance_credentials
  end

  def self.get_glance_credentials
    if glance_file and glance_file['keystone_authtoken'] and
      glance_file['keystone_authtoken']['auth_host'] and
      glance_file['keystone_authtoken']['auth_port'] and
      glance_file['keystone_authtoken']['auth_protocol'] and
      glance_file['keystone_authtoken']['project_name'] and
      glance_file['keystone_authtoken']['username'] and
      glance_file['keystone_authtoken']['password'] and
      glance_file['glance_store']['os_region_name']

        g = {}
        g['auth_host'] = glance_file['keystone_authtoken']['auth_host'].strip
        g['auth_port'] = glance_file['keystone_authtoken']['auth_port'].strip
        g['auth_protocol'] = glance_file['keystone_authtoken']['auth_protocol'].strip
        g['project_name'] = glance_file['keystone_authtoken']['project_name'].strip
        g['username'] = glance_file['keystone_authtoken']['username'].strip
        g['password'] = glance_file['keystone_authtoken']['password'].strip
        g['os_region_name'] = glance_file['glance_store']['os_region_name'].strip

        # auth_admin_prefix not required to be set.
        g['auth_admin_prefix'] = (glance_file['keystone_authtoken']['auth_admin_prefix'] || '').strip

        return g
    elsif glance_file and glance_file['keystone_authtoken'] and
      glance_file['keystone_authtoken']['auth_url'] and
      glance_file['keystone_authtoken']['project_name'] and
      glance_file['keystone_authtoken']['username'] and
      glance_file['keystone_authtoken']['password'] and
      glance_file['glance_store']['os_region_name']

        g = {}
        g['auth_url'] = glance_file['keystone_authtoken']['auth_url'].strip
        g['project_name'] = glance_file['keystone_authtoken']['project_name'].strip
        g['username'] = glance_file['keystone_authtoken']['username'].strip
        g['password'] = glance_file['keystone_authtoken']['password'].strip
        g['os_region_name'] = glance_file['glance_store']['os_region_name'].strip

        return g
    else
      raise(Puppet::Error, 'File: /etc/glance/glance-api.conf does not contain all required sections.')
    end
  end

  def self.auth_endpoint
    @auth_endpoint ||= get_auth_endpoint
  end

  def self.get_auth_endpoint
    g = glance_credentials
    if g.key?('auth_url')
      "#{g['auth_url']}/"
    else
      "#{g['auth_protocol']}://#{g['auth_host']}:#{g['auth_port']}#{g['auth_admin_prefix']}/v2.0/"
    end
  end

  def self.glance_file
    return @glance_file if @glance_file
    @glance_file = Puppet::Util::IniConfig::File.new
    @glance_file.read('/etc/glance/glance-api.conf')
    @glance_file
  end

  def self.glance_hash
    @glance_hash ||= build_glance_hash
  end

  def bool_to_sym(bool)
    bool == true ? :true : :false
  end

end