Class: ChefMetal::OpenstackCredentials
- Inherits:
-
Object
- Object
- ChefMetal::OpenstackCredentials
- Defined in:
- lib/chef_metal/openstack_credentials.rb
Overview
Reads in a credentials file
Class Method Summary collapse
Instance Method Summary collapse
- #[](name) ⇒ Object
- #default ⇒ Object
-
#initialize ⇒ OpenstackCredentials
constructor
A new instance of OpenstackCredentials.
- #keys ⇒ Object
- #load_default ⇒ Object
- #load_yaml(credentials_yaml_file) ⇒ Object
Constructor Details
#initialize ⇒ OpenstackCredentials
Returns a new instance of OpenstackCredentials.
4 5 6 |
# File 'lib/chef_metal/openstack_credentials.rb', line 4 def initialize @credentials = {} end |
Class Method Details
.method_missing(name, *args, &block) ⇒ Object
36 37 38 |
# File 'lib/chef_metal/openstack_credentials.rb', line 36 def self.method_missing(name, *args, &block) singleton.send(name, *args, &block) end |
.singleton ⇒ Object
40 41 42 |
# File 'lib/chef_metal/openstack_credentials.rb', line 40 def self.singleton @openstack_credentials ||= OpenstackCredentials.new end |
Instance Method Details
#[](name) ⇒ Object
16 17 18 |
# File 'lib/chef_metal/openstack_credentials.rb', line 16 def [](name) @credentials[name] end |
#default ⇒ Object
8 9 10 |
# File 'lib/chef_metal/openstack_credentials.rb', line 8 def default @credentials['default'] || @credentials.first[1] end |
#keys ⇒ Object
12 13 14 |
# File 'lib/chef_metal/openstack_credentials.rb', line 12 def keys @credentials.keys end |
#load_default ⇒ Object
32 33 34 |
# File 'lib/chef_metal/openstack_credentials.rb', line 32 def load_default load_yaml('~/.fog') end |
#load_yaml(credentials_yaml_file) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/chef_metal/openstack_credentials.rb', line 20 def load_yaml(credentials_yaml_file) creds_file = YAML.load_file(File.(credentials_yaml_file)) creds_file.each do |section, creds| @credentials[section] = { :openstack_username => creds_file[section]['openstack_username'], :openstack_api_key => creds_file[section]['openstack_api_key'], :openstack_tenant => creds_file[section]['openstack_tenant'], :openstack_auth_url => creds_file[section]['openstack_auth_url'] } end end |