mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Add avl zone as required param. Update endpoint retrieving logic from catalog to allow future avl zones. Fix minor error in tests.
This commit is contained in:
parent
1805a3a164
commit
11c1c40293
9 changed files with 20 additions and 18 deletions
|
@ -45,6 +45,7 @@ An alternate file may be used by placing its path in the FOG_RC environment vari
|
|||
:hp_account_id:
|
||||
:hp_secret_key:
|
||||
:hp_tenant_id:
|
||||
:hp_avl_zone:
|
||||
:linode_api_key:
|
||||
:local_root:
|
||||
:new_servers_password:
|
||||
|
|
|
@ -177,19 +177,19 @@ module Fog
|
|||
private
|
||||
|
||||
def self.get_endpoint_from_catalog(service_catalog, service_type, avl_zone)
|
||||
if service_catalog
|
||||
service_item = service_catalog.select {|s| s["type"] == service_type}.first
|
||||
if service_item and service_item['endpoints'] and
|
||||
if avl_zone == :az1
|
||||
endpoint_url = service_item['endpoints'][0]['publicURL'] if service_item['endpoints'][0]
|
||||
elsif avl_zone == :az2
|
||||
endpoint_url = service_item['endpoints'][1]['publicURL'] if service_item['endpoints'][1]
|
||||
end
|
||||
raise "Unable to retrieve endpoint service url from service catalog." if endpoint_url.nil?
|
||||
return endpoint_url
|
||||
raise "Unable to parse service catalog." unless service_catalog
|
||||
service_item = service_catalog.detect do |s|
|
||||
s["type"] == service_type
|
||||
end
|
||||
if service_item and service_item['endpoints']
|
||||
endpoint = service_item['endpoints'].detect do |ep|
|
||||
ep['region'] == avl_zone
|
||||
end
|
||||
endpoint_url = endpoint['publicURL'] if endpoint
|
||||
raise "Unable to retrieve endpoint service url for availability zone '#{avl_zone}' from service catalog. " if endpoint_url.nil?
|
||||
return endpoint_url
|
||||
else
|
||||
raise "Unable to parse service catalog."
|
||||
raise "Unable to retrieve service item for '#{service_type}' from service catalog."
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@ module Fog
|
|||
module Compute
|
||||
class HP < Fog::Service
|
||||
|
||||
requires :hp_secret_key, :hp_account_id, :hp_tenant_id
|
||||
recognizes :hp_auth_uri, :hp_servicenet, :persistent, :connection_options, :hp_use_upass_auth_style, :hp_auth_version, :hp_avl_zone
|
||||
requires :hp_secret_key, :hp_account_id, :hp_tenant_id, :hp_avl_zone
|
||||
recognizes :hp_auth_uri, :hp_servicenet, :persistent, :connection_options, :hp_use_upass_auth_style, :hp_auth_version
|
||||
|
||||
model_path 'fog/hp/models/compute'
|
||||
model :address
|
||||
|
|
|
@ -31,6 +31,7 @@ if Fog.mock?
|
|||
:hp_account_id => 'hp_account_id',
|
||||
:hp_secret_key => 'hp_secret_key',
|
||||
:hp_tenant_id => 'hp_tenant_id',
|
||||
:hp_avl_zone => 'hp_avl_zone',
|
||||
:linode_api_key => 'linode_api_key',
|
||||
:local_root => '~/.fog',
|
||||
:new_servers_password => 'new_servers_password',
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
Shindo.tests("Fog::Compute[:hp] | address", ['hp']) do
|
||||
|
||||
@base_image_id = ENV["BASE_IMAGE_ID"] ||= 1242
|
||||
@base_image_id = ENV["BASE_IMAGE_ID"] ||= "1242"
|
||||
|
||||
model_tests(Fog::Compute[:hp].addresses, {}, true) do
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ Shindo.tests('Fog::Compute[:hp] | address requests', ['hp']) do
|
|||
'id' => Integer
|
||||
}
|
||||
|
||||
@base_image_id = ENV["BASE_IMAGE_ID"] ||= 1242
|
||||
@base_image_id = ENV["BASE_IMAGE_ID"] ||= "1242"
|
||||
|
||||
tests('success') do
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ Shindo.tests('Fog::Compute[:hp] | image requests', ['hp']) do
|
|||
'name' => String
|
||||
}
|
||||
|
||||
@base_image_id = ENV["BASE_IMAGE_ID"] ||= 1242
|
||||
@base_image_id = ENV["BASE_IMAGE_ID"] ||= "1242"
|
||||
|
||||
tests('success') do
|
||||
@server_name = "fogservertest"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
Shindo.tests('Fog::Compute[:hp] | address requests', ['hp']) do
|
||||
|
||||
@base_image_id = ENV["BASE_IMAGE_ID"] ||= 1242
|
||||
@base_image_id = ENV["BASE_IMAGE_ID"] ||= "1242"
|
||||
|
||||
tests('success') do
|
||||
@server = Fog::Compute[:hp].servers.create(:name => 'fogaddresstests', :flavor_id => 100, :image_id => @base_image_id)
|
||||
|
|
|
@ -34,7 +34,7 @@ Shindo.tests('Fog::Compute[:hp] | server requests', ['hp']) do
|
|||
'output' => String
|
||||
}
|
||||
|
||||
@base_image_id = ENV["BASE_IMAGE_ID"] ||= 1242
|
||||
@base_image_id = ENV["BASE_IMAGE_ID"] ||= "1242"
|
||||
|
||||
tests('success') do
|
||||
|
||||
|
|
Loading…
Reference in a new issue