Skip to content

Commit

Permalink
Automatic update
Browse files Browse the repository at this point in the history
This module update commit was generated by Bade.
For more info please check https://github.com/paramite/bade

This commit is setting modules to following state:
pacemaker
 - old commit: 0ed9ee8a29c0f27e86727d415b39d2715332df7d
 - new commit: 52acfd9c31e0801cedf970929851d4bece5cf79b
  • Loading branch information
cwolferh committed Dec 4, 2014
1 parent 641576b commit a827f05
Show file tree
Hide file tree
Showing 67 changed files with 7,662 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Puppetfile
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ mod 'openstacklib',
:git => 'https://github.com/stackforge/puppet-openstacklib.git'

mod 'pacemaker',
:commit => '0ed9ee8a29c0f27e86727d415b39d2715332df7d',
:commit => '52acfd9c31e0801cedf970929851d4bece5cf79b',
:git => 'https://github.com/redhat-openstack/puppet-pacemaker.git'

mod 'puppet',
Expand Down
137 changes: 137 additions & 0 deletions pacemaker/agent_generator/agent_generator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
#!/usr/bin/ruby

# Usage:
#
# * install a fence agent package e.g. fence-agents-ilo2
# * fence_ilo2 -o metadata > ilo.xml
# * fence-generator.rb ilo.xml fence_ilo2 fence-agents-ilo2
# [ XML metadata, name of the class, name of the package for dependency check ]


require 'rexml/document'

class FencingMetadataParser
def initialize(filename, agentName, packageName)
@agentName = agentName
@packageName = packageName
file = File.new(filename)
@doc = REXML::Document.new file
end

def getPackageName()
return @packageName
end

def getAgentName()
return @agentName
end

def getParameters()
## result have to be array as order should be preserved
params = Array.new

@doc.elements.each("resource-agent/parameters/parameter") { |p|
param = Hash.new
param["name"] = REXML::XPath.match(p, "string(./@name)")[0]
param["type"] = REXML::XPath.match(p, "string(./content/@type)")[0]
## if 'default' is list then we can not enter it as parameter !!
## this is problem only for 'cmd_prompt'
param["default"] = REXML::XPath.match(p, "string(./content/@default)")[0]

## remove parameters that are not usable during automatic execution
if not ["help", "version", "action"].include?(param["name"])
params.push(param)
end
}
return params
end
end

class ManifestGenerator
def initialize(parser)
@parser = parser
end

def generate
puts <<-eos
# generated by agent_generator.rb, manual changes will be lost
class pacemaker::stonith::#{@parser.getAgentName} (
#{getManifestParameters}
) {
$real_address = "$(corosync-cfgtool -a $(crm_node -n))"
if($ensure == absent) {
exec {
"Removing stonith::#{@parser.getAgentName}":
command => "/usr/sbin/pcs stonith delete stonith-#{@parser.getAgentName}-${real_address}",
onlyif => "/usr/sbin/pcs stonith show stonith-#{@parser.getAgentName}-${real_address} > /dev/null 2>&1",
require => Class["pacemaker::corosync"],
}
} else {
#{getVariableValues}
$pcmk_host_value_chunk = $pcmk_host_list ? {
'' => '$(/usr/sbin/crm_node -n)',
default => "${pcmk_host_list}",
}
package {
"#{@parser.getPackageName}": ensure => installed,
} -> exec {
"Creating stonith::#{@parser.getAgentName}":
command => "/usr/sbin/pcs stonith create stonith-#{@parser.getAgentName}-${real_address} #{@parser.getAgentName} pcmk_host_list=\\"${pcmk_host_value_chunk}\\" #{getChunks} op monitor interval=${interval}",
unless => "/usr/sbin/pcs stonith show stonith-#{@parser.getAgentName}-${real_address} > /dev/null 2>&1",
require => Class["pacemaker::corosync"],
} -> exec {
"Adding non-local constraint stonith::#{@parser.getAgentName} ${real_address}":
command => "/usr/sbin/pcs constraint location stonith-#{@parser.getAgentName}-${real_address} avoids ${pcmk_host_value_chunk}"
}
}
}
eos
end

