diff options
author | James Turnbull <james@lovedthanlost.net> | 2008-02-28 13:30:33 +1100 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2008-02-28 13:30:33 +1100 |
commit | 62865e0dc921b3d81a89d59c387c3697f37a629c (patch) | |
tree | 6bf92f02574939b66ff2622a9b93c7b6c6529ecd | |
parent | 3b5daf77d4ab8da5d3ae9d20e86de8b79e74df2c (diff) | |
parent | bb8051bc406d1da67db8212e852bb36d1368e953 (diff) | |
download | puppet-62865e0dc921b3d81a89d59c387c3697f37a629c.tar.gz puppet-62865e0dc921b3d81a89d59c387c3697f37a629c.tar.xz puppet-62865e0dc921b3d81a89d59c387c3697f37a629c.zip |
Merge branch '0.24.x' of git://reductivelabs.com/puppet into 0.24.x
-rw-r--r-- | CHANGELOG | 6 | ||||
-rw-r--r-- | lib/puppet/provider/interface/redhat.rb | 130 | ||||
-rwxr-xr-x | lib/puppet/type/exec.rb | 5 | ||||
-rwxr-xr-x | lib/puppet/type/mailalias.rb | 2 | ||||
-rwxr-xr-x | test/ral/types/exec.rb | 4 |
5 files changed, 75 insertions, 72 deletions
@@ -1,3 +1,9 @@ + Removed the loglevels from the valid values for 'logoutput' + in the Exec resource type -- the log levels are specified + using the 'loglevel' parameter, not 'logoutput'. This never + worked, or at least hasn't for ages, and now the docs are + just correct. + Somewhat refactored fileserving so that it no longer caches any objects, nor does it use Puppet's RAL resources. In the process, I fixed #894 (you can now copy links) and refactored diff --git a/lib/puppet/provider/interface/redhat.rb b/lib/puppet/provider/interface/redhat.rb index aa217620e..4a9fcb491 100644 --- a/lib/puppet/provider/interface/redhat.rb +++ b/lib/puppet/provider/interface/redhat.rb @@ -5,7 +5,7 @@ Puppet::Type.type(:interface).provide(:redhat) do desc "Manage network interfaces on Red Hat operating systems. This provider parses and generates configuration files in ``/etc/sysconfig/network-scripts``." - INTERFACE_DIR = "/etc/sysconfig/network-scripts" + INTERFACE_DIR = "/etc/sysconfig/network-scripts" confine :exists => INTERFACE_DIR defaultfor :operatingsystem => [:fedora, :centos, :redhat] @@ -43,52 +43,52 @@ NETMASK=<%= self.netmask %> BROADCAST= LOOPBACKDUMMY - # maximum number of dummy interfaces - @max_dummies = 10 + # maximum number of dummy interfaces + @max_dummies = 10 - # maximum number of aliases per interface - @max_aliases_per_iface = 10 + # maximum number of aliases per interface + @max_aliases_per_iface = 10 - @@dummies = [] - @@aliases = Hash.new { |hash, key| hash[key] = [] } + @@dummies = [] + @@aliases = Hash.new { |hash, key| hash[key] = [] } - # calculate which dummy interfaces are currently already in - # use prior to needing to call self.next_dummy later on. - def self.instances - # parse all of the config files at once - Dir.glob("%s/ifcfg-*" % INTERFACE_DIR).collect do |file| - record = parse(file) + # calculate which dummy interfaces are currently already in + # use prior to needing to call self.next_dummy later on. + def self.instances + # parse all of the config files at once + Dir.glob("%s/ifcfg-*" % INTERFACE_DIR).collect do |file| + record = parse(file) - # store the existing dummy interfaces + # store the existing dummy interfaces @@dummies << record[:ifnum] if (record[:interface_type] == :dummy and ! @@dummies.include?(record[:ifnum])) @@aliases[record[:interface]] << record[:ifnum] if record[:interface_type] == :alias new(record) - end - end - - # return the next avaliable dummy interface number, in the case where - # ifnum is not manually specified - def self.next_dummy - @max_dummies.times do |i| - unless @@dummies.include?(i.to_s) - @@dummies << i.to_s - return i.to_s - end - end - end - - # return the next available alias on a given interface, in the case - # where ifnum if not manually specified - def self.next_alias(interface) - @max_aliases_per_iface.times do |i| - unless @@aliases[interface].include?(i.to_s) - @@aliases[interface] << i.to_s - return i.to_s - end - end - end + end + end + + # return the next avaliable dummy interface number, in the case where + # ifnum is not manually specified + def self.next_dummy + @max_dummies.times do |i| + unless @@dummies.include?(i.to_s) + @@dummies << i.to_s + return i.to_s + end + end + end + + # return the next available alias on a given interface, in the case + # where ifnum if not manually specified + def self.next_alias(interface) + @max_aliases_per_iface.times do |i| + unless @@aliases[interface].include?(i.to_s) + @@aliases[interface] << i.to_s + return i.to_s + end + end + end # base the ifnum, for dummy / loopback interface in linux # on the last octect of the IP address @@ -139,14 +139,14 @@ LOOPBACKDUMMY # on whether we are adding an alias to a real interface, or a loopback # address (also dummy) on linux. For linux it's quite involved, and we # will use an ERB template - def generate + def generate itype = self.interface_type == :alias ? :alias : :normal self.class.template(itype).result(binding) - end + end # Where should the file be written out? - # This defaults to INTERFACE_DIR/ifcfg-<namevar>, but can have a - # more symbolic name by setting interface_desc in the type. + # This defaults to INTERFACE_DIR/ifcfg-<namevar>, but can have a + # more symbolic name by setting interface_desc in the type. def file_path if resource and val = resource[:interface_desc] desc = val @@ -185,16 +185,16 @@ LOOPBACKDUMMY end end - # create the device name, so this based on the IP, and interface + type - def device - case @resource.should(:interface_type) - when :loopback - @property_hash[:ifnum] ||= self.class.next_dummy - return "dummy" + @property_hash[:ifnum] - when :alias - @property_hash[:ifnum] ||= self.class.next_alias(@resource[:interface]) - return @resource[:interface] + ":" + @property_hash[:ifnum] - end + # create the device name, so this based on the IP, and interface + type + def device + case @resource.should(:interface_type) + when :loopback + @property_hash[:ifnum] ||= self.class.next_dummy + return "dummy" + @property_hash[:ifnum] + when :alias + @property_hash[:ifnum] ||= self.class.next_alias(@resource[:interface]) + return @resource[:interface] + ":" + @property_hash[:ifnum] + end end # Set the name to our ip address. @@ -202,19 +202,19 @@ LOOPBACKDUMMY @property_hash[:name] = value end - # whether the device is to be brought up on boot or not. converts - # the true / false of the type, into yes / no values respectively - # writing out the ifcfg-* files - def on_boot - case @property_hash[:onboot].to_s - when "true" - return "yes" - when "false" - return "no" - else - return "neither" - end - end + # whether the device is to be brought up on boot or not. converts + # the true / false of the type, into yes / no values respectively + # writing out the ifcfg-* files + def on_boot + case @property_hash[:onboot].to_s + when "true" + return "yes" + when "false" + return "no" + else + return "neither" + end + end # Mark whether the interface should be started on boot. def on_boot=(value) diff --git a/lib/puppet/type/exec.rb b/lib/puppet/type/exec.rb index f8049236f..2772b54a8 100755 --- a/lib/puppet/type/exec.rb +++ b/lib/puppet/type/exec.rb @@ -211,10 +211,7 @@ module Puppet log the output when the command reports an error. Values are **true**, *false*, *on_failure*, and any legal log level." - values = [:true, :false, :on_failure] - # And all of the log levels - Puppet::Util::Log.eachlevel { |level| values << level } - newvalues(*values) + newvalues(:true, :false, :on_failure) end newparam(:refresh) do diff --git a/lib/puppet/type/mailalias.rb b/lib/puppet/type/mailalias.rb index 92f609267..50ca26ef6 100755 --- a/lib/puppet/type/mailalias.rb +++ b/lib/puppet/type/mailalias.rb @@ -9,7 +9,7 @@ module Puppet end newproperty(:recipient, :array_matching => :all) do - desc "Where email should should be sent. Multiple values + desc "Where email should be sent. Multiple values should be specified as an array." def is_to_s(value) diff --git a/test/ral/types/exec.rb b/test/ral/types/exec.rb index 4133d8519..e2a3dd9ed 100755 --- a/test/ral/types/exec.rb +++ b/test/ral/types/exec.rb @@ -394,8 +394,8 @@ class TestExec < Test::Unit::TestCase assert_apply(exec) assert_nothing_raised { - exec[:command] = "echo logoutput is warning" - exec[:logoutput] = "warning" + exec[:command] = "echo logoutput is on_failure" + exec[:logoutput] = "on_failure" } assert_apply(exec) |