Class: Puppet::Provider::Nova
- Inherits:
-
Openstack
- Object
- Openstack
- Puppet::Provider::Nova
- Extended by:
- Openstack::Auth
- Defined in:
- lib/puppet/provider/nova.rb
Class Method Summary collapse
- .auth_endpoint ⇒ Object
- .conf_filename ⇒ Object
- .get_auth_endpoint ⇒ Object
- .get_nova_credentials ⇒ Object
- .nova_conf ⇒ Object
- .nova_credentials ⇒ Object
- .nova_manage_request(*args) ⇒ Object
- .nova_request(service, action, error, properties = nil) ⇒ Object
- .nova_user ⇒ Object
- .request(service, action, properties = nil) ⇒ Object
- .reset ⇒ Object
Instance Method Summary collapse
Class Method Details
.auth_endpoint ⇒ Object
118 119 120 |
# File 'lib/puppet/provider/nova.rb', line 118 def self.auth_endpoint @auth_endpoint ||= get_auth_endpoint end |
.conf_filename ⇒ Object
62 63 64 |
# File 'lib/puppet/provider/nova.rb', line 62 def self.conf_filename '/etc/nova/nova.conf' end |
.get_auth_endpoint ⇒ Object
113 114 115 116 |
# File 'lib/puppet/provider/nova.rb', line 113 def self.get_auth_endpoint q = nova_credentials "#{q['auth_url']}" end |
.get_nova_credentials ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/puppet/provider/nova.rb', line 81 def self.get_nova_credentials #needed keys for authentication auth_keys = ['auth_url', 'project_name', 'username', 'password'] conf = nova_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']['region_name'].nil? creds['region_name'] = conf['keystone_authtoken']['region_name'].strip end if !conf['keystone_authtoken']['project_domain_name'].nil? creds['project_domain_name'] = conf['keystone_authtoken']['project_domain_name'].strip else creds['project_domain_name'] = 'Default' end if !conf['keystone_authtoken']['user_domain_name'].nil? creds['user_domain_name'] = conf['keystone_authtoken']['user_domain_name'].strip else creds['user_domain_name'] = 'Default' end return creds else raise(Puppet::Error, "File: #{conf_filename} does not contain all " + "required sections. Nova types will not work if nova is not " + "correctly configured.") end end |
.nova_conf ⇒ Object
66 67 68 69 70 71 |
# File 'lib/puppet/provider/nova.rb', line 66 def self.nova_conf return @nova_conf if @nova_conf @nova_conf = Puppet::Util::IniConfig::File.new @nova_conf.read(conf_filename) @nova_conf end |
.nova_credentials ⇒ Object
73 74 75 |
# File 'lib/puppet/provider/nova.rb', line 73 def self.nova_credentials @nova_credentials ||= get_nova_credentials end |
.nova_manage_request(*args) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/puppet/provider/nova.rb', line 39 def self.nova_manage_request(*args) # Not using the nova-manage command directly, # so we can disable combining of stderr/stdout output. args.unshift(Puppet::Util.which('nova-manage')) # NOTE(mnaser): We pass the arguments as an array to avoid problems with # symbols in the arguments breaking things. Puppet::Util::Execution.execute(args, { :uid => nova_user, :failonfail => true, :combine => false, :custom_environment => {} }) end |
.nova_request(service, action, error, properties = nil) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/puppet/provider/nova.rb', line 24 def self.nova_request(service, action, error, properties=nil) properties ||= [] @credentials.username = nova_credentials['username'] @credentials.password = nova_credentials['password'] @credentials.project_name = nova_credentials['project_name'] @credentials.auth_url = auth_endpoint @credentials.user_domain_name = nova_credentials['user_domain_name'] @credentials.project_domain_name = nova_credentials['project_domain_name'] if nova_credentials['region_name'] @credentials.region_name = nova_credentials['region_name'] end raise error unless @credentials.set? Puppet::Provider::Openstack.request(service, action, properties, @credentials) end |
.nova_user ⇒ Object
58 59 60 |
# File 'lib/puppet/provider/nova.rb', line 58 def self.nova_user 'nova' end |
.request(service, action, properties = nil) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/puppet/provider/nova.rb', line 16 def self.request(service, action, properties=nil) begin super rescue Puppet::Error::OpenstackAuthInputError => error nova_request(service, action, error, properties) end end |
.reset ⇒ Object
122 123 124 125 126 |
# File 'lib/puppet/provider/nova.rb', line 122 def self.reset @auth_endpoint = nil @nova_conf = nil @nova_credentials = nil end |
Instance Method Details
#nova_credentials ⇒ Object
77 78 79 |
# File 'lib/puppet/provider/nova.rb', line 77 def nova_credentials self.class.nova_credentials end |
#nova_manage_request(*args) ⇒ Object
54 55 56 |
# File 'lib/puppet/provider/nova.rb', line 54 def nova_manage_request(*args) self.class.nova_manage_request(args) end |