Skip to content

Commit b9c85d1

Browse files
committed
veeam3.py, huawei3.py: In Python 3, getheader() should be get() (fixed #46)
1 parent aa08cea commit b9c85d1

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

huawei3.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
needed by LibreNMS check plugins."""
1313

1414
__author__ = 'Linuxfabrik GmbH, Zurich/Switzerland'
15-
__version__ = '2021112202'
15+
__version__ = '2022012101'
1616

1717
import time
1818

@@ -51,7 +51,8 @@ def get_creds(args):
5151
timeout=args.TIMEOUT,
5252
))
5353
ibasetoken = result.get('response_json').get('data').get('iBaseToken')
54-
cookie = result.get('response_header').getheader('Set-Cookie')
54+
# In Python 3, getheader() should be get()
55+
cookie = result.get('response_header').get('Set-Cookie')
5556
expire = base3.now() + args.CACHE_EXPIRE*60
5657
cache3.set('huawei-{}-ibasetoken'.format(args.DEVICE_ID), ibasetoken, expire)
5758
cache3.set('huawei-{}-cookie'.format(args.DEVICE_ID), cookie, expire)

veeam3.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
Credits go to https://github.com/surfer190/veeam/blob/master/veeam/client.py."""
1313

1414
__author__ = 'Linuxfabrik GmbH, Zurich/Switzerland'
15-
__version__ = '2022012001'
15+
__version__ = '2022012101'
1616

1717
import base64
1818

@@ -44,7 +44,9 @@ def get_token(args):
4444
if not success:
4545
return (success, result)
4646
if not result:
47-
return (False, 'There was no result from {}.'.format(url), False)
48-
if not 'X-RestSvcSessionId' in result:
49-
return (False, 'Something went wrong, maybe user is unauthorized.', False)
47+
return (False, 'There was no result from {}.'.format(url))
48+
# In Python 3, getheader() should be get()
49+
result['X-RestSvcSessionId'] = result.get('response_header').get('X-RestSvcSessionId')
50+
if not result['X-RestSvcSessionId']:
51+
return (False, 'Something went wrong, maybe user is unauthorized.')
5052
return (True, result)

0 commit comments

Comments
 (0)