From 2d119164fdd6995a6b4535f4e5c97dd0b2ddd9f9 Mon Sep 17 00:00:00 2001 From: Stephen Gelman Date: Wed, 1 May 2019 23:26:46 -0500 Subject: [PATCH 1/2] Sort the list of VAG initiators and volumes when checking if in sync This prevents a permanent diff when the list of either initiators or volumes is sorted differently from what the API returns --- lib/puppet/type/solidfire_vag.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/puppet/type/solidfire_vag.rb b/lib/puppet/type/solidfire_vag.rb index 73dd4b4..6353be1 100644 --- a/lib/puppet/type/solidfire_vag.rb +++ b/lib/puppet/type/solidfire_vag.rb @@ -22,10 +22,18 @@ newproperty(:initiators, :array_matching => :all) do desc "List of initiators to include in the Volume Access Group" + + def insync?(is) + is.sort == should.sort + end end newproperty(:volumes, :array_matching => :all) do desc "List of Volume Names to include in the Volume Access Group" + + def insync?(is) + is.sort == should.sort + end end newproperty(:vagid) do From ec8a85cb72c769e6e60ba1e5b0830273b9df5322 Mon Sep 17 00:00:00 2001 From: Stephen Gelman Date: Wed, 1 May 2019 23:29:07 -0500 Subject: [PATCH 2/2] Improve readability of changes in VAG initiators and volumes Currently the puppet output when initiators or volumes change in a volume access group is a very hard to read output of an array. This changes it to only show what's different, making it much more readable. --- lib/puppet/type/solidfire_vag.rb | 46 ++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/lib/puppet/type/solidfire_vag.rb b/lib/puppet/type/solidfire_vag.rb index 6353be1..34642bf 100644 --- a/lib/puppet/type/solidfire_vag.rb +++ b/lib/puppet/type/solidfire_vag.rb @@ -26,6 +26,29 @@ def insync?(is) is.sort == should.sort end + + def change_to_s(currentvalue, newvalue) + currentvalue = if currentvalue == :absent || currentvalue.nil? + [] + else + currentvalue + end + newvalue = if newvalue == :absent + [] + else + newvalue + end + changes = [] + removing = currentvalue - newvalue + adding = newvalue - currentvalue + if removing != [] + changes << "Removing initiators: #{removing.join(',')}" + end + if adding != [] + changes << "Adding initiators: #{adding.join(',')}" + end + changes.join(' ') + end end newproperty(:volumes, :array_matching => :all) do @@ -34,6 +57,29 @@ def insync?(is) def insync?(is) is.sort == should.sort end + + def change_to_s(currentvalue, newvalue) + currentvalue = if currentvalue == :absent || currentvalue.nil? + [] + else + currentvalue + end + newvalue = if newvalue == :absent + [] + else + newvalue + end + changes = [] + removing = currentvalue - newvalue + adding = newvalue - currentvalue + if removing != [] + changes << "Removing volumes: #{removing.join(',')}" + end + if adding != [] + changes << "Adding volumes: #{adding.join(',')}" + end + changes.join(' ') + end end newproperty(:vagid) do