File 0013-medium-bootstrap-Make-arbitrator-argument-optional-b.patch of Package crmsh
From 79a73793fc536d87348b8058615faa2464f3ec1d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kristoffer=20Gr=C3=B6nlund?= <krig@koru.se>
Date: Wed, 10 May 2017 07:15:03 +0200
Subject: [PATCH] medium: bootstrap: Make arbitrator argument optional
(bsc#1038386)
---
crmsh/bootstrap.py | 27 +++++++++++----------------
crmsh/ui_cluster.py | 8 +++-----
doc/crm.8.adoc | 6 +++---
3 files changed, 17 insertions(+), 24 deletions(-)
diff --git a/crmsh/bootstrap.py b/crmsh/bootstrap.py
index 16772244..3d648539 100644
--- a/crmsh/bootstrap.py
+++ b/crmsh/bootstrap.py
@@ -1631,7 +1631,7 @@ def create_booth_authkey():
def create_booth_config(arbitrator, clusters, tickets):
status("Configure booth")
- config_template = Template("""# The booth configuration file is "/etc/booth/booth.conf". You need to
+ config_template = """# The booth configuration file is "/etc/booth/booth.conf". You need to
# prepare the same booth configuration file on each arbitrator and
# each node in the cluster sites where the booth daemon can be launched.
@@ -1639,21 +1639,16 @@ def create_booth_config(arbitrator, clusters, tickets):
# Currently only "UDP" is supported.
transport="UDP"
port="9929"
-arbitrator="$arbitrator"
-$sites
-authfile="$authkey"
-$tickets
-""")
- ticket_template = Template("""ticket="$name"
- expire="600"
-""")
- site_template = Template('site="$site"\n')
-
- cfg = config_template.substitute(
- arbitrator=arbitrator,
- sites="".join(site_template.substitute(site=s) for s in clusters.itervalues()),
- authkey=BOOTH_AUTH,
- tickets="".join(ticket_template.substitute(name=t) for t in tickets))
+"""
+ cfg = [config_template]
+ if arbitrator is not None:
+ cfg.append("arbitrator=\"{}\"".format(arbitrator))
+ for s in clusters.itervalues():
+ cfg.append("site=\"{}\"".format(s))
+ cfg.append("authfile=\"{}\"".format(BOOTH_AUTH))
+ for t in tickets:
+ cfg.append("ticket=\"{}\"\nexpire=\"600\"".format(t))
+ cfg = "\n".join(cfg) + "\n"
if os.path.exists(BOOTH_CFG):
invoke("rm -f {}".format(BOOTH_CFG))
diff --git a/crmsh/ui_cluster.py b/crmsh/ui_cluster.py
index 8730aa41..96166713 100644
--- a/crmsh/ui_cluster.py
+++ b/crmsh/ui_cluster.py
@@ -328,9 +328,9 @@ If stage is not specified, each stage will be invoked in sequence.
Make this cluster a geo cluster.
Needs some information to set up.
- * arbitrator IP / hostname
* cluster map: "cluster-name=ip cluster-name=ip"
- * list of tickets
+ * arbitrator IP / hostname (optional)
+ * list of tickets (can be empty)
'''
parser = OptParser(usage="usage: geo-init [options]", epilog="""
@@ -355,12 +355,10 @@ Cluster Description
parser.add_option("--tickets", help="Tickets to create (space-separated)", dest="tickets", metavar="LIST")
options, args = parser.parse_args(list(args))
- if options.clusters is None or options.arbitrator is None:
+ if options.clusters is None:
errs = []
if options.clusters is None:
errs.append("The --clusters argument is required.")
- if options.arbitrator is None:
- errs.append("The --arbitrator argument is required.")
parser.error(" ".join(errs))
clustermap = self._parse_clustermap(options.clusters)
diff --git a/doc/crm.8.adoc b/doc/crm.8.adoc
index e1218339..c7766824 100644
--- a/doc/crm.8.adoc
+++ b/doc/crm.8.adoc
@@ -996,12 +996,12 @@ Options:
*-y, --yes*::
Answer "yes" to all prompts (use with caution)
-*--arbitrator=IP*::
- IP address of geo cluster arbitrator
-
*--clusters=DESC*::
Cluster description (see details below)
+*--arbitrator=IP*::
+ IP address of geo cluster arbitrator (optional)
+
*--tickets=LIST*::
Tickets to create (space-separated)
--
2.12.2