lib/fog/compute/google/models/images.rb in fog-google-0.3.2 vs lib/fog/compute/google/models/images.rb in fog-google-0.4.0
- old
+ new
@@ -20,11 +20,10 @@
"windows-cloud"
]
def all
data = []
- all_projects = [service.project] + global_projects
all_projects.each do |project|
begin
images = service.list_images(project).body["items"] || []
@@ -48,14 +47,12 @@
all_images.each { |img| data.push(img) unless img.deprecated }
data
end
def get(identity)
- # Search own project before global projects
- all_projects = [service.project] + global_projects
-
data = nil
+
all_projects.each do |project|
begin
data = service.get_image(identity, project).body
data[:project] = project
rescue Fog::Errors::NotFound
@@ -66,13 +63,31 @@
end
return nil if data.nil?
new(data)
end
+ def get_from_family(family)
+ data = nil
+
+ all_projects.each do |project|
+ begin
+ data = service.get_image_from_family(family, project).body
+ data[:project] = project
+ rescue Fog::Errors::NotFound
+ next
+ else
+ break
+ end
+ end
+ return nil if data.nil?
+ new(data)
+ end
+
private
- def global_projects
- GLOBAL_PROJECTS + service.extra_global_projects
+ def all_projects
+ # Search own project before global projects
+ [service.project] + GLOBAL_PROJECTS + service.extra_global_projects
end
end
end
end
end