Class: Puppet::Provider::Cinder
- Inherits:
-
Openstack
- Object
- Openstack
- Puppet::Provider::Cinder
- Extended by:
- Openstack::Auth
- Defined in:
- lib/puppet/provider/cinder.rb
Class Method Summary collapse
- .auth_endpoint ⇒ Object
- .cinder_conf ⇒ Object
- .cinder_credentials ⇒ Object
- .cinder_request(service, action, error, properties = nil) ⇒ Object
- .conf_filename ⇒ Object
- .get_auth_endpoint ⇒ Object
- .get_cinder_credentials ⇒ Object
- .request(service, action, properties = nil) ⇒ Object
- .reset ⇒ Object
Instance Method Summary collapse
Class Method Details
.auth_endpoint ⇒ Object
82 83 84 |
# File 'lib/puppet/provider/cinder.rb', line 82 def self.auth_endpoint @auth_endpoint ||= get_auth_endpoint end |
.cinder_conf ⇒ Object
14 15 16 17 18 19 |
# File 'lib/puppet/provider/cinder.rb', line 14 def self.cinder_conf return @cinder_conf if @cinder_conf @cinder_conf = Puppet::Util::IniConfig::File.new @cinder_conf.read(conf_filename) @cinder_conf end |
.cinder_credentials ⇒ Object
43 44 45 |
# File 'lib/puppet/provider/cinder.rb', line 43 def self.cinder_credentials @cinder_credentials ||= get_cinder_credentials end |
.cinder_request(service, action, error, properties = nil) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/puppet/provider/cinder.rb', line 29 def self.cinder_request(service, action, error, properties=nil) properties ||= [] @credentials.username = cinder_credentials['username'] @credentials.password = cinder_credentials['password'] @credentials.project_name = cinder_credentials['project_name'] @credentials.auth_url = auth_endpoint if @credentials.version == '3' @credentials.user_domain_name = cinder_credentials['user_domain_name'] @credentials.project_domain_name = cinder_credentials['project_domain_name'] end raise error unless @credentials.set? Puppet::Provider::Openstack.request(service, action, properties, @credentials) end |
.conf_filename ⇒ Object
10 11 12 |
# File 'lib/puppet/provider/cinder.rb', line 10 def self.conf_filename '/etc/cinder/cinder.conf' end |
.get_auth_endpoint ⇒ Object
77 78 79 80 |
# File 'lib/puppet/provider/cinder.rb', line 77 def self.get_auth_endpoint q = cinder_credentials "#{q['auth_uri']}" end |
.get_cinder_credentials ⇒ Object
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 |
# File 'lib/puppet/provider/cinder.rb', line 51 def self.get_cinder_credentials auth_keys = ['auth_uri', 'project_name', 'username', 'password'] conf = cinder_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['project_domain_name'] creds['project_domain_name'] = conf['project_domain_name'] else creds['project_domain_name'] = 'Default' end if conf['user_domain_name'] creds['user_domain_name'] = conf['user_domain_name'] else creds['user_domain_name'] = 'Default' end return creds else raise(Puppet::Error, "File: #{conf_filename} does not contain all " + "required sections. Cinder types will not work if cinder is not " + "correctly configured.") end end |
.request(service, action, properties = nil) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/puppet/provider/cinder.rb', line 21 def self.request(service, action, properties=nil) begin super rescue Puppet::Error::OpenstackAuthInputError, Puppet::Error::OpenstackUnauthorizedError => error cinder_request(service, action, error, properties) end end |
.reset ⇒ Object
86 87 88 89 |
# File 'lib/puppet/provider/cinder.rb', line 86 def self.reset @cinder_conf = nil @cinder_credentials = nil end |
Instance Method Details
#cinder_credentials ⇒ Object
47 48 49 |
# File 'lib/puppet/provider/cinder.rb', line 47 def cinder_credentials self.class.cinder_credentials end |