lib/connection.rb in forj-0.0.18 vs lib/connection.rb in forj-0.0.19
- old
+ new
@@ -22,11 +22,11 @@
module Connection
def compute
credentials = get_credentials
- compute = Fog::Compute.new ({
+ Fog::Compute.new({
:provider => 'HP',
:hp_access_key => credentials['access_key'],
:hp_secret_key => credentials['secret_key'],
:hp_auth_uri => credentials['auth_uri'],
:hp_tenant_id => credentials['tenant_id'],
@@ -35,11 +35,11 @@
})
end
def network
credentials = get_credentials
- network = Fog::HP::Network.new ({
+ Fog::HP::Network.new({
:hp_access_key => credentials['access_key'],
:hp_secret_key => credentials['secret_key'],
:hp_auth_uri => credentials['auth_uri'],
:hp_tenant_id => credentials['tenant_id'],
:hp_avl_zone => credentials['availability_zone'],
@@ -48,21 +48,21 @@
end
def get_credentials
home = File.expand_path('~')
- file = home + '/.hpcloud/.hpcloud'
- template = YAML.load_file(file)
+ creds = '%s/.hpcloud/accounts/hp' % [home]
+ template = YAML.load_file(creds)
credentials = Hash.new
begin
- credentials['access_key'] = template['default']['access_key']
- credentials['secret_key'] = template['default']['secret_key']
- credentials['auth_uri'] = template['default']['auth_uri']
- credentials['tenant_id'] = template['default']['tenant_id']
- credentials['availability_zone'] = template['default']['availability_zone']
+ credentials['access_key'] = template[:credentials][:account_id]
+ credentials['secret_key'] = template[:credentials][:secret_key]
+ credentials['auth_uri'] = template[:credentials][:auth_uri]
+ credentials['tenant_id'] = template[:credentials][:tenant_id]
+ credentials['availability_zone'] = template[:regions][:monitoring]
rescue
- puts 'your credentials are not configured, delete the file %s and run forj setup again' % [file]
+ puts 'your credentials are not configured, delete the file %s and run forj setup again' % [creds]
end
credentials
end