1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[google|compute] Change projects we search for images in.

This removes Google (which has no valid v1 images) and adds rhel-cloud
and suse-cloud. It also wraps the lookups in a catch block for not-found
exceptions because not everyone has access to everything.
This commit is contained in:
Nat Welch 2014-03-17 07:46:25 -07:00
parent 2821afa750
commit 5f7886e08d
2 changed files with 25 additions and 10 deletions

View file

@ -0,0 +1,6 @@
def test
connection = Fog::Compute.new({ :provider => "Google" })
# If this doesn't raise an exception, everything is good.
connection.images.all
end

View file

@ -9,11 +9,14 @@ module Fog
model Fog::Compute::Google::Image
GLOBAL_PROJECTS = [ 'google',
# NOTE: Not everyone has access to these projects because of the
# licenses needed to use some of them.
# https://developers.google.com/compute/docs/premium-operating-systems
GLOBAL_PROJECTS = [
'debian-cloud',
'centos-cloud',
# RHEL removed from this list because not everyone has access to it.
# 'rhel-cloud',
'rhel-cloud',
'suse-cloud'
]
def all
@ -21,11 +24,17 @@ module Fog
all_projects = GLOBAL_PROJECTS + [ self.service.project ]
all_projects.each do |project|
begin
images = service.list_images(project).body["items"] || []
# Keep track of the project in which we found the image(s)
images.each { |img| img[:project] = project }
data += images
rescue Fog::Errors::NotFound
# Not everyone has access to every Global Project. Requests
# return 404 if you don't have access.
next
end
end
load(data)