diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-11-12 21:25:13 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-11-12 21:25:13 +0000 |
| commit | 4d5f70f017c744229ea83cda03c2c4334a010d1d (patch) | |
| tree | 54985b8c5f9412efdaa956b5919dd69afd363e7a /lib/puppet/provider | |
| parent | bd169b44a0ce58413fb5b031c3f12cd4ca6f4cbe (diff) | |
Trying to get a netinfo provider for mounts working, but i give up. I am leaving it in place but marked as highly experimental.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1860 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/provider')
| -rw-r--r-- | lib/puppet/provider/mount.rb | 39 | ||||
| -rw-r--r-- | lib/puppet/provider/mount/netinfo.rb | 37 | ||||
| -rwxr-xr-x | lib/puppet/provider/mount/parsed.rb | 32 | ||||
| -rw-r--r-- | lib/puppet/provider/nameservice.rb | 4 | ||||
| -rw-r--r-- | lib/puppet/provider/nameservice/netinfo.rb | 5 |
5 files changed, 81 insertions, 36 deletions
diff --git a/lib/puppet/provider/mount.rb b/lib/puppet/provider/mount.rb new file mode 100644 index 000000000..d3597ef15 --- /dev/null +++ b/lib/puppet/provider/mount.rb @@ -0,0 +1,39 @@ +# Created by Luke Kanies on 2006-11-12. +# Copyright (c) 2006. All rights reserved. + +require 'puppet' + +# A module just to store the mount/unmount methods. Individual providers +# still need to add the mount commands manually. +module Puppet::Provider::Mount + # This only works when the mount point is synced to the fstab. + def mount + mountcmd @model[:name] + end + + # This only works when the mount point is synced to the fstab. + def unmount + umount @model[:name] + end + + # Is the mount currently mounted? + def mounted? + platform = Facter["operatingsystem"].value + df = command(:df) + case Facter["operatingsystem"].value + # Solaris's df prints in a very weird format + when "Solaris": df = "#{command(:df)} -k" + end + %x{#{df}}.split("\n").find do |line| + fs = line.split(/\s+/)[-1] + if platform == "Darwin" + fs == "/private/var/automount" + @model[:name] or + fs == @model[:name] + else + fs == @model[:name] + end + end + end +end + +# $Id$
\ No newline at end of file diff --git a/lib/puppet/provider/mount/netinfo.rb b/lib/puppet/provider/mount/netinfo.rb new file mode 100644 index 000000000..4f39dfbdf --- /dev/null +++ b/lib/puppet/provider/mount/netinfo.rb @@ -0,0 +1,37 @@ +# Manage NetInfo POSIX objects. Probably only used on OS X, but I suppose +# it could be used elsewhere. +require 'puppet/provider/nameservice/netinfo' +require 'puppet/provider/mount' + +Puppet::Type.type(:mount).provide :netinfo, :parent => Puppet::Provider::NameService::NetInfo do + include Puppet::Provider::Mount + desc "Mount management in NetInfo. This provider is highly experimental and is known + not to work currently." + commands :nireport => "nireport", :niutil => "niutil" + commands :mountcmd => "mount", :umount => "umount", :df => "df" + + options :device, :key => "name" + options :name, :key => "dir" + options :dump, :key => "dump_freq" + options :pass, :key => "passno" + options :fstype, :key => "vfstype" + options :options, :key => "opts" + + defaultfor :operatingsystem => :darwin + + def initialize(model) + warning "The NetInfo mount provider is highly experimental. Use at your own risk." + end + + def mount + cmd = [] + if opts = @model.should(:options) + cmd << opts + end + cmd << @model.should(:device) + cmd << @model[:name] + mountcmd cmd.join(" ") + end +end + +# $Id$ diff --git a/lib/puppet/provider/mount/parsed.rb b/lib/puppet/provider/mount/parsed.rb index af67ca6ff..106d624bf 100755 --- a/lib/puppet/provider/mount/parsed.rb +++ b/lib/puppet/provider/mount/parsed.rb @@ -1,4 +1,5 @@ require 'puppet/provider/parsedfile' +require 'puppet/provider/mount' fstab = nil case Facter.value(:operatingsystem) @@ -12,6 +13,8 @@ Puppet::Type.type(:mount).provide(:parsed, :default_target => fstab, :filetype => :flat ) do + include Puppet::Provider::Mount + confine :exists => fstab commands :mountcmd => "mount", :umount => "umount", :df => "df" @@ -29,35 +32,6 @@ Puppet::Type.type(:mount).provide(:parsed, text_line :blank, :match => /^\s*$/ record_line self.name, :fields => @fields, :separator => /\s+/, :joiner => "\t" - - # This only works when the mount point is synced to the fstab. - def mount - mountcmd @model[:name] - end - - # This only works when the mount point is synced to the fstab. - def unmount - umount @model[:name] - end - - # Is the mount currently mounted? - def mounted? - platform = Facter["operatingsystem"].value - df = command(:df) - case Facter["operatingsystem"].value - # Solaris's df prints in a very weird format - when "Solaris": df = "#{command(:df)} -k" - end - %x{#{df}}.split("\n").find do |line| - fs = line.split(/\s+/)[-1] - if platform == "Darwin" - fs == "/private/var/automount" + @model[:name] or - fs == @model[:name] - else - fs == @model[:name] - end - end - end end # $Id$ diff --git a/lib/puppet/provider/nameservice.rb b/lib/puppet/provider/nameservice.rb index 5565de23a..d33ab1936 100644 --- a/lib/puppet/provider/nameservice.rb +++ b/lib/puppet/provider/nameservice.rb @@ -37,8 +37,8 @@ class Puppet::Provider::NameService < Puppet::Provider end def options(name, hash) - unless model.validstate?(name) - raise Puppet::DevError, "%s is not a valid state for %s" % + unless model.validattr?(name) + raise Puppet::DevError, "%s is not a valid attribute for %s" % [name, model.name] end @options ||= {} diff --git a/lib/puppet/provider/nameservice/netinfo.rb b/lib/puppet/provider/nameservice/netinfo.rb index f6822b087..00d1e4478 100644 --- a/lib/puppet/provider/nameservice/netinfo.rb +++ b/lib/puppet/provider/nameservice/netinfo.rb @@ -184,11 +184,6 @@ class NetInfo < Puppet::Provider::NameService return nil end - def retrieve - raise "wtf?" - @is = report() || :absent - end - def setuserlist(group, list) cmd = "#{command(:niutil)} -createprop / /groups/%s users %s" % [group, list.join(",")] |
