Project

General

Profile

« Previous | Next » 

Revision d55f273f

Added by Kavita Gaikwad about 4 years ago

Fixes #29049 - filter images & extends projects in GCE (#7463)

appends Google extra global projects list with 'rhel-sap-cloud' project
to show images as Google compute engine.
Also, adds a method to filter the image list from
google compute by adding image family names to filter list.

View differences:

app/models/compute_resources/foreman/model/gce.rb
end
def available_images
client.images
images_list = client.images.current
if image_families_to_filter.any?
regexp = Setting.convert_array_to_regexp(image_families_to_filter, prefix: '', suffix: '')
images_list.select! { |img| img.family&.match(regexp) }
end
images_list
end
def image_families_to_filter
self.class.image_families_to_filter
end
def self.image_families_to_filter
@image_families_to_filter ||= []
end
# Becomes easy to filter the images list from Google Compute Engine
# Register an image family using this method to filter list
# Example - 'rhel', 'centos'
def self.register_family_for_image_filter(family)
image_families_to_filter << family
image_families_to_filter.uniq!
end
def self.model_name
......
:provider => 'google',
:google_project => project,
:google_client_email => email,
:google_json_key_location => key_path
:google_json_key_location => key_path,
:google_extra_global_projects => ['rhel-sap-cloud']
)
end

Also available in: Unified diff