Check for existence of object attr login_handle (#53821)
This commit is contained in:
parent
6b4aabd355
commit
8aaed4c856
1 changed files with 10 additions and 8 deletions
|
@ -5,7 +5,7 @@
|
|||
# to the complete work.
|
||||
#
|
||||
# (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,
|
||||
# are permitted provided that the following conditions are met:
|
||||
|
@ -76,12 +76,14 @@ class UCSModule():
|
|||
proxy = {}
|
||||
|
||||
try:
|
||||
handle = UcsHandle(ip=self.module.params['hostname'],
|
||||
handle = UcsHandle(
|
||||
ip=self.module.params['hostname'],
|
||||
username=self.module.params['username'],
|
||||
password=self.module.params['password'],
|
||||
port=self.module.params['port'],
|
||||
secure=self.module.params['use_ssl'],
|
||||
proxy=proxy)
|
||||
proxy=proxy
|
||||
)
|
||||
handle.login()
|
||||
except Exception as e:
|
||||
self.result['msg'] = str(e)
|
||||
|
@ -89,7 +91,7 @@ class UCSModule():
|
|||
self.login_handle = handle
|
||||
|
||||
def logout(self):
|
||||
if self.login_handle:
|
||||
if hasattr(self, 'login_handle'):
|
||||
self.login_handle.logout()
|
||||
return True
|
||||
return False
|
||||
|
|
Loading…
Reference in a new issue