Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:12.3
pssh
pssh_pcmk_nodes.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File pssh_pcmk_nodes.patch of Package pssh
commit 9341f843f7eff49da9e909b9b0c87c9d5396155e Author: Dejan Muhamedagic <dejan@suse.de> Date: Mon Aug 15 14:24:35 2011 +0200 add -C/--pcmk_nodes option to get list of nodes from Pacemaker diff --git a/bin/pnuke b/bin/pnuke index 2b4feb5..a0eabdc 100755 --- a/bin/pnuke +++ b/bin/pnuke @@ -40,7 +40,7 @@ def parse_args(): if len(args) > 1: parser.error('Extra arguments given after the pattern.') - if not opts.host_files and not opts.host_strings: + if not opts.host_files and not opts.host_strings and not opts.pcmk_nodes: parser.error('Hosts not specified.') return opts, args @@ -90,4 +90,6 @@ if __name__ == "__main__": if opts.host_strings: for s in opts.host_strings: hosts.extend(psshutil.parse_host_string(s, default_user=opts.user)) + if opts.pcmk_nodes: + hosts += psshutil.get_pcmk_nodes() do_pnuke(hosts, pattern, opts) diff --git a/bin/prsync b/bin/prsync index b66443b..85c4959 100755 --- a/bin/prsync +++ b/bin/prsync @@ -55,7 +55,7 @@ def parse_args(): if len(args) > 2: parser.error('Extra arguments given after the remote path.') - if not opts.host_files and not opts.host_strings: + if not opts.host_files and not opts.host_strings and not opts.pcmk_nodes: parser.error('Hosts not specified.') return opts, args @@ -122,4 +122,6 @@ if __name__ == "__main__": if opts.host_strings: for s in opts.host_strings: hosts.extend(psshutil.parse_host_string(s, default_user=opts.user)) + if opts.pcmk_nodes: + hosts += psshutil.get_pcmk_nodes() do_prsync(hosts, local, remote, opts) diff --git a/bin/pscp b/bin/pscp index 3caf455..4f8c56b 100755 --- a/bin/pscp +++ b/bin/pscp @@ -47,7 +47,7 @@ def parse_args(): if len(args) < 2: parser.error('Remote path not specified.') - if not opts.host_files and not opts.host_strings: + if not opts.host_files and not opts.host_strings and not opts.pcmk_nodes: parser.error('Hosts not specified.') return opts, args @@ -105,4 +105,6 @@ if __name__ == "__main__": if opts.host_strings: for s in opts.host_strings: hosts.extend(psshutil.parse_host_string(s, default_user=opts.user)) + if opts.pcmk_nodes: + hosts += psshutil.get_pcmk_nodes() do_pscp(hosts, localargs, remote, opts) diff --git a/bin/pslurp b/bin/pslurp index 5797e7c..2336a15 100755 --- a/bin/pslurp +++ b/bin/pslurp @@ -52,7 +52,7 @@ def parse_args(): if len(args) > 2: parser.error('Extra arguments given after the local path.') - if not opts.host_files and not opts.host_strings: + if not opts.host_files and not opts.host_strings and not opts.pcmk_nodes: parser.error('Hosts not specified.') return opts, args @@ -126,4 +126,6 @@ if __name__ == "__main__": if opts.host_strings: for s in opts.host_strings: hosts.extend(psshutil.parse_host_string(s, default_user=opts.user)) + if opts.pcmk_nodes: + hosts += psshutil.get_pcmk_nodes() do_pslurp(hosts, remote, local, opts) diff --git a/bin/pssh b/bin/pssh index f9af471..25daa9c 100755 --- a/bin/pssh +++ b/bin/pssh @@ -51,7 +51,7 @@ def parse_args(): if len(args) == 0 and not opts.send_input: parser.error('Command not specified.') - if not opts.host_files and not opts.host_strings: + if not opts.host_files and not opts.host_strings and not opts.pcmk_nodes: parser.error('Hosts not specified.') return opts, args @@ -109,6 +109,10 @@ if __name__ == "__main__": _, e, _ = sys.exc_info() sys.stderr.write('Could not open hosts file: %s\n' % e.strerror) sys.exit(1) + if opts.pcmk_nodes: + hosts = psshutil.get_pcmk_nodes() + if not hosts: + sys.exit(1) if opts.host_strings: for s in opts.host_strings: hosts.extend(psshutil.parse_host_string(s, default_user=opts.user)) diff --git a/psshlib/cli.py b/psshlib/cli.py index e11645a..e950581 100644 --- a/psshlib/cli.py +++ b/psshlib/cli.py @@ -28,6 +28,8 @@ def common_parser(): parser.add_option('-H', '--host', dest='host_strings', action='append', metavar='HOST_STRING', help='additional host entries ("[user@]host[:port]")') + parser.add_option('-C', '--pcmk_nodes', dest='pcmk_nodes', action='store_true', + help='get nodes from pacemaker') parser.add_option('-l', '--user', dest='user', help='username (OPTIONAL)') parser.add_option('-p', '--par', dest='par', type='int', diff --git a/psshlib/psshutil.py b/psshlib/psshutil.py index ae1a24c..0700ef5 100644 --- a/psshlib/psshutil.py +++ b/psshlib/psshutil.py @@ -4,6 +4,7 @@ import fcntl import string import sys +import subprocess HOST_FORMAT = 'Host format is [user@]host[:port] [user]' @@ -98,6 +99,33 @@ def parse_host(host, default_user=None, default_port=None): host, port = host.rsplit(':', 1) return (host, port, user) +def get_pcmk_nodes(): + """Get the list of nodes from crm_node -l. + + Returns a list of (host, port, user) triples. + """ + hosts = [] + if subprocess.call("which crm_node >/dev/null 2>&1", shell=True) != 0: + sys.stderr.write('crm_node not available\n') + return hosts + cmd = "crm_node -l" + p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE) + try: + outp = p.communicate()[0] + p.wait() + rc = p.returncode + except IOError, msg: + sys.stderr.write('%s failed: %s\n' % (cmd,msg)) + return hosts + if rc != 0: + sys.stderr.write('%s failed: exit code %d\n' % (cmd,rc)) + return hosts + for s in outp.split('\n'): + a = s.split() + if len(a) != 3: + continue + hosts.append((a[1], None, None)) + return hosts def set_cloexec(filelike): """Sets the underlying filedescriptor to automatically close on exec. @@ -106,3 +134,5 @@ def set_cloexec(filelike): not require the close_fds option. """ fcntl.fcntl(filelike.fileno(), fcntl.FD_CLOEXEC, 1) + +# vim:ts=4:sw=4:et:
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor