Hello community, here is the log from the commit of package pssh for openSUSE:Factory checked in at 2014-01-15 16:26:13 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/pssh (Old) and /work/SRC/openSUSE:Factory/.pssh.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "pssh" Changes: -------- --- /work/SRC/openSUSE:Factory/pssh/pssh.changes 2013-09-14 19:55:42.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.pssh.new/pssh.changes 2014-01-15 16:26:14.000000000 +0100 @@ -1,0 +2,31 @@ +Thu Jan 9 11:56:31 UTC 2014 - [email protected] + +- Changed to .xz compression +- Updated to latest upstream (cs: b6c8d715) +- added support for multiple source paths in prsync (issue #64) +- made a relative import explicit (issue #66) +- Add support for select.poll on systems where it is available (issue #72) +- Remove restriction on remote relative paths (Issue #83) +- Added programmatic API (with tests) +- Fixed teardown handling for tests + +Cleaned up and added patches: +- Rename pssh-remove_shebangs.patch: + to 0001-Remove-shebangs-from-library-files.patch + Also updated patch format +- Rename pssh-man_dir.patch: + to 0006-openSUSE-Adjust-man-pages-destination.patch + Also updated patch format +- Rename pssh-quiet.patch: to 0002-Add-quiet-option.patch +- Rename pssh_pcmk_nodes.patch: + to 0008-openSUSE-add-C-pcmk_nodes-option-to-get-list-of-node.patch +- Rename pssh_askpass_dir.patch: + to 0007-openSUSE-Add-openSUSE-specific-pssh-askpass-location.patch +- Rename pssh_status_order.patch: + to 0003-Fix-order-of-command-statuses-returned-by-the-Manage.patch +- Add 0005-Add-an-explicit-API-entrypoint.patch: + Add an explicit API entry point +- Add 0004-test-Teardown-code-was-never-called.patch: + Fixes test cases so teardown code is called + +------------------------------------------------------------------- Old: ---- pssh-2.3.1.tar.gz pssh-man_dir.patch pssh-remove_shebangs.patch pssh_askpass_dir.patch pssh_pcmk_nodes.patch pssh_quiet.patch pssh_status_order.patch New: ---- 0001-Remove-shebangs-from-library-files.patch 0002-Add-quiet-option.patch 0003-Fix-order-of-command-statuses-returned-by-the-Manage.patch 0004-test-Teardown-code-was-never-called.patch 0005-Add-an-explicit-API-entrypoint.patch 0006-openSUSE-Adjust-man-pages-destination.patch 0007-openSUSE-Add-openSUSE-specific-pssh-askpass-location.patch 0008-openSUSE-add-C-pcmk_nodes-option-to-get-list-of-node.patch pssh-2.3.1.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ pssh.spec ++++++ --- /var/tmp/diff_new_pack.96Y5zt/_old 2014-01-15 16:26:15.000000000 +0100 +++ /var/tmp/diff_new_pack.96Y5zt/_new 2014-01-15 16:26:15.000000000 +0100 @@ -1,7 +1,7 @@ # # spec file for package pssh # -# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -22,24 +22,31 @@ Summary: Parallel SSH to control large numbers of Machines simultaneously License: BSD-3-Clause Group: Productivity/Clustering/Computing -Source: http://parallel-ssh.googlecode.com/files/pssh-%{version}.tar.gz -# PATCH-FIX-OPENSUSE pssh-remove_shebangs.patch -- remove +Source: pssh-%{version}.tar.xz +# PATCH-FIX-OPENSUSE 0001-Remove-shebangs-from-library-files.patch [email protected] -- remove # shebangs from library files -Patch1: pssh-remove_shebangs.patch -# PATCH-FIX-OPENSUSE pssh-man_dir.patch -- adjust man pages -# destination -Patch2: pssh-man_dir.patch -# PATCH-FEATURE-UPSTREAM pssh_quiet.patch -- add the -q (quiet) -# option -Patch3: pssh_quiet.patch -# PATCH-FEATURE-UPSTREAM pssh_pcmk_nodes.patch -- add +Patch1: 0001-Remove-shebangs-from-library-files.patch +# PATCH-FEATURE-UPSTREAM 0002-Add-quiet-option.patch [email protected] -- add +# the -q (quiet) option +Patch2: 0002-Add-quiet-option.patch +# PATCH-FIX-UPSTREAM 0003-Fix-order-of-command-statuses-returned-by-the-Manage.patch bnc#828897 [email protected] -- Fix +# order of command statuses returned by the Manager +Patch3: 0003-Fix-order-of-command-statuses-returned-by-the-Manage.patch +# PATCH-FIX-UPSTREAM 0007-test-Teardown-code-was-never-called.patch [email protected] -- test: +# Teardown code was never called +Patch4: 0004-test-Teardown-code-was-never-called.patch +# PATCH-FEATURE-UPSTREAM 0005-Add-an-explicit-API-entrypoint.patch [email protected] -- Add +# an explicit API entrypoint +Patch5: 0005-Add-an-explicit-API-entrypoint.patch +# PATCH-FIX-OPENSUSE 0006-openSUSE-Adjust-man-pages-destination.patch [email protected] -- adjust +# man pages destination +Patch6: 0006-openSUSE-Adjust-man-pages-destination.patch +# PATCH-FIX-OPENSUSE 0007-openSUSE-Add-openSUSE-specific-pssh-askpass-location.patch [email protected] -- add +# openSUSE specific pssh-askpass location +Patch7: 0007-openSUSE-Add-openSUSE-specific-pssh-askpass-location.patch +# PATCH-FEATURE-UPSTREAM 0008-openSUSE-add-C-pcmk_nodes-option-to-get-list-of-node.patch [email protected] -- add # -C/--pcmk_nodes option to get list of nodes from Pacemaker -Patch4: pssh_pcmk_nodes.patch -# PATCH-FIX-OPENSUSE pssh_askpass_dir.patch -- add openSUSE -# specific pssh-askpass location -Patch5: pssh_askpass_dir.patch -# PATCH-FIX-UPSTREAM pssh_status_order.patch -- bnc#828897 -Patch6: pssh_status_order.patch +Patch8: 0008-openSUSE-add-C-pcmk_nodes-option-to-get-list-of-node.patch Url: http://code.google.com/p/parallel-ssh/ BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: python-devel @@ -78,12 +85,14 @@ %prep %setup -q -%patch1 -%patch2 +%patch1 -p1 +%patch2 -p1 %patch3 -p1 %patch4 -p1 %patch5 -p1 %patch6 -p1 +%patch7 -p1 +%patch8 -p1 %build %__python ./setup.py build ++++++ 0001-Remove-shebangs-from-library-files.patch ++++++ >From 059ddf3cca97d0b3d62f80835d6c8c040bc1cb79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristoffer=20Gr=C3=B6nlund?= <[email protected]> Date: Thu, 9 Jan 2014 11:45:21 +0100 Subject: [PATCH 1/8] Remove shebangs from library files --- psshlib/askpass_client.py | 1 - psshlib/askpass_server.py | 1 - test/test.py | 1 - 3 files changed, 3 deletions(-) diff --git a/psshlib/askpass_client.py b/psshlib/askpass_client.py index 34a8bc95dcee..8c5fae528cfb 100644 --- a/psshlib/askpass_client.py +++ b/psshlib/askpass_client.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # -*- Mode: python -*- # Copyright (c) 2009-2012, Andrew McNabb diff --git a/psshlib/askpass_server.py b/psshlib/askpass_server.py index 429316407228..9d8170abe202 100644 --- a/psshlib/askpass_server.py +++ b/psshlib/askpass_server.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # -*- Mode: python -*- # Copyright (c) 2009-2012, Andrew McNabb diff --git a/test/test.py b/test/test.py index e85b27d91a0f..c11d38b357a2 100644 --- a/test/test.py +++ b/test/test.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # Copyright (c) 2009, Andrew McNabb # Copyright (c) 2003-2008, Brent N. Chun -- 1.8.4 ++++++ 0002-Add-quiet-option.patch ++++++ >From ebeb6afae57885ec005a5ea542e6fdeeda0788ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristoffer=20Gr=C3=B6nlund?= <[email protected]> Date: Thu, 9 Jan 2014 11:47:32 +0100 Subject: [PATCH 2/8] Add quiet option --- man/man1/pssh.1 | 13 +++++++++++-- psshlib/cli.py | 3 +++ psshlib/task.py | 16 +++++++++++----- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/man/man1/pssh.1 b/man/man1/pssh.1 index e50efc78e84e..122e253793d8 100644 --- a/man/man1/pssh.1 +++ b/man/man1/pssh.1 @@ -7,7 +7,7 @@ pssh \(em parallel ssh program .SH SYNOPSIS .B pssh -.RB [ \-vAiIP ] +.RB [ \-vqAiIP ] .RB [ \-h .IR hosts_file ] .RB [ \-H @@ -31,7 +31,7 @@ pssh \(em parallel ssh program .I command ... .B pssh \-I -.RB [ \-vAiIP ] +.RB [ \-vqAiIP ] .RB [ \-h .IR hosts_file ] .RB [ \-H @@ -237,6 +237,15 @@ and options. .TP +.B \-q +.PD 0 +.TP +.B \-\-quiet +Don't print status messages. With +.B \-i +prepend host names to the output. + +.TP .B \-I .PD 0 .TP diff --git a/psshlib/cli.py b/psshlib/cli.py index c342cde47dad..58bd9332ce3d 100644 --- a/psshlib/cli.py +++ b/psshlib/cli.py @@ -45,6 +45,8 @@ def common_parser(): metavar='OPTION', help='SSH option (OPTIONAL)') parser.add_option('-v', '--verbose', dest='verbose', action='store_true', help='turn on warning and diagnostic messages (OPTIONAL)') + parser.add_option('-q', '--quiet', dest='quiet', action='store_true', + help='turn off informational and status messages (OPTIONAL)') parser.add_option('-A', '--askpass', dest='askpass', action='store_true', help='Ask for a password (OPTIONAL)') parser.add_option('-x', '--extra-args', action='callback', type='string', @@ -66,6 +68,7 @@ def common_defaults(**kwargs): ('errdir', 'PSSH_ERRDIR'), ('timeout', 'PSSH_TIMEOUT'), ('verbose', 'PSSH_VERBOSE'), + ('quiet', 'PSSH_QUIET'), ('print_out', 'PSSH_PRINT'), ('askpass', 'PSSH_ASKPASS'), ('inline', 'PSSH_INLINE'), diff --git a/psshlib/task.py b/psshlib/task.py index f8052563f9e9..0c74db517ae4 100644 --- a/psshlib/task.py +++ b/psshlib/task.py @@ -56,6 +56,7 @@ class Task(object): # Set options. self.verbose = opts.verbose + self.quiet = opts.quiet try: self.print_out = bool(opts.print_out) except AttributeError: @@ -188,7 +189,10 @@ class Task(object): buf = os.read(fd, BUFFER_SIZE) if buf: if self.inline or self.inline_stdout: - self.outputbuffer += buf + if self.quiet: + self.outputbuffer += "%s: %s" % (self.host, buf) + else: + self.outputbuffer += buf if self.outfile: self.writer.write(self.outfile, buf) if self.print_out: @@ -264,10 +268,11 @@ class Task(object): failure = "[FAILURE]" stderr = "Stderr: " host = self.pretty_host - if self.failures: - print(' '.join((progress, tstamp, failure, host, error))) - else: - print(' '.join((progress, tstamp, success, host))) + if not self.quiet: + if self.failures: + print(' '.join((progress, tstamp, failure, host, error))) + else: + print(' '.join((progress, tstamp, success, host))) # NOTE: The extra flushes are to ensure that the data is output in # the correct order with the C implementation of io. if self.outputbuffer: @@ -286,3 +291,4 @@ class Task(object): except AttributeError: sys.stdout.write(self.errorbuffer) +# vim:ts=4:sw=4:et: -- 1.8.4 ++++++ 0003-Fix-order-of-command-statuses-returned-by-the-Manage.patch ++++++ >From ffa067b469d00d3f6c054252690cd894a7551312 Mon Sep 17 00:00:00 2001 From: Dejan Muhamedagic <[email protected]> Date: Wed, 26 Jun 2013 17:11:46 +0200 Subject: [PATCH 3/8] Fix order of command statuses returned by the Manager --- psshlib/manager.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/psshlib/manager.py b/psshlib/manager.py index 7dbf4e377116..06e1cf31a010 100644 --- a/psshlib/manager.py +++ b/psshlib/manager.py @@ -6,6 +6,7 @@ import select import signal import sys import threading +import copy try: import queue @@ -43,6 +44,7 @@ class Manager(object): self.taskcount = 0 self.tasks = [] + self.save_tasks = [] self.running = [] self.done = [] @@ -50,6 +52,7 @@ class Manager(object): def run(self): """Processes tasks previously added with add_task.""" + self.save_tasks = copy.copy(self.tasks) try: if self.outdir or self.errdir: writer = Writer(self.outdir, self.errdir) @@ -88,7 +91,7 @@ class Manager(object): writer.signal_quit() writer.join() - statuses = [task.exitstatus for task in self.done] + statuses = [task.exitstatus for task in self.save_tasks if task in self.done] return statuses def clear_sigchld_handler(self): -- 1.8.4 ++++++ 0004-test-Teardown-code-was-never-called.patch ++++++ >From df34832187bc48a29dc43bf51a358df0487a93c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristoffer=20Gr=C3=B6nlund?= <[email protected]> Date: Thu, 9 Jan 2014 09:40:17 +0100 Subject: [PATCH 4/8] test: Teardown code was never called --- test/test.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/test.py b/test/test.py index c11d38b357a2..fc86bc54dd45 100644 --- a/test/test.py +++ b/test/test.py @@ -25,7 +25,7 @@ class PsshTest(unittest.TestCase): self.outDir = tempfile.mkdtemp() self.errDir = tempfile.mkdtemp() - def teardown(self): + def tearDown(self): shutil.rmtree(self.errDir) shutil.rmtree(self.outDir) @@ -69,7 +69,7 @@ class PscpTest(unittest.TestCase): self.outDir = tempfile.mkdtemp() self.errDir = tempfile.mkdtemp() - def teardown(self): + def tearDown(self): shutil.rmtree(self.errDir) shutil.rmtree(self.outDir) try: @@ -134,7 +134,7 @@ class PslurpTest(unittest.TestCase): self.outDir = tempfile.mkdtemp() self.errDir = tempfile.mkdtemp() - def teardown(self): + def tearDown(self): shutil.rmtree(self.errDir) shutil.rmtree(self.outDir) @@ -200,7 +200,7 @@ class PrsyncTest(unittest.TestCase): self.outDir = tempfile.mkdtemp() self.errDir = tempfile.mkdtemp() - def teardown(self): + def tearDown(self): shutil.rmtree(self.errDir) shutil.rmtree(self.outDir) @@ -261,7 +261,7 @@ class PnukeTest(unittest.TestCase): self.outDir = tempfile.mkdtemp() self.errDir = tempfile.mkdtemp() - def teardown(self): + def tearDown(self): shutil.rmtree(self.errDir) shutil.rmtree(self.outDir) -- 1.8.4 ++++++ 0005-Add-an-explicit-API-entrypoint.patch ++++++ ++++ 741 lines (skipped) ++++++ 0006-openSUSE-Adjust-man-pages-destination.patch ++++++ >From 8e092603ea429fb6dde3f2580d0d6d8fe79ec265 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristoffer=20Gr=C3=B6nlund?= <[email protected]> Date: Thu, 9 Jan 2014 11:46:15 +0100 Subject: [PATCH 6/8] openSUSE: Adjust man pages destination --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index b82a880038c8..70a238a3900a 100644 --- a/setup.py +++ b/setup.py @@ -38,6 +38,6 @@ setup( packages=['psshlib'], scripts = [os.path.join("bin", p) for p in ["pssh", "pnuke", "prsync", "pslurp", "pscp", "pssh-askpass"]], - data_files=[('man/man1', ['man/man1/pssh.1', 'man/man1/pscp.1', + data_files=[('share/man/man1', ['man/man1/pssh.1', 'man/man1/pscp.1', 'man/man1/prsync.1', 'man/man1/pslurp.1', 'man/man1/pnuke.1'])], ) -- 1.8.4 ++++++ 0007-openSUSE-Add-openSUSE-specific-pssh-askpass-location.patch ++++++ >From 464bb8a0fa767d491860292c64ff96ce4d3fa640 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristoffer=20Gr=C3=B6nlund?= <[email protected]> Date: Thu, 9 Jan 2014 11:49:07 +0100 Subject: [PATCH 7/8] openSUSE: Add openSUSE-specific pssh-askpass location --- psshlib/askpass_client.py | 1 + 1 file changed, 1 insertion(+) diff --git a/psshlib/askpass_client.py b/psshlib/askpass_client.py index 8c5fae528cfb..d66d455d4786 100644 --- a/psshlib/askpass_client.py +++ b/psshlib/askpass_client.py @@ -25,6 +25,7 @@ import textwrap bin_dir = os.path.dirname(os.path.abspath(sys.argv[0])) askpass_bin_path = os.path.join(bin_dir, 'pssh-askpass') ASKPASS_PATHS = (askpass_bin_path, + '/usr/bin/pssh-askpass', '/usr/libexec/pssh/pssh-askpass', '/usr/local/libexec/pssh/pssh-askpass', '/usr/lib/pssh/pssh-askpass', -- 1.8.4 ++++++ 0008-openSUSE-add-C-pcmk_nodes-option-to-get-list-of-node.patch ++++++ >From 755b1ce33d6f726c54891eadb9bd61c7893f5252 Mon Sep 17 00:00:00 2001 From: Dejan Muhamedagic <[email protected]> Date: Fri, 10 Jan 2014 12:17:23 +0100 Subject: [PATCH 8/8] openSUSE: add -C/--pcmk_nodes option to get list of nodes from Pacemaker --- bin/pnuke | 4 +++- bin/prsync | 4 +++- bin/pscp | 4 +++- bin/pslurp | 4 +++- bin/pssh | 6 +++++- psshlib/cli.py | 2 ++ psshlib/psshutil.py | 30 ++++++++++++++++++++++++++++++ 7 files changed, 49 insertions(+), 5 deletions(-) diff --git a/bin/pnuke b/bin/pnuke index 884ac25a1d35..ec314f3858e8 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 @@ -93,4 +93,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 5e25786a90e8..d7868c87a945 100755 --- a/bin/prsync +++ b/bin/prsync @@ -52,7 +52,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 @@ -117,4 +117,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 d569be7d5404..4408913ce077 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 @@ -102,4 +102,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 c7dece656f1b..0f17b5bc87d9 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 5b6c2a5e4661..cf02f40c2fbd 100755 --- a/bin/pssh +++ b/bin/pssh @@ -54,7 +54,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 @@ -112,6 +112,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 611fadb6eb16..09e2571f3c6c 100644 --- a/psshlib/cli.py +++ b/psshlib/cli.py @@ -31,6 +31,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 6c67f667637e..274b3b92546c 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) < 2: + 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: -- 1.8.4 -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
