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.
|
# 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…
Reference in a new issue