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
113 114 115 |
# File 'lib/puppet/provider/nova.rb', line 113 def self.auth_endpoint @auth_endpoint ||= get_auth_endpoint end |
.conf_filename ⇒ Object
57 58 59 |
# File 'lib/puppet/provider/nova.rb', line 57 def self.conf_filename '/etc/nova/nova.conf' end |
.get_auth_endpoint ⇒ Object
108 109 110 111 |
# File 'lib/puppet/provider/nova.rb', line 108 def self.get_auth_endpoint q = nova_credentials "#{q['auth_url']}" end |
.get_nova_credentials ⇒ Object
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 105 106 |
# File 'lib/puppet/provider/nova.rb', line 76 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
61 62 63 64 65 66 |
# File 'lib/puppet/provider/nova.rb', line 61 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
68 69 70 |
# File 'lib/puppet/provider/nova.rb', line 68 def self.nova_credentials @nova_credentials ||= get_nova_credentials end |
.nova_manage_request(*args) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/puppet/provider/nova.rb', line 34 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
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/puppet/provider/nova.rb', line 18 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
53 54 55 |
# File 'lib/puppet/provider/nova.rb', line 53 def self.nova_user 'nova' end |
.request(service, action, properties = nil) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/puppet/provider/nova.rb', line 10 def self.request(service, action, properties=nil) begin super rescue Puppet::Error::OpenstackAuthInputError => error nova_request(service, action, error, properties) end end |
.reset ⇒ Object
117 118 119 120 121 |
# File 'lib/puppet/provider/nova.rb', line 117 def self.reset @auth_endpoint = nil @nova_conf = nil @nova_credentials = nil end |
Instance Method Details
#nova_credentials ⇒ Object
72 73 74 |
# File 'lib/puppet/provider/nova.rb', line 72 def nova_credentials self.class.nova_credentials end |
#nova_manage_request(*args) ⇒ Object
49 50 51 |
# File 'lib/puppet/provider/nova.rb', line 49 def nova_manage_request(*args) self.class.nova_manage_request(args) end |