From 7c2c2d6130648fb6dd7c0e52d802cc6eff39ef95 Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Mon, 30 Nov 2009 15:28:09 -0500 Subject: Add option to have ipautil.run() not raise an exception There are times where a caller will want to determine the course of action based on the returncode instead of relying on it != 0. This also lets the caller get the contents of stdout and stderr. --- ipaserver/install/cainstance.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'ipaserver/install/cainstance.py') diff --git a/ipaserver/install/cainstance.py b/ipaserver/install/cainstance.py index a4fcec4a1..198b0c644 100644 --- a/ipaserver/install/cainstance.py +++ b/ipaserver/install/cainstance.py @@ -612,7 +612,7 @@ class CAInstance(service.Service): # pkisilent doesn't return 1 on error so look at the output of # /sbin/service pki-ca status. It will tell us if the instance # still needs to be configured. - (stdout, stderr) = ipautil.run(["/sbin/service", "pki-ca", "status"]) + (stdout, stderr, returncode) = ipautil.run(["/sbin/service", "pki-ca", "status"]) try: stdout.index("CONFIGURED!") raise RuntimeError("pkisilent failed to configure instance.") @@ -640,7 +640,7 @@ class CAInstance(service.Service): def __get_agent_cert(self, nickname): args = ["/usr/bin/certutil", "-L", "-d", self.ca_agent_db, "-n", nickname, "-a"] - (out, err) = ipautil.run(args) + (out, err, returncode) = ipautil.run(args) out = out.replace('-----BEGIN CERTIFICATE-----', '') out = out.replace('-----END CERTIFICATE-----', '') return out @@ -692,7 +692,7 @@ class CAInstance(service.Service): '%s:%d' % (self.host_name, AGENT_SECURE_PORT), ] logging.debug("running sslget %s" % args) - (stdout, stderr) = ipautil.run(args) + (stdout, stderr, returncode) = ipautil.run(args) data = stdout.split('\r\n') params = get_defList(data) @@ -713,7 +713,7 @@ class CAInstance(service.Service): '%s:%d' % (self.host_name, AGENT_SECURE_PORT), ] logging.debug("running sslget %s" % args) - (stdout, stderr) = ipautil.run(args) + (stdout, stderr, returncode) = ipautil.run(args) data = stdout.split('\r\n') outputList = get_outputList(data) @@ -844,7 +844,7 @@ class CAInstance(service.Service): # makes openssl throw up. data = base64.b64decode(chain) - (certs, stderr) = ipautil.run(["/usr/bin/openssl", + (certs, stderr, returncode) = ipautil.run(["/usr/bin/openssl", "pkcs7", "-inform", "DER", @@ -989,7 +989,7 @@ class CAInstance(service.Service): """ # Start by checking to see if policy is already installed. - (stdout, stderr) = ipautils.run(["/usr/sbin/semodule", "-l"]) + (stdout, stderr, returncode) = ipautil.run(["/usr/sbin/semodule", "-l"]) # Ok, so stdout is a huge string of the output. Look through that # for our policy -- cgit