From 4f18efe57bb18771319b582580bcce5ae4d25bdd Mon Sep 17 00:00:00 2001 From: Erez Freiberger Date: Tue, 13 Jun 2017 19:08:40 +0300 Subject: [PATCH] add openshift_container_image class proccessing --- .../manageiq/providers/openshift/container_manager.rb | 2 ++ .../openshift/container_manager/refresh_parser.rb | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/models/manageiq/providers/openshift/container_manager.rb b/app/models/manageiq/providers/openshift/container_manager.rb index b0681dc7..08b31e6b 100644 --- a/app/models/manageiq/providers/openshift/container_manager.rb +++ b/app/models/manageiq/providers/openshift/container_manager.rb @@ -8,6 +8,8 @@ class ManageIQ::Providers::Openshift::ContainerManager < ManageIQ::Providers::Co require_nested :RefreshWorker require_nested :Refresher + has_many :openshift_container_images, :foreign_key => :ems_id, :dependent => :destroy + def self.ems_type @ems_type ||= "openshift".freeze end diff --git a/app/models/manageiq/providers/openshift/container_manager/refresh_parser.rb b/app/models/manageiq/providers/openshift/container_manager/refresh_parser.rb index 9d223f72..eef83eed 100644 --- a/app/models/manageiq/providers/openshift/container_manager/refresh_parser.rb +++ b/app/models/manageiq/providers/openshift/container_manager/refresh_parser.rb @@ -14,7 +14,12 @@ def ems_inv_to_hashes(inventory, options = Config::Options.new) end def get_openshift_images(inventory) - inventory["image"].each { |img| parse_openshift_image(img) } + #inventory["image"].each { |img| parse_openshift_image(img) } + key = path_for_entity("openshift_image") + process_collection(inventory["image"], key) { |n| parse_openshift_image(n) } + + # remove all openshift images from container_image list + @data[:container_images].delete_if { |ci| ci[:ems_ref] } end def get_builds(inventory) @@ -175,6 +180,8 @@ def parse_openshift_image(openshift_image) ref = "#{ContainerImage::DOCKER_PULLABLE_PREFIX}#{id}" new_result = parse_container_image(id, ref) + new_result.merge!(:ems_ref => openshift_image.metadata.uid) + if openshift_image[:dockerImageManifest].present? begin json = JSON.parse(openshift_image[:dockerImageManifest])