diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-08-05 19:01:39 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-08-05 19:01:39 +0000 |
commit | 22e7b390878769e2079b5bbd5f10ab152b4b921d (patch) | |
tree | 0a2c0931e2b755de86234de386485345118beb54 /lib/puppet/provider/interface/sunos.rb | |
parent | 7bda32e9fbb6fb63c5f33fa839f03cc305c2b449 (diff) | |
download | puppet-22e7b390878769e2079b5bbd5f10ab152b4b921d.tar.gz puppet-22e7b390878769e2079b5bbd5f10ab152b4b921d.tar.xz puppet-22e7b390878769e2079b5bbd5f10ab152b4b921d.zip |
Fixing #751 -- the interface providers now have basic tests, at least to verify that prefetching and listing works. I think these resource types need to be largely rewritten, though, and they currently have no relationship to ifconfig, which seems strange.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2747 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/provider/interface/sunos.rb')
-rw-r--r-- | lib/puppet/provider/interface/sunos.rb | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/lib/puppet/provider/interface/sunos.rb b/lib/puppet/provider/interface/sunos.rb index 0290aa209..abe9dd8c6 100644 --- a/lib/puppet/provider/interface/sunos.rb +++ b/lib/puppet/provider/interface/sunos.rb @@ -12,10 +12,7 @@ Puppet::Type.type(:interface).provide(:sunos, # Two types of lines: # the first line does not start with 'addif' # the rest do - - record_line :sunos, :fields => %w{interface_type name ifopts onboot}, :rts => true, :absent => "", :block_eval => :instance do - # Parse our interface line def process(line) details = {:ensure => :present} @@ -80,6 +77,14 @@ Puppet::Type.type(:interface).provide(:sunos, %{} end + # Get a list of interface instances. + def self.instances + Dir.glob("/etc/hostname.*").collect do |file| + # We really only expect one record from each file + parse(file).shift + end.collect { |record| new(record) } + end + def self.match(hash) # see if we can match the has against an existing object if model.find { |obj| obj.value(:name) == hash[:name] } @@ -89,10 +94,22 @@ Puppet::Type.type(:interface).provide(:sunos, end end + # Prefetch our interface list, yo. + def self.prefetch(resources) + instances.each do |prov| + if resource = resources[prov.name] + resource.provider = prov + end + end + end + # Where should the file be written out? Can be overridden by setting # :target in the model. def file_path - return File.join("/etc", "hostname." + @model[:interface]) + unless @resource[:interface] + raise ArgumentError, "You must provide the interface name on Solaris" + end + return File.join("/etc", "hostname." + @resource[:interface]) end end |