Ignore non-existing option when activate a session

For kerberos auth, if not login with a keytab and principal, those two
options may not be present in the incoming options.

Similarly, debug is also an optional option that could not exist.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>
This commit is contained in:
Chenxiong Qi 2018-10-15 20:25:34 +08:00 committed by Mike McLean
parent 41593d6a4e
commit 5a3246f22a

View file

@ -578,7 +578,7 @@ def activate_session(session, options):
session.login()
elif options.authtype == "kerberos" or has_krb_creds() and options.authtype is None:
try:
if options.keytab and options.principal:
if getattr(options, 'keytab', None) and getattr(options, 'principal', None):
session.krb_login(principal=options.principal, keytab=options.keytab, proxyuser=runas)
else:
session.krb_login(proxyuser=runas)
@ -592,7 +592,7 @@ def activate_session(session, options):
if not noauth and not session.logged_in:
error(_("Unable to log in, no authentication methods available"))
ensure_connection(session)
if options.debug:
if getattr(options, 'debug', None):
print("successfully connected to hub")