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, options = {}) ⇒ Object
- .nova_user ⇒ Object
- .project_request(service, action, properties = nil, options = {}) ⇒ Object
- .request(service, action, properties = nil, options = {}, scope = 'project') ⇒ Object
- .reset ⇒ Object
- .system_request(service, action, properties = nil, options = {}) ⇒ Object
Instance Method Summary collapse
Class Method Details
.auth_endpoint ⇒ Object
121 122 123 |
# File 'lib/puppet/provider/nova.rb', line 121 def self.auth_endpoint @auth_endpoint ||= get_auth_endpoint end |
.conf_filename ⇒ Object
65 66 67 |
# File 'lib/puppet/provider/nova.rb', line 65 def self.conf_filename '/etc/nova/nova.conf' end |
.get_auth_endpoint ⇒ Object
116 117 118 119 |
# File 'lib/puppet/provider/nova.rb', line 116 def self.get_auth_endpoint q = nova_credentials "#{q['auth_url']}" end |
.get_nova_credentials ⇒ Object
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 112 113 114 |
# File 'lib/puppet/provider/nova.rb', line 84 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
69 70 71 72 73 74 |
# File 'lib/puppet/provider/nova.rb', line 69 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
76 77 78 |
# File 'lib/puppet/provider/nova.rb', line 76 def self.nova_credentials @nova_credentials ||= get_nova_credentials end |
.nova_manage_request(*args) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/puppet/provider/nova.rb', line 42 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, options = {}) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/puppet/provider/nova.rb', line 26 def self.nova_request(service, action, error, properties=nil, ={}) warning('Usage of keystone_authtoken parameters is deprecated.') 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
61 62 63 |
# File 'lib/puppet/provider/nova.rb', line 61 def self.nova_user 'nova' end |
.project_request(service, action, properties = nil, options = {}) ⇒ Object
10 11 12 |
# File 'lib/puppet/provider/nova.rb', line 10 def self.project_request(service, action, properties=nil, ={}) self.request(service, action, properties, , 'project') end |
.request(service, action, properties = nil, options = {}, scope = 'project') ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/puppet/provider/nova.rb', line 18 def self.request(service, action, properties=nil, ={}, scope='project') begin super rescue Puppet::Error::OpenstackAuthInputError => error nova_request(service, action, error, properties, ) end end |
.reset ⇒ Object
125 126 127 128 129 |
# File 'lib/puppet/provider/nova.rb', line 125 def self.reset @auth_endpoint = nil @nova_conf = nil @nova_credentials = nil end |
.system_request(service, action, properties = nil, options = {}) ⇒ Object
14 15 16 |
# File 'lib/puppet/provider/nova.rb', line 14 def self.system_request(service, action, properties=nil, ={}) self.request(service, action, properties, , 'system') end |
Instance Method Details
#nova_credentials ⇒ Object
80 81 82 |
# File 'lib/puppet/provider/nova.rb', line 80 def nova_credentials self.class.nova_credentials end |
#nova_manage_request(*args) ⇒ Object
57 58 59 |
# File 'lib/puppet/provider/nova.rb', line 57 def nova_manage_request(*args) self.class.nova_manage_request(args) end |