diff options
| author | Ade Lee <alee@redhat.com> | 2013-03-18 11:29:52 -0400 |
|---|---|---|
| committer | Ade Lee <alee@redhat.com> | 2013-03-21 12:11:31 -0400 |
| commit | c9a081037aa5bf15cf6226f06ea54ea98deba5bc (patch) | |
| tree | ba095458c940b4db7923719ce6cf6e14a2c1da8e /base/common/python/pki/client.py | |
| parent | 22d50cc526c7fd4224a4d5a0ae9ebf66afd8e83a (diff) | |
| download | pki-c9a081037aa5bf15cf6226f06ea54ea98deba5bc.tar.gz pki-c9a081037aa5bf15cf6226f06ea54ea98deba5bc.tar.xz pki-c9a081037aa5bf15cf6226f06ea54ea98deba5bc.zip | |
Refactor installation code to remove dependency on jython
Connection is now made to the installation servlet through a python
client using JSON. The code to construct the ConfgurationRequest and
parse the results has been moved to pkihelper.py, and configuration.py
no longer calls a separate jython process to create the Configuration
object and parse the results. The jython code has therefore been removed.
Also added status servlet to other java subsystems, to be tested prior
to starting configuration.
Trac Ticket 532
Diffstat (limited to 'base/common/python/pki/client.py')
| -rw-r--r-- | base/common/python/pki/client.py | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/base/common/python/pki/client.py b/base/common/python/pki/client.py index 7635fe879..05f42ba06 100644 --- a/base/common/python/pki/client.py +++ b/base/common/python/pki/client.py @@ -27,7 +27,8 @@ class PKIConnection: protocol='http', hostname='localhost', port=80, - subsystem='ca'): + subsystem='ca', + accept='application/json'): self.protocol = protocol self.hostname = hostname @@ -39,15 +40,26 @@ class PKIConnection: self.subsystem self.session = requests.Session() - self.session.headers.update({'Accept': 'application/json'}) + if accept: + self.session.headers.update({'Accept': accept}) def authenticate(self, username=None, password=None): if username is not None and password is not None: self.session.auth = (username, password) - def get(self, path): + def get(self, path, headers=None): r = self.session.get( - self.serverURI + '/rest/' + path, - verify=False) + self.serverURI + path, + verify=False, + headers=headers) r.raise_for_status() - return r
\ No newline at end of file + return r + + def post(self, path, payload, headers=None): + r = self.session.post( + self.serverURI + path, + verify=False, + data=payload, + headers=headers) + r.raise_for_status() + return r |
