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,23 +9,32 @@ module Fog
|
||||||
|
|
||||||
model Fog::Compute::Google::Image
|
model Fog::Compute::Google::Image
|
||||||
|
|
||||||
GLOBAL_PROJECTS = [ 'google',
|
# NOTE: Not everyone has access to these projects because of the
|
||||||
'debian-cloud',
|
# licenses needed to use some of them.
|
||||||
'centos-cloud',
|
# https://developers.google.com/compute/docs/premium-operating-systems
|
||||||
# RHEL removed from this list because not everyone has access to it.
|
GLOBAL_PROJECTS = [
|
||||||
# 'rhel-cloud',
|
'debian-cloud',
|
||||||
]
|
'centos-cloud',
|
||||||
|
'rhel-cloud',
|
||||||
|
'suse-cloud'
|
||||||
|
]
|
||||||
|
|
||||||
def all
|
def all
|
||||||
data = []
|
data = []
|
||||||
all_projects = GLOBAL_PROJECTS + [ self.service.project ]
|
all_projects = GLOBAL_PROJECTS + [ self.service.project ]
|
||||||
|
|
||||||
all_projects.each do |project|
|
all_projects.each do |project|
|
||||||
images = service.list_images(project).body["items"] || []
|
begin
|
||||||
|
images = service.list_images(project).body["items"] || []
|
||||||
|
|
||||||
# Keep track of the project in which we found the image(s)
|
# Keep track of the project in which we found the image(s)
|
||||||
images.each { |img| img[:project] = project }
|
images.each { |img| img[:project] = project }
|
||||||
data += images
|
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
|
end
|
||||||
|
|
||||||
load(data)
|
load(data)
|
||||||
|
|
Loading…
Reference in a new issue