summaryrefslogtreecommitdiffstats
path: root/lib/puppet/type/zfs.rb
blob: 3a8806a5e8460d5e24135890f483edc11f252fc8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
module Puppet
    newtype(:zfs) do
        @doc = "Manage zfs. Create destroy and set properties on zfs instances."

        ensurable

        newparam(:name) do
            desc "The full name for this filesystem. (including the zpool)"
        end

        newproperty(:mountpoint) do
            desc "The mountpoint property."
        end

        newproperty(:compression) do
            desc "The compression property."
        end

        newproperty(:copies) do
            desc "The copies property."
        end

        newproperty(:quota) do
            desc "The quota property."
        end

        newproperty(:reservation) do
            desc "The reservation property."
        end

        newproperty(:sharenfs) do
            desc "The sharenfs property."
        end

        newproperty(:snapdir) do
            desc "The sharenfs property."
        end

        autorequire(:zpool) do
            #strip the zpool off the zfs name and autorequire it
            [@parameters[:name].value.split('/')[0]]
        end

        autorequire(:zfs) do
            #slice and dice, we want all the zfs before this one
            names = @parameters[:name].value.split('/')
            names.slice(1..-2).inject([]) { |a,v| a << "#{a.last}/#{v}" }.collect { |fs| names[0] + fs }
        end
    end
end