def getManifestParameters
text = ""
@parser.getParameters.each { |p|
text += "\t$#{p['name']} = undef,\n"
}

text += "\n"
text += "\t$interval = \"60s\",\n"
text += "\t$ensure = present,\n"
text += "\t$pcmk_host_value = undef,\n"

return text
end

def getVariableValues
text = ""
@parser.getParameters.each { |p|
text += "\t$#{p['name']}_chunk = $#{p['name']} ? {\n"
text += "\t\tundef => \"\",\n"
text += "\t\tdefault => \"#{p['name']}=\\\"${#{p['name']}}\\\"\",\n"
text += "\t}\n"
}

return text
end

def getChunks
text = ""
@parser.getParameters.each { |p|
text += "${#{p['name']}_chunk} "
}
return text
end
end

if ARGV.length != 3 then
puts "You have to enter three arguments: path to metadata, name of fence agent and fence agent package"
exit 1
end

metadata, agentName, packageName = ARGV
# e.g. parser = FencingMetadataParser.new("ilo.xml", "fence_ilo", "fence-agents-ilo2")
parser = FencingMetadataParser.new(metadata, agentName, packageName)
ManifestGenerator.new(parser).generate
17 changes: 17 additions & 0 deletions pacemaker/agent_generator/generate_manifests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

# This scripts generates fence agent manifests from their XML
# descriptions

set -exuo pipefail

generator_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

source "$generator_dir/variables.sh"

