Merge "Support native OS primitive classes in Pacemaker"

This commit is contained in:
Jenkins 2015-01-23 16:58:08 +00:00 committed by Gerrit Code Review
commit bb3438c0be
3 changed files with 22 additions and 2 deletions

View File

@ -296,6 +296,14 @@ class Puppet::Provider::Pacemaker_common < Puppet::Provider
primitives[primitive]['parent']['type'] == 'master'
end
# return primitive class
# @param primitive [String] primitive id
# @return [String]
def primitive_class(primitive)
return unless primitive_exists? primitive
primitives[primitive]['class']
end
# disable this primitive
# @param primitive [String]
def disable_primitive(primitive)

View File

@ -186,8 +186,12 @@ Puppet::Type.type(:service).provide :pacemaker, :parent => Puppet::Provider::Pac
Puppet.info "Basic service '#{extra_provider.name}' is disabled as reported by '#{extra_provider.class.name}' provider"
end
if extra_provider.status == :running
Puppet.info "Stop basic service '#{extra_provider.name}' using provider '#{extra_provider.class.name}'"
extra_provider.stop
if not ['lsb','systemd','upstart'].include?(primitive_class name)
Puppet.info "Stop basic service '#{extra_provider.name}' using provider '#{extra_provider.class.name}'"
extra_provider.stop
else
Puppet.info "Not stopping basic service '#{extra_provider.name}', since its Pacemaker primitive is using primitive_class '#{extra_provider.class.name}'"
end
else
Puppet.info "Basic service '#{extra_provider.name}' is stopped as reported by '#{extra_provider.class.name}' provider"
end

View File

@ -8,6 +8,7 @@ describe Puppet::Type.type(:service).provider(:pacemaker) do
let(:full_name) { 'clone-p_myservice' }
let(:name) { 'p_myservice' }
let(:hostname) { 'mynode' }
let(:primitive_class) { 'ocf' }
before :each do
@class = provider
@ -17,6 +18,7 @@ describe Puppet::Type.type(:service).provider(:pacemaker) do
@class.stubs(:name).returns(name)
@class.stubs(:full_name).returns(full_name)
@class.stubs(:basic_service_name).returns(title)
@class.stubs(:primitive_class).returns(primitive_class)
@class.stubs(:cib_reset).returns(true)
@ -221,6 +223,12 @@ describe Puppet::Type.type(:service).provider(:pacemaker) do
@class.extra_provider.expects(:stop)
@class.disable_basic_service
end
it 'does not try to stop a systemd running service' do
@class.stubs(:primitive_class).returns('systemd')
@class.extra_provider.expects(:stop).never
@class.disable_basic_service
end
end
end