Hello All,

I am working on netapp puppet module enhancment present here 
https://github.com/puppetlabs/puppetlabs-netapp/

I have a doubt here regarding community acceptance to a thought flow.  


=============================================================================
I have got limitation of NETAPP API, i am using to interact with underlying 
system through my provider file.


I DO NOT have an available api "*to obtain state of all resources of this 
type from underlying system*."
Hence i do not have any way to populate my hash table in *self.instances()* 
function 
at all.
in result , "property hash" is not created properly.

*WorkAround*
I thought of a workaround, to set all properties as None in has and use 
name as @resource[:name]

  def self.instances
    Puppet.debug("Puppet::Provider::Netapp_snmp_community.cmode 
self.instances: Got to self.instances.")
    snmp_community_info = []
    snmp_community_info_hash = {
      :name           => @resource[:name]  >> for this particular resource
      :access_control => None,   >>>>>>>>>>>>>>>>.returning property as NOne
      :ensure         => :present
    }
    Puppet.debug("Puppet::Provider::Netapp_aggregate.cmode self.instances: 
aggr_info = #{snmp_community_info_hash}.")
    snmp_community_info << new(snmp_community_info_hash)
    Puppet.debug("Puppet:: returning instance .")
    snmp_community_info
  end

*But i guess in self.instances @resource[:name] is not accessible.*

*Alternative*
Finally i understood i can not use property hash in this situation.
I used just getter setter methods to code such case.
*getter method*
where AGAIN i do not have an API to obtain this resource properties from 
underlying system.

Hence i have implemented it this way.


===============================================================================
require_relative '../netapp_cmode'

Puppet::Type.type(:netapp_snmp_community_delete).provide(:cmode, :parent => 
Puppet::Provider::NetappCmode) do
  @doc = "Manage Netapp SNMP community [Family: vserver]"

  confine    :feature => :posix
  defaultfor :feature => :posix

  netapp_commands :snmpcommunitydelete    => 'snmp-community-delete'
  netapp_commands :snmpcommunitydeleteall => 'snmp-community-delete-all'



  def community_name 
    community_name = @resource[:community_name] + "1234"    >>>>>>>>>>>>>>> 
returning some value which will never be same as desired value asked in 
puppet manifest file
    community_name
  end


  def community_name=(value)
    if @resource[:community_name] == 'all'
      result = snmpcommunitydeleteall()
    else
      result = snmpcommunitydelete('access-control', 'ro', 'community', 
@resource[:community_name])
    end
  end
end

One more thing here .
There is no modify api at all 
And MUST requirement from this provider is to give delete capability.
*Hence i placed delete / deleteall in setter method !!!!!!!!!*

Here in setter method - i am calling delete or delete all 

*Result*
1) Its fulfilling my purpose well, expected goals i had are being met well.
2) But will such code be accepted by community ?
3) Or is there any other approach to handle such situation ?

Community opinion is most sought here please .. 

Thanks
Nidhi


-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/3970c465-1b56-4cdf-9c8d-d585448de620%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to