Class: Puppet::Provider::Manila

Inherits:
Openstack
  • Object
show all
Extended by:
Openstack::Auth
Defined in:
lib/puppet/provider/manila.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.auth_endpointObject



90
91
92
# File 'lib/puppet/provider/manila.rb', line 90

def self.auth_endpoint
  @auth_endpoint ||= get_auth_endpoint
end

.conf_filenameObject



10
11
12
# File 'lib/puppet/provider/manila.rb', line 10

def self.conf_filename
  '/etc/manila/manila.conf'
end

.get_auth_endpointObject



85
86
87
88
# File 'lib/puppet/provider/manila.rb', line 85

def self.get_auth_endpoint
  q = manila_credentials
  "#{q['auth_url']}"
end

.get_manila_credentialsObject



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
# File 'lib/puppet/provider/manila.rb', line 53

def self.get_manila_credentials
  auth_keys = ['auth_url', 'project_name', 'username',
               'password']
  conf = manila_conf
  if conf and conf['keystone_authtoken'] and
      auth_keys.all?{|k| !conf['keystone_authtoken'][k].nil?}
    creds = Hash[ auth_keys.map \
                 { |k| [k, conf['keystone_authtoken'][k].strip] } ]
    if conf['keystone_authtoken']['project_domain_name']
      creds['project_domain_name'] = conf['keystone_authtoken']['project_domain_name']
    else
      creds['project_domain_name'] = 'Default'
    end

    if conf['keystone_authtoken']['user_domain_name']
      creds['user_domain_name'] = conf['keystone_authtoken']['user_domain_name']
    else
      creds['user_domain_name'] = 'Default'
    end

    if conf['keystone_authtoken']['region_name']
      creds['region_name'] = conf['keystone_authtoken']['region_name']
    end

    return creds
  else
    raise(Puppet::Error, "File: #{conf_filename} does not contain all " +
          "required sections. Manila types will not work if manila is not " +
          "correctly configured.")
  end
end

.manila_confObject



14
15
16
17
18
19
# File 'lib/puppet/provider/manila.rb', line 14

def self.manila_conf
  return @manila_conf if @manila_conf
  @manila_conf = Puppet::Util::IniConfig::File.new
  @manila_conf.read(conf_filename)
  @manila_conf
end

.manila_credentialsObject



45
46
47
# File 'lib/puppet/provider/manila.rb', line 45

def self.manila_credentials
  @manila_credentials ||= get_manila_credentials
end

.manila_request(service, action, error, properties = nil) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/puppet/provider/manila.rb', line 29

def self.manila_request(service, action, error, properties=nil)
  warning('Usage of keystone_authtoken parameters is deprecated.')
  properties ||= []
  @credentials.username = manila_credentials['username']
  @credentials.password = manila_credentials['password']
  @credentials.project_name = manila_credentials['project_name']
  @credentials.auth_url = auth_endpoint
  @credentials.user_domain_name = manila_credentials['user_domain_name']
  @credentials.project_domain_name = manila_credentials['project_domain_name']
  if manila_credentials['region_name']
    @credentials.region_name = manila_credentials['region_name']
  end
  raise error unless @credentials.set?
  Puppet::Provider::Openstack.request(service, action, properties, @credentials)
end

.request(service, action, properties = nil) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/puppet/provider/manila.rb', line 21

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

.resetObject



94
95
96
97
98
# File 'lib/puppet/provider/manila.rb', line 94

def self.reset
  @manila_conf = nil
  @manila_credentials = nil
  @auth_endpoint = nil
end

Instance Method Details

#manila_credentialsObject



49
50
51
# File 'lib/puppet/provider/manila.rb', line 49

def manila_credentials
  self.class.manila_credentials
end