|
|
7e1b55 |
From 7fb95cc638b1c9b7f2e9a67dba859ef8126f2c5f Mon Sep 17 00:00:00 2001
|
|
|
7e1b55 |
From: Chris Kelley <ckelley@redhat.com>
|
|
|
7e1b55 |
Date: Tue, 27 Jul 2021 21:57:26 +0100
|
|
|
7e1b55 |
Subject: [PATCH] Parse getStatus as JSON not XML
|
|
|
7e1b55 |
|
|
|
7e1b55 |
On dogtagpki/pki master XML is being replaced by JSON, getStatus will
|
|
|
7e1b55 |
return JSON in PKI 11.0+
|
|
|
7e1b55 |
|
|
|
7e1b55 |
The PR for dogtagpki/pki that makes this change necessary is:
|
|
|
7e1b55 |
https://github.com/dogtagpki/pki/pull/3674
|
|
|
7e1b55 |
|
|
|
7e1b55 |
Reviewed-By: Francois Cami <fcami@redhat.com>
|
|
|
7e1b55 |
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
|
|
|
7e1b55 |
---
|
|
|
7e1b55 |
install/tools/ipa-pki-wait-running.in | 18 ++++++++++++++----
|
|
|
7e1b55 |
1 file changed, 14 insertions(+), 4 deletions(-)
|
|
|
7e1b55 |
|
|
|
7e1b55 |
diff --git a/install/tools/ipa-pki-wait-running.in b/install/tools/ipa-pki-wait-running.in
|
|
|
7e1b55 |
index 4f0f2f34a7b0a43210676e7fd50e7029e798f301..9ca6e974e55a4d68afd06e1d9c7b67c5f926e48c 100644
|
|
|
7e1b55 |
--- a/install/tools/ipa-pki-wait-running.in
|
|
|
7e1b55 |
+++ b/install/tools/ipa-pki-wait-running.in
|
|
|
7e1b55 |
@@ -13,6 +13,7 @@ import logging
|
|
|
7e1b55 |
import sys
|
|
|
7e1b55 |
import time
|
|
|
7e1b55 |
from xml.etree import ElementTree
|
|
|
7e1b55 |
+import json
|
|
|
7e1b55 |
|
|
|
7e1b55 |
from ipalib import api
|
|
|
7e1b55 |
from ipaplatform.paths import paths
|
|
|
7e1b55 |
@@ -74,10 +75,19 @@ def get_status(conn, timeout):
|
|
|
7e1b55 |
"""
|
|
|
7e1b55 |
client = SystemStatusClient(conn)
|
|
|
7e1b55 |
response = client.get_status(timeout=timeout)
|
|
|
7e1b55 |
- root = ElementTree.fromstring(response)
|
|
|
7e1b55 |
- status = root.findtext("Status")
|
|
|
7e1b55 |
- error = root.findtext("Error")
|
|
|
7e1b55 |
- logging.debug("Got status '%s', error '%s'", status, error)
|
|
|
7e1b55 |
+ status = None
|
|
|
7e1b55 |
+ error = None
|
|
|
7e1b55 |
+ try:
|
|
|
7e1b55 |
+ json_response = json.loads(response)
|
|
|
7e1b55 |
+ status = json_response['Response']['Status']
|
|
|
7e1b55 |
+ except KeyError as e:
|
|
|
7e1b55 |
+ error = repr(e)
|
|
|
7e1b55 |
+ except json.JSONDecodeError:
|
|
|
7e1b55 |
+ logger.debug("Response is not valid JSON, try XML")
|
|
|
7e1b55 |
+ root = ElementTree.fromstring(response)
|
|
|
7e1b55 |
+ status = root.findtext("Status")
|
|
|
7e1b55 |
+ error = root.findtext("Error")
|
|
|
7e1b55 |
+ logger.debug("Got status '%s', error '%s'", status, error)
|
|
|
7e1b55 |
return status, error
|
|
|
7e1b55 |
|
|
|
7e1b55 |
|
|
|
7e1b55 |
--
|
|
|
7e1b55 |
2.31.1
|
|
|
7e1b55 |
|