make default lookup key in ServiceCatalog type and not name

This commit is contained in:
Mike Hagedorn 2014-08-11 16:08:55 -04:00
parent 1911883f82
commit 9534dd4a15
1 changed files with 8 additions and 6 deletions

View File

@ -254,21 +254,22 @@ module Fog
raise "Unable to parse service catalog." unless body raise "Unable to parse service catalog." unless body
service_catalog = {} service_catalog = {}
body.each do |s| body.each do |s|
name = s["name"] type = s["type"]
next if name.nil? next if type.nil?
name = name.to_sym type = type.to_sym
next if s['endpoints'].nil? next if s['endpoints'].nil?
service_catalog[name] = {} service_catalog[type] = {}
service_catalog[type]['name'] = s['name']
s['endpoints'].each do |ep| s['endpoints'].each do |ep|
next if ep['region'].nil? next if ep['region'].nil?
next if ep['publicURL'].nil? next if ep['publicURL'].nil?
next if ep['publicURL'].empty? next if ep['publicURL'].empty?
service_catalog[name][ep['region'].to_sym] = ep['publicURL'] service_catalog[type][ep['region'].to_sym] = ep['publicURL']
end end
end end
return service_catalog return service_catalog
end end
#//http://10.23.67.66:9696/
def self.get_endpoint_url(service_catalog, service_type, avl_zone) def self.get_endpoint_url(service_catalog, service_type, avl_zone)
return nil if service_type.nil? return nil if service_type.nil?
service_type = service_type.to_sym service_type = service_type.to_sym
@ -278,6 +279,7 @@ module Fog
return service_catalog[service_type][avl_zone] return service_catalog[service_type][avl_zone]
end end
end end
raise "Unable to retrieve endpoint service url for availability zone '#{avl_zone}' from service catalog. " raise "Unable to retrieve endpoint service url for availability zone '#{avl_zone}' from service catalog. "
end end