diff --git a/app/models/manageiq/providers/kubernetes/container_manager/refresh_parser.rb b/app/models/manageiq/providers/kubernetes/container_manager/refresh_parser.rb index abfcfaa12f2..73a4f0fad94 100644 --- a/app/models/manageiq/providers/kubernetes/container_manager/refresh_parser.rb +++ b/app/models/manageiq/providers/kubernetes/container_manager/refresh_parser.rb @@ -3,8 +3,8 @@ module ManageIQ::Providers::Kubernetes class ContainerManager::RefreshParser include Vmdb::Logging - def self.ems_inv_to_hashes(inventory) - new.ems_inv_to_hashes(inventory) + def self.ems_inv_to_hashes(inventory, options = Config::Options.new) + new.ems_inv_to_hashes(inventory, options) end def initialize @@ -13,7 +13,7 @@ def initialize @label_tag_mapping = ContainerLabelTagMapping.cache end - def ems_inv_to_hashes(inventory) + def ems_inv_to_hashes(inventory, _options = Config::Options.new) get_additional_attributes(inventory) get_nodes(inventory) get_namespaces(inventory) 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 90a7075943d..be9ae3e97b9 100644 --- a/app/models/manageiq/providers/openshift/container_manager/refresh_parser.rb +++ b/app/models/manageiq/providers/openshift/container_manager/refresh_parser.rb @@ -1,14 +1,14 @@ module ManageIQ::Providers module Openshift class ContainerManager::RefreshParser < ManageIQ::Providers::Kubernetes::ContainerManager::RefreshParser - def ems_inv_to_hashes(inventory) - super(inventory) + def ems_inv_to_hashes(inventory, options = Config::Options.new) + super(inventory, options) get_projects(inventory) get_routes(inventory) get_builds(inventory) get_build_pods(inventory) get_templates(inventory) - get_openshift_images(inventory) + get_openshift_images(inventory) if options.get_container_images EmsRefresh.log_inv_debug_trace(@data, "data:") @data end diff --git a/app/models/manageiq/providers/openshift/container_manager/refresher.rb b/app/models/manageiq/providers/openshift/container_manager/refresher.rb index 0ddfc96c89f..c1e6f793b76 100644 --- a/app/models/manageiq/providers/openshift/container_manager/refresher.rb +++ b/app/models/manageiq/providers/openshift/container_manager/refresher.rb @@ -8,8 +8,7 @@ class ContainerManager::Refresher < ManageIQ::Providers::BaseManager::Refresher OPENSHIFT_ENTITIES = [ {:name => 'routes'}, {:name => 'projects'}, - {:name => 'build_configs'}, {:name => 'builds'}, {:name => 'templates'}, - {:name => 'images'} + {:name => 'build_configs'}, {:name => 'builds'}, {:name => 'templates'} ] def fetch_hawk_inv(ems) @@ -25,16 +24,19 @@ def fetch_hawk_inv(ems) end def parse_legacy_inventory(ems) + request_entities = OPENSHIFT_ENTITIES.dup + request_entities << {:name => 'images'} if refresher_options.get_container_images + kube_entities = ems.with_provider_connection(:service => KUBERNETES_EMS_TYPE) do |kubeclient| fetch_entities(kubeclient, KUBERNETES_ENTITIES) end openshift_entities = ems.with_provider_connection do |openshift_client| - fetch_entities(openshift_client, OPENSHIFT_ENTITIES) + fetch_entities(openshift_client, request_entities) end entities = openshift_entities.merge(kube_entities) entities["additional_attributes"] = fetch_hawk_inv(ems) || {} EmsRefresh.log_inv_debug_trace(entities, "inv_hash:") - ManageIQ::Providers::Openshift::ContainerManager::RefreshParser.ems_inv_to_hashes(entities) + ManageIQ::Providers::Openshift::ContainerManager::RefreshParser.ems_inv_to_hashes(entities, refresher_options) end end end diff --git a/config/settings.yml b/config/settings.yml index 9d8a10306d4..cb964169c95 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -143,6 +143,7 @@ :refresh_interval: 15.minutes :openshift: :refresh_interval: 15.minutes + :get_container_images: true :raise_vm_snapshot_complete_if_created_within: 15.minutes :refresh_interval: 24.hours :scvmm: diff --git a/spec/models/manageiq/providers/openshift/container_manager/refresher_spec.rb b/spec/models/manageiq/providers/openshift/container_manager/refresher_spec.rb index f2c8b2ff9c8..e18f5a68bf6 100644 --- a/spec/models/manageiq/providers/openshift/container_manager/refresher_spec.rb +++ b/spec/models/manageiq/providers/openshift/container_manager/refresher_spec.rb @@ -192,6 +192,24 @@ end end + it 'will skip container_images if get_container_images = false' do + stub_settings( + :ems_refresh => {:openshift => {:get_container_images => false}}, + :http_proxy => {}, + :ssl => {} + ) + + VCR.use_cassette(described_class.name.underscore, + :match_requests_on => [:path,], + :allow_unused_http_interactions => true) do # , :record => :new_episodes) do + EmsRefresh.refresh(@ems) + end + + @ems.reload + + expect(ContainerImage.count).to eq(12) + end + def assert_table_counts expect(ContainerGroup.count).to eq(20) expect(ContainerNode.count).to eq(2)