From 7baad26fc9700bf99b4ce9669dfbc56afa6ebfc1 Mon Sep 17 00:00:00 2001 From: Ade Lee Date: Fri, 9 May 2014 09:31:47 -0400 Subject: Added security domain functionality to python API Currently the security domain python API just extracts the security domain name from the json returned by the server. This patch allows it to extract and use all the information in the response. This info is needed to determine the state of the security domain for the IPA vault case. --- base/common/python/pki/system.py | 49 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 5 deletions(-) (limited to 'base/common/python/pki') diff --git a/base/common/python/pki/system.py b/base/common/python/pki/system.py index cada5af69..62888335a 100644 --- a/base/common/python/pki/system.py +++ b/base/common/python/pki/system.py @@ -28,9 +28,52 @@ if os.path.exists("/etc/debian_version"): SYSTEM_TYPE = "debian" +class SecurityDomainHost(object): + def __init__(self): + """ constructor """ + self.id = None + self.clone = False + self.domain_manager = False + self.hostname = None + self.unsecure_port = None + self.admin_port = None + self.agent_port = None + self.ee_client_auth_port = None + self.secure_port = None + self.subsystem_name = None + + @classmethod + def from_json(cls, json_value): + host = cls() + host.admin_port = json_value['SecureAdminPort'] + host.agent_port = json_value['SecureAgentPort'] + host.clone = json_value['Clone'] + host.domain_manager = json_value['DomainManager'] + host.ee_client_auth_port = json_value['SecureEEClientAuthPort'] + host.hostname = json_value['Hostname'] + host.id = json_value['id'] + host.secure_port = json_value['SecurePort'] + host.subsystem_name = json_value['SubsystemName'] + host.unsecure_port = json_value['Port'] + return host + + class SecurityDomainInfo(object): def __init__(self): self.name = None + self.systems = {} + + @classmethod + def from_json(cls, json_value): + ret = cls() + ret.name = json_value['id'] + for slist in json_value['Subsystem']: + system_type = slist['id'] + system_list = [] + for host in slist['Host']: + system_list.append(SecurityDomainHost.from_json(host)) + ret.systems[system_type] = system_list + return ret class SecurityDomainClient(object): @@ -39,10 +82,7 @@ class SecurityDomainClient(object): def get_security_domain_info(self): response = self.connection.get('/rest/securityDomain/domainInfo') - - info = SecurityDomainInfo() - info.name = response.json()['id'] - + info = SecurityDomainInfo.from_json(response.json()) return info def get_old_security_domain_info(self): @@ -51,7 +91,6 @@ class SecurityDomainClient(object): domaininfo = ETree.fromstring(root.find("DomainInfo").text) info = SecurityDomainInfo() info.name = domaininfo.find("Name").text - return info -- cgit