Skip to content

Commit

Permalink
Add debug logging for object updates from the VC
Browse files Browse the repository at this point in the history
This adds a debug logging method to print the object, the type of
update, and a short list of property names which changed.

Example:
`Object: [Datastore:datastore-52] Kind: [modify] Props:
[host["host-1836"].mountInfo, info.freeSpace, info.timestamp,
summary.freeSpace]`
  • Loading branch information
agrare committed Jul 9, 2018
1 parent a875367 commit f4d0af2
Showing 1 changed file with 20 additions and 1 deletion.
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

0 comments on commit f4d0af2

Please sign in to comment.