On Mon, Feb 15, 2010 at 9:30 AM, Daniel Kerwin <d.k3r...@googlemail.com> wrote: > Hi list, > > i tried to write my first type and provider that should create logical > volumes. Seems like i'm missing something as i get nothing when i use > it: No errors and no logical volume :-(
This might be better for puppet-dev. It looks to me like you need to provide some properties, not just parameters, in your type. > > type/logicalvolume.rb: > ================= > > Puppet::Type.newtype(:logicalvolume) do > �...@doc = "Manage logical volumes" > > ensurable > > newparam(:lvname) do > desc "The logcal volume's name" > > validate do |value| > unless value =~ /^[a-z0-9]+/ > raise ArgumentError , "%s is not a valid lv name" % > value > end > end > > isnamevar > > end > > newparam(:size) do > desc "The size in M or G" > > validate do |value| > unless value =~ /^[0-9]+[MG]/ > raise ArgumentError , "%s is not a valid lv size" % > value > end > end > end > > newparam(:vg) do > desc "The volumevg to create the volume in" > > validate do |value| > unless value =~ /^[a-z0-9]+/ > raise ArgumentError , "%s is not a valid lv name" % > value > end > end > end > end > > provider/logicalvolume/logicalvolume.rb > =============================== > > Puppet::Type.type(:logicalvolume).provide(:logicalvolume) do > desc "LogicalVolume management" > > commands :lvcreate => "lvcreate" > > def create > lvcreate "-L", resource[:size], "-n", resource[:name], > resource[:vg] > end > > def destroy > return true > end > > def exists? > return nil > end So this should return true or false. If exists? is false and ensure is present, then create will be called. If exists? is true and ensure is absent, then destroy will be called. if you make size and vg properties rather than parameters, then: a method called 'size' will be called to determine the current size a method called 'size=' will be called to set the current size if the desired and current size values differ. a method called 'vg' will be called to determine the current vg a method called 'vg=' will be called to set the current vg if the desired and current vg values differ. Does that make more sense? > end > > Test class Bozo > ============= > > class bozo { > > logicalvolume { "test01lv": > size => "100M", > vg => "datavg", > #provider => "logicalvolume", > } > > file { "/tmp/lvtest": > content => "aaa", > } > } > > The file is created and no notice about the volume. I checken my type > and provider and it seems to be ok: > > ruby -rpuppet type/logicalvolume.rb > ruby -rpuppet provider/logicalvolume/logicalvolume.rb > > It's my first try and it may be obvious to you but i just don't get > it. > > Thanks, > > Daniel > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To post to this group, send email to puppet-us...@googlegroups.com. > To unsubscribe from this group, send email to > puppet-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. > > -- nigel -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-us...@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.