diff options
author | Luke Kanies <luke@madstop.com> | 2008-02-28 13:58:56 -0600 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2008-02-28 13:58:56 -0600 |
commit | 614ab9fcc33a7c4abffc0b407335f4a713f2fabd (patch) | |
tree | 748c9275f876a3c4938c46c773f23a02119b5525 | |
parent | bb8051bc406d1da67db8212e852bb36d1368e953 (diff) | |
download | puppet-614ab9fcc33a7c4abffc0b407335f4a713f2fabd.tar.gz puppet-614ab9fcc33a7c4abffc0b407335f4a713f2fabd.tar.xz puppet-614ab9fcc33a7c4abffc0b407335f4a713f2fabd.zip |
Adding a 'control' parameter to services, for those
service types that need a control variable to enable/disable.
-rw-r--r-- | lib/puppet/type/service.rb | 9 | ||||
-rwxr-xr-x | spec/unit/ral/types/service.rb | 15 |
2 files changed, 20 insertions, 4 deletions
diff --git a/lib/puppet/type/service.rb b/lib/puppet/type/service.rb index c41a7883b..1b625cc41 100644 --- a/lib/puppet/type/service.rb +++ b/lib/puppet/type/service.rb @@ -28,6 +28,8 @@ module Puppet feature :enableable, "The provider can enable and disable the service", :methods => [:disable, :enable, :enabled?] + feature :controllable, "The provider uses a control variable." + newproperty(:enable, :required_features => :enableable) do desc "Whether a service should be enabled to start at boot. This property behaves quite differently depending on the platform; @@ -163,6 +165,13 @@ module Puppet desc "Specify a *stop* command manually." end + newparam(:control) do + desc "The control variable used to manage services (originally for HP-UX). + Defaults to the upcased service name plus ``START`` replacing dots with + underscores, for those providers that support the ``controllable`` feature." + defaultto { resource.name.gsub(".","_").upcase + "_START" if resource.provider.controllable? } + end + newparam :hasrestart do desc "Specify that an init script has a ``restart`` option. Otherwise, the init script's ``stop`` and ``start`` methods are used." diff --git a/spec/unit/ral/types/service.rb b/spec/unit/ral/types/service.rb index 981d38a15..0f00992fa 100755 --- a/spec/unit/ral/types/service.rb +++ b/spec/unit/ral/types/service.rb @@ -15,7 +15,7 @@ describe Puppet::Type::Service do end describe Puppet::Type::Service, "when validating attributes" do - [:name, :binary, :hasstatus, :path, :pattern, :start, :restart, :stop, :status, :hasrestart].each do |param| + [:name, :binary, :hasstatus, :path, :pattern, :start, :restart, :stop, :status, :hasrestart, :control].each do |param| it "should have a #{param} parameter" do Puppet::Type::Service.attrtype(param).should == :param end @@ -30,7 +30,7 @@ end describe Puppet::Type::Service, "when validating attribute values" do before do - @provider = stub 'provider', :class => Puppet::Type::Service.defaultprovider, :clear => nil + @provider = stub 'provider', :class => Puppet::Type::Service.defaultprovider, :clear => nil, :controllable? => false Puppet::Type::Service.defaultprovider.stubs(:new).returns(@provider) end @@ -132,16 +132,23 @@ describe Puppet::Type::Service, "when setting default attribute values" do svc[:path].should == ["testing"] end - it "should default to the binary for the pattern if one is provided" do + it "should default 'pattern' to the binary if one is provided" do svc = Puppet::Type::Service.create(:name => "other", :binary => "/some/binary") svc[:pattern].should == "/some/binary" end - it "should default to the name for the pattern if no pattern is provided" do + it "should default 'pattern' to the name if no pattern is provided" do svc = Puppet::Type::Service.create(:name => "other") svc[:pattern].should == "other" end + it "should default 'control' to the upcased service name with periods replaced by underscores if the provider supports the 'controllable' feature" do + provider = stub 'provider', :controllable? => true, :class => Puppet::Type::Service.defaultprovider, :clear => nil + Puppet::Type::Service.defaultprovider.stubs(:new).returns(provider) + svc = Puppet::Type::Service.create(:name => "nfs.client") + svc[:control].should == "NFS_CLIENT_START" + end + after { Puppet::Type::Service.clear } end |