Hi, I am writing custom resources for Arista switches and I have an issue with the hash.merge. I want to implement logging in a vrf (which is a kind of change root).
The resource is ensurable, if I want to delete a logging entry, I get a :vrf=>nil in the property_hash. Prior to the hash merge I have in the property_hash: {:name=>"192.168.12.2", :ensure=>:present, :vrf=>"mgmt"} property_flush: {:name=>"192.168.12.2", :provider=>:eos, :loglevel=>:notice, :ensure=>:absent, :vrf=>nil} Post merge property_hash: {:name=>"192.168.12.2", :ensure=>:absent, :vrf=>nil, :provider=>:eos, :loglevel=>:notice} But without the vrf information my api command is not working right. What is the best way to solve this issue? Thanks in advanced, Martin Code: def self.instances logging = node.api('logging').get Puppet.debug("Puppet::Provider::Eos_logging_host.instances: rbeapi get " + logging.inspect) return [] if !logging[:hosts] || logging[:hosts].empty? logging[:hosts].each_with_object([]) do |(name,attrs),arry| provider_hash = { :name => name, :ensure => :present } provider_hash[:vrf] = attrs[:vrf] if attrs[:vrf] arry << new(provider_hash) end end . . . def flush api = node.api('logging') Puppet.debug("Puppet::Provider::Eos_logging_host.instances: property_hash" + @property_hash.inspect) Puppet.debug("Puppet::Provider::Eos_logging_host.instances: provider_flush" + @property_flush.inspect) @property_hash.merge!(@property_flush) Puppet.debug("Puppet::Provider::Eos_logging_host.instances post merge: property_hash" + @property_hash.inspect) case @property_hash[:ensure] when :present remove_puppet_keys(@property_hash) api.add_host(resource[:name], @property_hash) when :absent remove_puppet_keys(@property_hash) api.remove_host(resource[:name], @property_hash) end @property_flush = {} end Log: Debug: Puppet::Provider::Eos_logging_host.instances: rbeapi get {:enable=>true, :hosts=>{"192.168.10.2"=>{:name=>"192.168.10.2", :vrf=>"mgmt"}, "192.168.11.2"=>{:name=>"192.168.11.2", :vrf=>"mgmt"}, "192.168.12.2"=>{:name=>"192.168.12.2", :vrf=>"mgmt"}}} Notice: /Stage[main]/Noc::Profile::System/Eos_logging_host[192.168.12.2]/ensure: removed Debug: Puppet::Provider::Eos_logging_host.instances: property_hash{:name=>"192.168.12.2", :ensure=>:present, :vrf=>"mgmt"} Debug: Puppet::Provider::Eos_logging_host.instances: provider_flush{:name=>"192.168.12.2", :provider=>:eos, :loglevel=>:notice, :ensure=>:absent, :vrf=>nil} Debug: Puppet::Provider::Eos_logging_host.instances post merge: property_hash{:name=>"192.168.12.2", :ensure=>:absent, :vrf=>nil, :provider=>:eos, :loglevel=>:notice} Debug: /Stage[main]/Noc::Profile::System/Eos_logging_host[192.168.12.2]: The container Class[Noc::Profile::System] will propagate my refresh event Debug: Class[Noc::Profile::System]: The container Stage[main] will propagate my refresh event Debug: Finishing transaction 90685620 Debug: Storing state Debug: Stored state in 0.00 seconds -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/44711b23-d6cf-4516-9fde-97f5d83b6c77%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.