summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-11-12 21:25:13 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-11-12 21:25:13 +0000
commit4d5f70f017c744229ea83cda03c2c4334a010d1d (patch)
tree54985b8c5f9412efdaa956b5919dd69afd363e7a /lib/puppet
parentbd169b44a0ce58413fb5b031c3f12cd4ca6f4cbe (diff)
downloadpuppet-4d5f70f017c744229ea83cda03c2c4334a010d1d.tar.gz
puppet-4d5f70f017c744229ea83cda03c2c4334a010d1d.tar.xz
puppet-4d5f70f017c744229ea83cda03c2c4334a010d1d.zip
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')
-rw-r--r--lib/puppet/metatype/providers.rb11
-rw-r--r--lib/puppet/provider/mount.rb39
-rw-r--r--lib/puppet/provider/mount/netinfo.rb37
-rwxr-xr-xlib/puppet/provider/mount/parsed.rb32
-rw-r--r--lib/puppet/provider/nameservice.rb4
-rw-r--r--lib/puppet/provider/nameservice/netinfo.rb5
-rwxr-xr-xlib/puppet/type/group.rb2
-rwxr-xr-xlib/puppet/type/mount.rb7
8 files changed, 97 insertions, 40 deletions
diff --git a/lib/puppet/metatype/providers.rb b/lib/puppet/metatype/providers.rb
index 0165da83e..04de20732 100644
--- a/lib/puppet/metatype/providers.rb
+++ b/lib/puppet/metatype/providers.rb
@@ -44,7 +44,7 @@ class Puppet::Type
# Convert a hash, as provided by, um, a provider, into an instance of self.
def self.hash2obj(hash)
obj = nil
-
+
namevar = self.namevar
unless hash.include?(namevar) and hash[namevar]
raise Puppet::DevError, "Hash was not passed with namevar"
@@ -93,7 +93,14 @@ class Puppet::Type
suitableprovider.find_all { |p| p.respond_to?(:list) }.collect { |prov|
prov.list.each { |h| h[:provider] = prov.name }
}.flatten.collect do |hash|
- hash2obj(hash)
+ if hash.is_a?(Hash)
+ hash2obj(hash)
+ elsif hash.is_a?(self)
+ hash
+ else
+ raise Puppet::DevError, "Provider %s returned object of type %s in list" %
+ [prov.name, hash.class]
+ end
end
end
end
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(",")]
diff --git a/lib/puppet/type/group.rb b/lib/puppet/type/group.rb
index aa982c247..d68d03515 100755
--- a/lib/puppet/type/group.rb
+++ b/lib/puppet/type/group.rb
@@ -89,7 +89,7 @@ module Puppet
end
# Set ourselves to whatever our should value is.
- self.set
+ self.set(self.should)
end
end
diff --git a/lib/puppet/type/mount.rb b/lib/puppet/type/mount.rb
index a6be65ae6..517f52632 100755
--- a/lib/puppet/type/mount.rb
+++ b/lib/puppet/type/mount.rb
@@ -116,7 +116,12 @@ module Puppet
desc "The file in which to store the mount table. Only used by
those providers that write to disk (i.e., not NetInfo)."
- defaultto { @parent.class.defaultprovider.default_target }
+ defaultto { if @parent.class.defaultprovider.ancestors.include?(Puppet::Provider::ParsedFile)
+ @parent.class.defaultprovider.default_target
+ else
+ nil
+ end
+ }
end
newparam(:name) do