mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Parse getStatus as JSON not XML
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 Reviewed-By: Rob Crittenden <rcritten@redhat.com> Reviewed-By: Francois Cami <fcami@redhat.com>
This commit is contained in:
parent
e3304ff3aa
commit
9310366a6f
@ -13,6 +13,7 @@ import logging
|
||||
import sys
|
||||
import time
|
||||
from xml.etree import ElementTree
|
||||
import json
|
||||
|
||||
from ipalib import api
|
||||
from ipaplatform.paths import paths
|
||||
@ -74,10 +75,19 @@ 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")
|
||||
logging.debug("Got status '%s', error '%s'", status, error)
|
||||
status = None
|
||||
error = None
|
||||
try:
|
||||
json_response = json.loads(response)
|
||||
status = json_response['Response']['Status']
|
||||
except KeyError as e:
|
||||
error = repr(e)
|
||||
except json.JSONDecodeError:
|
||||
logger.debug("Response is not valid JSON, try XML")
|
||||
root = ElementTree.fromstring(response)
|
||||
status = root.findtext("Status")
|
||||
error = root.findtext("Error")
|
||||
logger.debug("Got status '%s', error '%s'", status, error)
|
||||
return status, error
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user