Example: How to use the whitelist for Object_walker

I’m just writing this to share a simple how-to that I thought other newcomers might benefit from.

If you haven’t begun using the Object_walker script for inspecting the objects available in the automation engine, drop everything and go set it up: https://github.com/pemcg/object_walker

When you use the object walker it “walks” through the tree of objects in the workspace and prints out various properties, methods, associations, etc. But it doesn’t walk through everything or the output would be overwhelming. Instead, the script relies on a ‘white list’ or a list of objects to include in the process.

You may edit the whitelist to add objects to the list and thus expose more detail in the output.

Below is a simple example of how to do this. I wanted to learn more about the providers objects, which by default are not whitelisted.

Before editing the whitelist, the output read:

     |    |    $evm.root['tenant'].providers (type: Association)
     |    |    *** not walking: 'providers' isn't in the walk_association_whitelist hash for MiqAeServiceTenant ***

I was interested in the contents of providers.

So I went into the investigative debugging domain in the automate explorer (you’ll learn how to install this domain by following the directions found in the first link I shared above). In this domain go to:
Investigative_debugging / ObjectWalker / configuration:

image

The fields of this configuration instance include an attribute called walk_association_whitelist:

I added the final key-value pair in the list (outlined in red in the screenshot above) to tell object_walker to include the providers object in the process. Now when I run object_walker and print the contents in object walker reader I see a ton of detail for each provider in the db:

     |    |    $evm.root['tenant'].providers (type: Association)
     |    |    $evm.root['tenant'].providers.each do |provider|
     |    |    (object type: MiqAeServiceManageIQ_Providers_EmbeddedAnsible_Provider, object ID: 1)
     |    |    |    --- attributes follow ---
     |    |    |    provider.created_at = 2020-08-24 18:12:09 UTC   (type: ActiveSupport::TimeWithZone)
     |    |    |    provider.guid = a66c088e-aaaa-aaaa-aaaa-821aaaa94c46   (type: String)
     |    |    |    provider.id = 1   (type: Integer)
     |    |    |    provider.name = Embedded Ansible   (type: String)
     |    |    |    provider.tenant_id = 1   (type: Integer)
     |    |    |    provider.type = ManageIQ::Providers::EmbeddedAnsible::Provider   (type: String)
     |    |    |    provider.updated_at = 2020-08-24 18:12:09 UTC   (type: ActiveSupport::TimeWithZone)
     |    |    |    provider.zone_id = nil
     |    |    |    --- end of attributes ---
     |    |    |    --- virtual columns follow ---
     |    |    |    provider.authentication_status = None   (type: String)
     |    |    |    provider.href_slug = nil
     |    |    |    provider.region_description = Region 0   (type: String)
     |    |    |    provider.region_number = 0   (type: Integer)
     |    |    |    !!! MiqAeServiceManageIQ_Providers_EmbeddedAnsible_Provider virtual column 'security_protocol' throws a DRb::DRbUnknownError exception when accessed (product bug?) !!!
     |    |    |    provider.url = nil
     |    |    |    provider.verify_ssl = 1   (type: Integer)
     |    |    |    --- end of virtual columns ---
     |    |    |    --- associations follow ---
     |    |    |    provider.authentication_status_severity_level (type: Association (empty))
     |    |    |    provider.authentications (type: Association (empty))
     |    |    |    provider.automation_manager (type: Association)
     |    |    |    *** not walking: 'automation_manager' isn't in the walk_association_whitelist hash for MiqAeServiceManageIQ_Providers_EmbeddedAnsible_Provider ***
     |    |    |    provider.default_ansible_objects (type: Association (empty))
     |    |    |    provider.endpoints (type: Association)
     |    |    |    *** not walking: 'endpoints' isn't in the walk_association_whitelist hash for MiqAeServiceManageIQ_Providers_EmbeddedAnsible_Provider ***
     |    |    |    provider.external_urls (type: Association (empty))
     |    |    |    provider.managers (type: Association)
     |    |    |    *** not walking: 'managers' isn't in the walk_association_whitelist hash for MiqAeServiceManageIQ_Providers_EmbeddedAnsible_Provider ***
     |    |    |    provider.tenant (type: Association)
     |    |    |    *** not walking: 'tenant' isn't in the walk_association_whitelist hash for MiqAeServiceManageIQ_Providers_EmbeddedAnsible_Provider ***
     |    |    |    provider.zone (type: Association (empty))
     |    |    |    --- end of associations ---
     |    |    |    --- methods follow ---
     |    |    |    provider.inspect
     |    |    |    provider.inspect_all
     |    |    |    provider.model_suffix
     |    |    |    provider.reload
     |    |    |    --- end of methods ---
     |    |    |    --- object is not taggable ---
     |    |    |    --- object does not support custom attributes ---
     |    |    --- next provider ---
     |    |    (object type: MiqAeServiceManageIQ_Providers_AnsibleTower_Provider, object ID: 2)
     |    |    |    --- attributes follow ---
     |    |    |    provider.created_at = 2020-08-26 15:38:08 UTC   (type: ActiveSupport::TimeWithZone)
     |    |    |    provider.guid = 63e85aec-5555-ssss-aaaa-a714aaaa796d   (type: String)
     |    |    |    provider.id = 2   (type: Integer)
     |    |    |    provider.name = awx   (type: String)
     |    |    |    provider.tenant_id = 1   (type: Integer)
     |    |    |    provider.type = ManageIQ::Providers::AnsibleTower::Provider   (type: String)
     |    |    |    provider.updated_at = 2020-08-26 15:38:08 UTC   (type: ActiveSupport::TimeWithZone)
     |    |    |    provider.zone_id = 2   (type: Integer)
     |    |    |    --- end of attributes ---
     |    |    |    --- virtual columns follow ---
     |    |    |    provider.authentication_status = Error   (type: String)
     |    |    |    provider.href_slug = nil
     |    |    |    provider.region_description = Region 0   (type: String)
     |    |    |    provider.region_number = 0   (type: Integer)
     |    |    |    !!! MiqAeServiceManageIQ_Providers_AnsibleTower_Provider virtual column 'security_protocol' throws a DRb::DRbUnknownError exception when accessed (product bug?) !!!
     |    |    |    provider.url = https://ansible.chq.ei/api/v2   (type: String)
     |    |    |    provider.verify_ssl = 0   (type: Integer)
     |    |    |    --- end of virtual columns ---
     |    |    |    --- associations follow ---
     |    |    |    provider.authentication_status_severity_level (type: Association)
     |    |    |    *** not walking: 'authentication_status_severity_level' isn't in the walk_association_whitelist hash for MiqAeServiceManageIQ_Providers_AnsibleTower_Provider ***
     |    |    |    provider.authentications (type: Association)
     |    |    |    *** not walking: 'authentications' isn't in the walk_association_whitelist hash for MiqAeServiceManageIQ_Providers_AnsibleTower_Provider ***
     |    |    |    provider.automation_manager (type: Association)
     |    |    |    *** not walking: 'automation_manager' isn't in the walk_association_whitelist hash for MiqAeServiceManageIQ_Providers_AnsibleTower_Provider ***
     |    |    |    provider.endpoints (type: Association)
     |    |    |    *** not walking: 'endpoints' isn't in the walk_association_whitelist hash for MiqAeServiceManageIQ_Providers_AnsibleTower_Provider ***
     |    |    |    provider.external_urls (type: Association (empty))
     |    |    |    provider.managers (type: Association)
     |    |    |    *** not walking: 'managers' isn't in the walk_association_whitelist hash for MiqAeServiceManageIQ_Providers_AnsibleTower_Provider ***
     |    |    |    provider.tenant (type: Association)
     |    |    |    *** not walking: 'tenant' isn't in the walk_association_whitelist hash for MiqAeServiceManageIQ_Providers_AnsibleTower_Provider ***
     |    |    |    provider.zone (type: Association)
     |    |    |    *** not walking: 'zone' isn't in the walk_association_whitelist hash for MiqAeServiceManageIQ_Providers_AnsibleTower_Provider ***
     |    |    |    --- end of associations ---
     |    |    |    --- methods follow ---
     |    |    |    provider.inspect
     |    |    |    provider.inspect_all
     |    |    |    provider.model_suffix
     |    |    |    provider.reload
     |    |    |    --- end of methods ---
     |    |    |    --- object is not taggable ---
     |    |    |    --- object does not support custom attributes ---
     |    |    --- end of $evm.root['tenant'].providers.each do |provider| ---

Thanks for the writeup Michael, I’m glad it’s proving useful!

pemcg

Very welcome :slight_smile: Thanks for building such a helpful tool !