Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 943334 Details for
Bug 1115537
[RFE] 'pcs cluster cib': implement --scope as cibadmin does
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
proposed fix
0001-Added-scope-support-for-cib-commands.patch (text/plain), 9.03 KB, created by
Tomas Jelinek
on 2014-10-02 08:51:26 UTC
(
hide
)
Description:
proposed fix
Filename:
MIME Type:
Creator:
Tomas Jelinek
Created:
2014-10-02 08:51:26 UTC
Size:
9.03 KB
patch
obsolete
>From 4a13e8dad6b58c257151dfdf297d8529373d05a0 Mon Sep 17 00:00:00 2001 >From: Tomas Jelinek <tojeline@redhat.com> >Date: Wed, 1 Oct 2014 16:50:59 +0200 >Subject: [PATCH] Added scope support for cib commands > >--- > pcs/cluster.py | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++-------- > pcs/pcs.8 | 12 ++++---- > pcs/usage.py | 19 +++++++++---- > pcs/utils.py | 13 +++++++-- > 4 files changed, 104 insertions(+), 26 deletions(-) > >diff --git a/pcs/cluster.py b/pcs/cluster.py >index 01e484e..bb941c8 100644 >--- a/pcs/cluster.py >+++ b/pcs/cluster.py >@@ -632,12 +632,33 @@ def kill_cluster(argv): > # sys.exit(1) > > def cluster_push(argv): >- if len(argv) == 1: >- filename = argv[0] >- else: >- usage.cluster() >+ if len(argv) > 2: >+ usage.cluster(["cib-push"]) > sys.exit(1) >- output, retval = utils.run(["cibadmin", "--replace", "--xml-file", filename]) >+ >+ filename = None >+ scope = None >+ for arg in argv: >+ if "=" not in arg: >+ filename = arg >+ else: >+ arg_name, arg_value = arg.split("=", 1) >+ if arg_name == "scope": >+ if not utils.is_valid_cib_scope(arg_value): >+ utils.err("invalid CIB scope '%s'" % arg_value) >+ else: >+ scope = arg_value >+ else: >+ usage.cluster(["cib-push"]) >+ sys.exit(1) >+ if not filename: >+ usage.cluster(["cib-push"]) >+ sys.exit(1) >+ >+ command = ["cibadmin", "--replace", "--xml-file", filename] >+ if scope: >+ command.append("--scope=%s" % scope) >+ output, retval = utils.run(command) > if retval != 0: > utils.err("unable to push cib\n" + output) > else: >@@ -651,9 +672,31 @@ def cluster_upgrade(): > > def cluster_edit(argv): > if 'EDITOR' in os.environ: >+ if len(argv) > 1: >+ usage.cluster(["edit"]) >+ sys.exit(1) >+ >+ scope = None >+ scope_arg = "" >+ for arg in argv: >+ if "=" not in arg: >+ usage.cluster(["edit"]) >+ sys.exit(1) >+ else: >+ arg_name, arg_value = arg.split("=", 1) >+ if arg_name == "scope": >+ if not utils.is_valid_cib_scope(arg_value): >+ utils.err("invalid CIB scope '%s'" % arg_value) >+ else: >+ scope_arg = arg >+ scope = arg_value >+ else: >+ usage.cluster(["edit"]) >+ sys.exit(1) >+ > editor = os.environ['EDITOR'] > tempcib = tempfile.NamedTemporaryFile('w+b',-1,".pcs") >- cib = utils.get_cib() >+ cib = utils.get_cib(scope) > tempcib.write(cib) > tempcib.flush() > try: >@@ -666,21 +709,40 @@ def cluster_edit(argv): > if newcib == cib: > print "CIB not updated, no changes detected" > else: >- cluster_push([tempcib.name]) >+ cluster_push(filter(None, [tempcib.name, scope_arg])) > > else: > utils.err("$EDITOR environment variable is not set") > > def get_cib(argv): >- if len(argv) == 0: >- print utils.get_cib(), >+ if len(argv) > 2: >+ usage.cluster(["cib"]) >+ sys.exit(1) >+ >+ filename = None >+ scope = None >+ for arg in argv: >+ if "=" not in arg: >+ filename = arg >+ else: >+ arg_name, arg_value = arg.split("=", 1) >+ if arg_name == "scope": >+ if not utils.is_valid_cib_scope(arg_value): >+ utils.err("invalid CIB scope '%s'" % arg_value) >+ else: >+ scope = arg_value >+ else: >+ usage.cluster(["cib"]) >+ sys.exit(1) >+ >+ if not filename: >+ print utils.get_cib(scope), > else: >- filename = argv[0] > try: > f = open(filename, 'w') >- output = utils.get_cib() >+ output = utils.get_cib(scope) > if output != "": >- f.write(utils.get_cib()) >+ f.write(output) > else: > utils.err("No data in the CIB") > except IOError as e: >diff --git a/pcs/pcs.8 b/pcs/pcs.8 >index a6f0fa9..5390350 100644 >--- a/pcs/pcs.8 >+++ b/pcs/pcs.8 >@@ -222,17 +222,17 @@ Sync corosync configuration to all nodes found from current corosync.conf file ( > quorum unblock > Cancel waiting for all nodes when establishing quorum. Usefull in situations where you know the cluster is inquorate, but you are confident that the cluster should proceed with resource management regardless. > .TP >-cib [filename] >-Get the raw xml from the CIB (Cluster Information Base). If a filename is provided, we save the cib to that file, otherwise the cib is printed >+cib [filename] [scope=<scope>] >+Get the raw xml from the CIB (Cluster Information Base). If a filename is provided, we save the cib to that file, otherwise the cib is printed. Specify scope to get a specific section of the CIB. Valid values of the scope are: nodes, resources, constraints, crm_config, rsc_defaults, op_defaults, status. > .TP >-cib\-push <filename> >-Push the raw xml from <filename> to the CIB (Cluster Information Base) >+cib-push <filename> [scope=<scope>] >+Push the raw xml from <filename> to the CIB (Cluster Information Base). Specify scope to push a specific section of the CIB. Valid values of the scope are: nodes, resources, constraints, crm_config, rsc_defaults, op_defaults. > .TP > cib\-upgrade > Upgrade the cib to the latest version > .TP >-edit >-Edit the cib in the editor specified by the $EDITOR environment variable and push out any changes upon saving >+edit [scope=<scope>] >+Edit the cib in the editor specified by the $EDITOR environment variable and push out any changes upon saving. Specify scope to edit a specific section of the CIB. Valid values of the scope are: nodes, resources, constraints, crm_config, rsc_defaults, op_defaults. > .TP > node add <node[,node\-altaddr]> [\fB\-\-start\fR] [\fB\-\-enable\fR] > Add the node to corosync.conf and corosync on all nodes in the cluster and sync the new corosync.conf to the new node. If \fB\-\-start\fR is specified also start corosync/pacemaker on the new node, if \fB\-\-enable\fR is specified enable corosync/pacemaker on new node. When using Redundant Ring Protocol (RRP) with udpu transport, specify the ring 0 address first followed by a ',' and then the ring 1 address. >diff --git a/pcs/usage.py b/pcs/usage.py >index dfa392d..bb15a23 100644 >--- a/pcs/usage.py >+++ b/pcs/usage.py >@@ -570,20 +570,27 @@ Commands: > confident that the cluster should proceed with resource management > regardless. > >- cib [filename] >+ cib [filename] [scope=<scope>] > Get the raw xml from the CIB (Cluster Information Base). If a > filename is provided, we save the cib to that file, otherwise the cib >- is printed >+ is printed. Specify scope to get a specific section of the CIB. Valid >+ values of the scope are: nodes, resources, constraints, crm_config, >+ rsc_defaults, op_defaults, status. > >- cib-push <filename> >- Push the raw xml from <filename> to the CIB (Cluster Information Base) >+ cib-push <filename> [scope=<scope>] >+ Push the raw xml from <filename> to the CIB (Cluster Information Base). >+ Specify scope to push a specific section of the CIB. Valid values >+ of the scope are: nodes, resources, constraints, crm_config, >+ rsc_defaults, op_defaults. > > cib-upgrade > Upgrade the cib to the latest version > >- edit >+ edit [scope=<scope>] > Edit the cib in the editor specified by the $EDITOR environment >- variable and push out any changes upon saving >+ variable and push out any changes upon saving. Specify scope to edit >+ a specific section of the CIB. Valid values of the scope are: >+ nodes, resources, constraints, crm_config, rsc_defaults, op_defaults. > > node add <node[,node-altaddr]> [--start] [--enable] > Add the node to corosync.conf and corosync on all nodes in the cluster >diff --git a/pcs/utils.py b/pcs/utils.py >index 06defda..6bdc7ea 100644 >--- a/pcs/utils.py >+++ b/pcs/utils.py >@@ -1135,8 +1135,11 @@ def remove_from_cib(xml): > args = args + ["-D", "-X", xml] > return run(args) > >-def get_cib(): >- output, retval = run(["cibadmin", "-l", "-Q"]) >+def get_cib(scope=None): >+ command = ["cibadmin", "-l", "-Q"] >+ if scope: >+ command.append("--scope=%s" % scope) >+ output, retval = run(command) > if retval != 0: > err("unable to get cib") > return output >@@ -1165,6 +1168,12 @@ def replace_cib_configuration(dom): > if retval != 0: > err("Unable to update cib\n"+output) > >+def is_valid_cib_scope(scope): >+ return scope in [ >+ "configuration", "nodes", "resources", "constraints", "crm_config", >+ "rsc_defaults", "op_defaults", "status", >+ ] >+ > # Checks to see if id exists in the xml dom passed > def does_id_exist(dom, check_id): > if dom.__class__ == xml.etree.ElementTree.Element or dom.__class__ == xml.etree.ElementTree._ElementInterface: >-- >1.9.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 1115537
: 943334 |
965905