Quick question about types/providers

74 views
Skip to first unread message

Peter Berghold

unread,
Feb 27, 2015, 11:02:20 AM2/27/15
to puppet-users
Using the example of the file provider that is bundled with puppet here is a sniglet of code that I've zoomed in on:

 def mode
    if stat = resource.stat
      return (stat.mode & 007777).to_s(8)
    else
      return :absent
    end
  end

  def mode=(value)
    begin
      File.chmod(value.to_i(8), resource[:path])
    rescue => detail
      error = Puppet::Error.new("failed to set mode #{mode} on #{resource[:path]}: #{detail.message}")
      error.set_backtrace detail.backtrace
      raise error
    end
  end

can I guess that the first def mod is what is referred to as a "getter" and second is a "setter?"    Can I stretch that inference to say that if the value being passed to the setter is the same as what the getter is seeing it won't be set again?


Felix Frank

unread,
Feb 27, 2015, 11:08:59 AM2/27/15
to puppet...@googlegroups.com
On 02/27/2015 05:02 PM, Peter Berghold wrote:
> can I guess that the first def mod is what is referred to as a "getter"
> and second is a "setter?" Can I stretch that inference to say that if
> the value being passed to the setter is the same as what the getter is
> seeing it won't be set again?
>

Yes, this is basically a getter/setter pair.

However, the idempotency is implemented closer to the type layer. The
transaction code will check whether properties are out of sync, and
invoke the provider "=" methods to take action if necessary.

On this higher level, your assertion should hold true. But I'm not sure
if that's what you were asking.

HTH,
Felix

Peter Berghold

unread,
Feb 27, 2015, 11:14:05 AM2/27/15
to puppet...@googlegroups.com
that's exactly what I was after.  Since this is my first type/provider pair I'm proceeding cautiously. 

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/54F09689.7070607%40alumni.tu-berlin.de.
For more options, visit https://groups.google.com/d/optout.

Trevor Vaughan

unread,
Feb 27, 2015, 12:25:54 PM2/27/15
to puppet...@googlegroups.com

To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/CAArvnv0FwW2wFqye_VU_LRX4yyFD4yu0O6VVVDQOQ0Q9Yxi3Tg%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.



--
Trevor Vaughan
Vice President, Onyx Point, Inc
(410) 541-6699
tvau...@onyxpoint.com

-- This account not approved for unencrypted proprietary information --

Peter Berghold

unread,
Feb 27, 2015, 2:22:17 PM2/27/15
to puppet...@googlegroups.com
So, I wrote my type and its provider.

Have a bunch of params and of course the first one I try to use
  newparam(:ipv4listen) do
    desc "the ipv4listen param"
  end

doesn't seem to be seen by the Puppet infrastructure.  

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Invalid parameter ipv4listen on Bindconfigure[MOB_OAM_SVC] at /etc/puppet/environments/POC/modules/multibind/manifests/mob_oam_svc.pp:22 on node CLIENT
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

So obviously I'm missing something here...

Thoughts?   Wish there was an equivalent to Perl's Data::Dumper that would let me see what parameters Puppet things are defined.


Peter Berghold

unread,
Feb 27, 2015, 3:22:45 PM2/27/15
to puppet...@googlegroups.com
I think I discovered something, correct me if I'm in the weeds with this.  

Seems certain patterns cannot be used as parameters for a type.   So far on my list

version  
ipv4listen
rndcport

that last one baffles me.

bindconfigure { $mypersonality:
    #  ipv4listen=>"any",
      ipv6listen=>"any",
      # rndcport=>"951",
      statsport=>"8080",
      named=>'-n 2',
      ztp=>"no",
      m_notify=>"no",
      transfer=>"none",
      version=>'9.9.5-S1',
      state=>"on",
      notify=> Service['named-all']

    }
 anybody see anything objectionable here?



For more options, visit https://groups.google.com/d/optout.



--
Trevor Vaughan
Vice President, Onyx Point, Inc
(410) 541-6699
tvau...@onyxpoint.com

-- This account not approved for unencrypted proprietary information --

--
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+unsubscribe@googlegroups.com.

Felix Frank

unread,
Mar 1, 2015, 2:58:57 PM3/1/15
to puppet...@googlegroups.com
Can you make your code available somewhere, so that we can reproduce?

Generally, I'd like to second John's general advice: Do restart your
Puppet processes to make sure that changes to your Ruby code take effect.

Best,
Felix

Peter Berghold

unread,
Mar 2, 2015, 11:26:05 AM3/2/15
to puppet...@googlegroups.com
Turned out restarting the puppet master was the solution.  Drove me insane for a while, but now all but a couple of things have started to work.  I've posted about one of them in a separate thread.

--
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+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages