From b86c6145642b9310581e49f6e7e0b19ff893ac02 Mon Sep 17 00:00:00 2001 From: "C. R. Oldham" Date: Mon, 9 Nov 2015 11:04:34 -0700 Subject: [PATCH] Better logic around fallback credentials. --- salt/proxy/fx2.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/salt/proxy/fx2.py b/salt/proxy/fx2.py index 21dcf6f553..4ce021aafc 100644 --- a/salt/proxy/fx2.py +++ b/salt/proxy/fx2.py @@ -197,11 +197,13 @@ def init(opts): fallback_available = False check_grains = _grains(DETAILS['host'], first_user, first_password) - if check_grains.get('retcode', 0) == 0: + if check_grains: DETAILS['admin_username'] = opts['proxy']['admin_username'] DETAILS['admin_password'] = opts['proxy']['admin_password'] return True - elif fallback_available and _grains(DETAILS['host'], fallback_user, fallback_password).get('retcode', 0) == 0: + elif fallback_available and _grains(DETAILS['host'], + fallback_user, + fallback_password): log.info('Fallback credentials used' ' to access chassis {0}'.format(opts['proxy']['host'])) DETAILS['admin_username'] = opts['proxy']['fallback_admin_username'] @@ -233,13 +235,10 @@ def grains(): Get the grains from the proxied device ''' if not GRAINS_CACHE: - r = _grains(DETAILS['host'], - DETAILS['admin_username'], - DETAILS['admin_password']) - if r.get('retcode', 0) == 0: - GRAINS_CACHE = r - else: - GRAINS_CACHE = {} + return _grains(DETAILS['host'], + DETAILS['admin_username'], + DETAILS['admin_password']) + return GRAINS_CACHE