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:
parent
2821afa750
commit
5f7886e08d
2 changed files with 25 additions and 10 deletions
6
lib/fog/google/examples/image_all.rb
Normal file
6
lib/fog/google/examples/image_all.rb
Normal 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
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue