Skip to content

Commit

Permalink
Merge pull request #14606 from agrare/allow_container_images_to_be_sk…
Browse files Browse the repository at this point in the history
…ipped

Add config option to skip container_images

(cherry picked from commit d3ebee7)
  • Loading branch information
blomquisg authored and agrare committed Aug 24, 2017
1 parent e893a4e commit d89ceea
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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_nodes(inventory)
get_namespaces(inventory)
get_resource_quotas(inventory)
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,22 @@ 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 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)
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
Expand Down
2 changes: 2 additions & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,10 @@
:kubernetes:
:refresh_interval: 15.minutes
:openshift:
:get_container_images: true
:refresh_interval: 15.minutes
:openshift_enterprise:
:get_container_images: true
:refresh_interval: 15.minutes
:raise_vm_snapshot_complete_if_created_within: 15.minutes
:refresh_interval: 24.hours
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,22 @@
end
end

it 'will skip container_images if get_container_images = false' do
stub_settings(Settings.to_hash.deep_merge(
:ems_refresh => {:openshift => {:get_container_images => false}},
))

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(4)
end

def assert_table_counts
expect(ContainerGroup.count).to eq(5)
expect(ContainerNode.count).to eq(1)
Expand Down

0 comments on commit d89ceea

Please sign in to comment.