Check for existence of object attr login_handle (#53821)

pull/54450/head
John McDonough 6 years ago committed by John R Barker
parent 6b4aabd355
commit 8aaed4c856

@ -5,7 +5,7 @@
# to the complete work. # to the complete work.
# #
# (c) 2016 Red Hat Inc. # (c) 2016 Red Hat Inc.
# (c) 2017 Cisco Systems Inc. # (c) 2019 Cisco Systems Inc.
# #
# Redistribution and use in source and binary forms, with or without modification, # Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met: # are permitted provided that the following conditions are met:
@ -76,12 +76,14 @@ class UCSModule():
proxy = {} proxy = {}
try: try:
handle = UcsHandle(ip=self.module.params['hostname'], handle = UcsHandle(
username=self.module.params['username'], ip=self.module.params['hostname'],
password=self.module.params['password'], username=self.module.params['username'],
port=self.module.params['port'], password=self.module.params['password'],
secure=self.module.params['use_ssl'], port=self.module.params['port'],
proxy=proxy) secure=self.module.params['use_ssl'],
proxy=proxy
)
handle.login() handle.login()
except Exception as e: except Exception as e:
self.result['msg'] = str(e) self.result['msg'] = str(e)
@ -89,7 +91,7 @@ class UCSModule():
self.login_handle = handle self.login_handle = handle
def logout(self): def logout(self):
if self.login_handle: if hasattr(self, 'login_handle'):
self.login_handle.logout() self.login_handle.logout()
return True return True
return False return False

Loading…
Cancel
Save