for cmd_pkg in "${cmd_pkg_map[@]}"; do
cmd=${cmd_pkg%%:*}
pkg=${cmd_pkg#*:}

"$generator_dir/agent_generator.rb" "$generator_dir/src_xml/$cmd.xml" $cmd $pkg > "$generator_dir/../manifests/stonith/$cmd.pp"
done
142 changes: 142 additions & 0 deletions pacemaker/agent_generator/src_xml/fence_apc.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
<?xml version="1.0" ?>
<resource-agent name="fence_apc" shortdesc="Fence agent for APC over telnet/ssh" >
<longdesc>fence_apc is an I/O Fencing agent which can be used with the APC network power switch. It logs into device via telnet/ssh and reboots a specified outlet. Lengthy telnet/ssh connections should be avoided while a GFS cluster is running because the connection will block any necessary fencing actions.</longdesc>
<vendor-url>http://www.apc.com</vendor-url>
<parameters>
<parameter name="ipaddr" unique="0" required="1">
<getopt mixed="-a, --ip=[ip]" />
<content type="string" />
<shortdesc lang="en">IP Address or Hostname</shortdesc>
</parameter>
<parameter name="login" unique="0" required="1">
<getopt mixed="-l, --username=[name]" />
<content type="string" />
<shortdesc lang="en">Login Name</shortdesc>
</parameter>
<parameter name="passwd" unique="0" required="0">
<getopt mixed="-p, --password=[password]" />
<content type="string" />
<shortdesc lang="en">Login password or passphrase</shortdesc>
</parameter>
<parameter name="cmd_prompt" unique="0" required="0">
<getopt mixed="-c, --command-prompt=[prompt]" />
<content type="string" default="[&apos;\n&gt;&apos;, &apos;\napc&gt;&apos;]" />
<shortdesc lang="en">Force Python regex for command prompt</shortdesc>
</parameter>
<parameter name="secure" unique="0" required="0">
<getopt mixed="-x, --ssh" />
<content type="boolean" />
<shortdesc lang="en">SSH connection</shortdesc>
</parameter>
<parameter name="port" unique="0" required="1">
<getopt mixed="-n, --plug=[id]" />
<content type="string" />
<shortdesc lang="en">Physical plug number, name of virtual machine or UUID</shortdesc>
</parameter>
<parameter name="switch" unique="0" required="0">
<getopt mixed="-s, --switch=[id]" />
<content type="string" />
<shortdesc lang="en">Physical switch number on device</shortdesc>
</parameter>
<parameter name="ipport" unique="0" required="0">
<getopt mixed="-u, --ipport=[port] TCP/UDP port to use
(default 23, 22 if --ssh" />
<content type="string" default="23" />
<shortdesc lang="en">TCP/UDP port to use for connection with device</shortdesc>
</parameter>
<parameter name="inet4_only" unique="0" required="0">
<getopt mixed="-4, --inet4-only" />
<content type="boolean" />
<shortdesc lang="en">Forces agent to use IPv4 addresses only</shortdesc>
</parameter>
<parameter name="inet6_only" unique="0" required="0">
<getopt mixed="-6, --inet6-only" />
<content type="boolean" />
<shortdesc lang="en">Forces agent to use IPv6 addresses only</shortdesc>
</parameter>
<parameter name="passwd_script" unique="0" required="0">
<getopt mixed="-S, --password-script=[script]" />
<content type="string" />
<shortdesc lang="en">Script to retrieve password</shortdesc>
</parameter>
<parameter name="identity_file" unique="0" required="0">
<getopt mixed="-k, --identity-file=[filename]" />
<content type="string" />
<shortdesc lang="en">Identity file for ssh</shortdesc>
</parameter>
<parameter name="ssh_options" unique="0" required="0">
<getopt mixed="--ssh-options=[options]" />
<content type="string" default="-1 -c blowfish" />
<shortdesc lang="en">SSH options to use</shortdesc>
</parameter>
<parameter name="action" unique="0" required="1">
<getopt mixed="-o, --action=[action]" />
<content type="string" default="reboot" />
<shortdesc lang="en">Fencing Action</shortdesc>
</parameter>
<parameter name="verbose" unique="0" required="0">
<getopt mixed="-v, --verbose" />
<content type="boolean" />
<shortdesc lang="en">Verbose mode</shortdesc>
</parameter>
<parameter name="debug" unique="0" required="0">
<getopt mixed="-D, --debug-file=[debugfile]" />
<content type="string" />
<shortdesc lang="en">Write debug information to given file</shortdesc>
</parameter>
<parameter name="version" unique="0" required="0">
<getopt mixed="-V, --version" />
<content type="boolean" />
<shortdesc lang="en">Display version information and exit</shortdesc>
</parameter>
<parameter name="help" unique="0" required="0">
<getopt mixed="-h, --help" />
<content type="boolean" />
<shortdesc lang="en">Display help and exit</shortdesc>
</parameter>
<parameter name="separator" unique="0" required="0">
<getopt mixed="-C, --separator=[char]" />
<content type="string" default="," />
<shortdesc lang="en">Separator for CSV created by operation list</shortdesc>
</parameter>
<parameter name="power_timeout" unique="0" required="0">
<getopt mixed="--power-timeout=[seconds]" />
<content type="string" default="20" />
<shortdesc lang="en">Test X seconds for status change after ON/OFF</shortdesc>
</parameter>
<parameter name="shell_timeout" unique="0" required="0">
<getopt mixed="--shell-timeout=[seconds]" />
<content type="string" default="3" />
<shortdesc lang="en">Wait X seconds for cmd prompt after issuing command</shortdesc>
</parameter>
<parameter name="login_timeout" unique="0" required="0">
<getopt mixed="--login-timeout=[seconds]" />
<content type="string" default="5" />
<shortdesc lang="en">Wait X seconds for cmd prompt after login</shortdesc>
</parameter>
<parameter name="power_wait" unique="0" required="0">
<getopt mixed="--power-wait=[seconds]" />
<content type="string" default="0" />
<shortdesc lang="en">Wait X seconds after issuing ON/OFF</shortdesc>
</parameter>
<parameter name="delay" unique="0" required="0">
<getopt mixed="--delay=[seconds]" />
<content type="string" default="0" />
<shortdesc lang="en">Wait X seconds before fencing is started</shortdesc>
</parameter>
<parameter name="retry_on" unique="0" required="0">
<getopt mixed="--retry-on=[attempts]" />
<content type="string" default="1" />
<shortdesc lang="en">Count of attempts to retry power on</shortdesc>
</parameter>
</parameters>
<actions>
<action name="on" automatic="0"/>
<action name="off" />
<action name="reboot" />
<action name="status" />
<action name="list" />
<action name="monitor" />
<action name="metadata" />
</actions>
</resource-agent>
Loading

0 comments on commit a827f05

Please sign in to comment.