Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add debug logging for object updates from the VC #293

Merged
merged 1 commit into from
Jul 10, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ class ManageIQ::Providers::Vmware::InfraManager::Inventory::Collector
include Vmdb::Logging

attr_reader :ems, :inventory_cache, :run_once, :saver
attr_accessor :exit_requested
attr_accessor :exit_requested, :initial

def initialize(ems, run_once: false, threaded: true)
@ems = ems
@initial = true
@inventory_cache = ems.class::Inventory::Cache.new
@run_once = run_once
@saver = ems.class::Inventory::Saver.new(:threaded => threaded)
Expand All @@ -26,6 +27,8 @@ def run
version = initial_refresh(vim, property_filter)
_log.info("Refreshing initial inventory...Complete")

self.initial = false

return if run_once

until exit_requested
Expand Down Expand Up @@ -158,6 +161,8 @@ def process_object_update_set(object_update_set)
def process_object_update(object_update)
managed_object = object_update.obj

log_object_update(object_update)

props =
case object_update.kind
when "enter"
Expand Down Expand Up @@ -218,6 +223,20 @@ def save_inventory(persister)
saver.queue_save_inventory(persister)
end

def log_object_update(object_update)
return if initial

_log.debug do
object_str = "#{object_update.obj.class.wsdl_name}:#{object_update.obj._ref}"

prop_changes = object_update.changeSet.map(&:name).take(5).join(", ")
prop_changes << ", ..." if object_update.changeSet.length > 5

s = "Object: [#{object_str}] Kind: [#{object_update.kind}]"
s << " Props: [#{prop_changes}]" if object_update.kind == "modify"
end
end

def full_persister_klass
@full_persister_klass ||= ems.class::Inventory::Persister
end
Expand Down