summaryrefslogtreecommitdiffstats
path: root/ipalib/cli.py
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2008-10-23 11:00:50 -0400
committerRob Crittenden <rcritten@redhat.com>2008-10-23 11:00:50 -0400
commit06a82bf4b646cd077a43841abb5670d9a495b24c (patch)
tree3b205e58546590c402fea858db3ad4bea6e28ec1 /ipalib/cli.py
parentf8e8ac85036ad4100664de7b853c2bb58677088d (diff)
downloadfreeipa-06a82bf4b646cd077a43841abb5670d9a495b24c.tar.gz
freeipa-06a82bf4b646cd077a43841abb5670d9a495b24c.tar.xz
freeipa-06a82bf4b646cd077a43841abb5670d9a495b24c.zip
Fix ipa command running in server_context=True
Make the LDAP host and port environment variables More changes so that commands have a shell return value lite-xmlrpc no longer hardcodes the kerberos credentials cache location
Diffstat (limited to 'ipalib/cli.py')
-rw-r--r--ipalib/cli.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/ipalib/cli.py b/ipalib/cli.py
index 4e5e433ed..a802f8ef0 100644
--- a/ipalib/cli.py
+++ b/ipalib/cli.py
@@ -311,9 +311,25 @@ class CLI(object):
break
except errors.ValidationError, e:
error = e.error
+ if self.api.env.server_context:
+ try:
+ import krbV
+ import ldap
+ from ipa_server import conn
+ from ipa_server.servercore import context
+ krbccache = krbV.default_context().default_ccache().name
+ context.conn = conn.IPAConn(self.api.env.ldaphost, self.api.env.ldapport, krbccache)
+ except ImportError:
+ print >> sys.stderr, "There was a problem importing a Python module: %s" % sys.exc_value
+ return 2
+ except ldap.LDAPError, e:
+ print >> sys.stderr, "There was a problem connecting to the LDAP server: %s" % e[0].get('desc')
+ return 2
ret = cmd(**kw)
if callable(cmd.output_for_cli):
- cmd.output_for_cli(ret)
+ return cmd.output_for_cli(ret)
+ else:
+ return 0
def parse(self, cmd, argv):
parser = self.build_parser(cmd)