URL: https://github.com/freeipa/freeipa/pull/5932
Author: ckelleyRH
 Title: #5932: Parse getStatus as JSON not XML
Action: opened

PR body:
"""
On `dogtagpki/pki` master XML is being replaced by JSON, getStatus will return 
JSON in PKI 11.0+.

The PR for `dogtagpki/pki` that makes this change necessary is: 
https://github.com/dogtagpki/pki/pull/3674

To test, I forked the nightly copr build of `freeipa` and added in this patch. 
I then ran the `dogtagpki/pki` CI against my copr fork instead of the nightly 
freeipa copr. `dogtagpki/pki` CI fails against the nightly `freeipa` build, but 
succeeds with my patched build.

This is my first PR to this repo (hello everyone!) so if I need to do anything 
in addition, like bump a version or document that there is a breaking API 
change, then I would be grateful if someone could point me in the right 
direction!
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/5932/head:pr5932
git checkout pr5932
From bb2ee47e91be3e1df944383d3fe907a6e8044ca2 Mon Sep 17 00:00:00 2001
From: Chris Kelley <ckel...@redhat.com>
Date: Tue, 27 Jul 2021 21:57:26 +0100
Subject: [PATCH] Parse getStatus as JSON not XML

On dogtagpki/pki master XML is being replaced by JSON, getStatus will
return JSON in PKI 11.0+
---
 install/tools/ipa-pki-wait-running.in | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/install/tools/ipa-pki-wait-running.in b/install/tools/ipa-pki-wait-running.in
index 4f0f2f34a7b..4a62518bf61 100644
--- a/install/tools/ipa-pki-wait-running.in
+++ b/install/tools/ipa-pki-wait-running.in
@@ -12,7 +12,7 @@ import os
 import logging
 import sys
 import time
-from xml.etree import ElementTree
+import json
 
 from ipalib import api
 from ipaplatform.paths import paths
@@ -74,9 +74,13 @@ def get_status(conn, timeout):
     """
     client = SystemStatusClient(conn)
     response = client.get_status(timeout=timeout)
-    root = ElementTree.fromstring(response)
-    status = root.findtext("Status")
-    error = root.findtext("Error")
+    status = None
+    error = None
+    try:
+        json_response = json.loads(response)
+        status = json_response['Response']['Status']
+    except Exception as e:
+        error = e.message
     logging.debug("Got status '%s', error '%s'", status, error)
     return status, error
 
_______________________________________________
FreeIPA-devel mailing list -- freeipa-devel@lists.fedorahosted.org
To unsubscribe send an email to freeipa-devel-le...@lists.fedorahosted.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedorahosted.org/archives/list/freeipa-devel@lists.fedorahosted.org
Do not reply to spam on the list, report it: 
https://pagure.io/fedora-infrastructure

Reply via email to