HewlettPackard / oneview-chef

This project is no longer being developed and has limited support. In the near future this repository will be fully deprecated. Please consider using other OneView projects, such as Terraform and Ansible Collection
https://supermarket.chef.io/cookbooks/oneview
Apache License 2.0
17 stars 15 forks source link

Show diff of resource that needs updated #17

Closed jsmartt closed 8 years ago

jsmartt commented 8 years ago

When updating resources, there is no log output that indicates what is changed; just that it needs updated. However, when trying to debug a resource that continually needs updated because it seems to never match the definition, it's impossible to tell why.

For instance, if you have:

oneview_ethernet_network 'Chef-Eth-Net' do
  client <my_client>
  data(
    vlanId: 51,
    purpose: 'General',
    smartLink: true,
    privateNetwork: false
  )
end

It will always get "updated". On further investigation, it's because "smartLink"=>false on OneView, and it can't be set to false. It's pretty easy to output a diff for single-level hashes like ethernet_network data. You could just output:

...
[2016-09-01T19:48:39+00:00] INFO: Update oneview_ethernet_network 'Chef-Eth-Net'

    - Update oneview_ethernet_network 'Chef-Eth-Net'

  key1: old_val -> new_val
  key2: old_val -> new_val
...

However, for nested hashes, this may prove a little more difficult. We could do a dot chain, which could look something like:

...
[2016-09-01T19:48:39+00:00] INFO: Update oneview_ethernet_network 'Chef-Eth-Net'

    - Update oneview_ethernet_network 'Chef-Eth-Net'

  key1: old_val -> new_val
  first_level.key2: old_val -> new_val
  first_level.second.third.key3: old_val -> new_val
...

The easiest option would just be to print a debug statement with both complete hashes (no diff), but I think it's worth handling cleaner than that. Thoughts?

tmiotto commented 8 years ago

It would be an interesting feature to the cookbook.

I don't know if it would be trivial without editing the like? method from the Ruby SDK, but if you have any idea on how to implement it I totally agree adding it as a Chef::log.debug output.

jsmartt commented 8 years ago

I think I can come up with something... :wink:

hdiomede commented 8 years ago

That would be a nice feature!!!