1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
#!/usr/bin/python
# Authors:
# Endi S. Dewata <edewata@redhat.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright (C) 2013 Red Hat, Inc.
# All rights reserved.
#
import pki.encoder as encoder
import xml.etree.ElementTree as ET
import os
SYSTEM_TYPE = "Fedora/RHEL"
if os.path.exists("/etc/debian_version"):
SYSTEM_TYPE = "debian"
class SecurityDomainInfo(object):
def __init__(self):
self.name = None
class SecurityDomainClient(object):
def __init__(self, connection):
self.connection = connection
def getSecurityDomainInfo(self):
response = self.connection.get('/rest/securityDomain/domainInfo')
info = SecurityDomainInfo()
info.name = response.json()['id']
return info
def getOldSecurityDomainInfo(self):
response = self.connection.get('/admin/ca/getDomainXML')
root = ET.fromstring(response.text)
domaininfo = ET.fromstring(root.find("DomainInfo").text)
info = SecurityDomainInfo()
info.name = domaininfo.find("Name").text
return info
class ConfigurationRequest(object):
def __init__(self):
self.token = "Internal Key Storage Token"
self.isClone = "false"
self.secureConn = "off"
self.importAdminCert = "false"
self.generateServerCert = "true"
class ConfigurationResponse(object):
def __init__(self):
pass
class SystemCertData(object):
def __init__(self):
pass
class SystemConfigClient(object):
def __init__(self, connection):
self.connection = connection
def configure(self, data):
headers = {'Content-type': 'application/json',
'Accept': 'application/json'}
response = self.connection.post('/rest/installer/configure', data, headers)
return response.json()
class SystemStatusClient(object):
def __init__(self, connection):
self.connection = connection
def getStatus(self):
response = self.connection.get('/admin/' + \
self.connection.subsystem + '/getStatus')
return response.text
encoder.NOTYPES['ConfigurationRequest'] = ConfigurationRequest
encoder.NOTYPES['ConfigurationResponse'] = ConfigurationResponse
encoder.NOTYPES['SystemCertData'] = SystemCertData
|