Skip to content

Commit

Permalink
Initial Pacemaker primitive native type
Browse files Browse the repository at this point in the history
  • Loading branch information
rodjek committed May 16, 2010
1 parent d926e73 commit bc49a18
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
24 changes: 24 additions & 0 deletions lib/puppet/provider/ha_crm_primitive/crm.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
require 'rexml/document'

Puppet::Type.type(:ha_crm_primitive).provide(:crm) do
desc "CRM shell support"

commands :crm => "crm"

def create
crm "configure", "primitive", resource[:id], "#{resource[:class]}:#{resource[:type]}"
end

def destroy
crm "configure", "delete", resource[:id]
end

def exists?
cib_file = File.open("/var/lib/heartbeat/crm/cib.xml")
cib = REXML::Document.new cib_file

resource = REXML::XPath.first(cib, "//cib/configuration/resources/primitive[@id='#{resource[:id]}']")

!resource.nil?
end
end
25 changes: 25 additions & 0 deletions lib/puppet/type/ha_crm_primitive.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Puppet::Type.newtype(:ha_crm_primitive) do
@doc = "Manage Pacemaker primitives"

ensureable

newparam(:class) do
desc "The standard that the script conforms to."

validate do |value|
unless value =~ /^(heartbeat|lsb|ocf|stonith)$/ do
raise ArgumentError, "%s is not a valid Resource Agent class" % value
end
end
end

newparam(:type) do
desc "The name of the Resource Agent you with to use. eg. IPAddr or Filesystem"
end

newparam(:id) do
desc "The name of the resource"

isnamevar
end
end

0 comments on commit bc49a18

Please sign in to comment.