Skip to content
This repository was archived by the owner on Oct 15, 2020. It is now read-only.

Commit e97fcd5

Browse files
authored
Merge pull request #310 from HewlettPackard/enhancement/catch-http-lib-exceptions-as-hponeviewexceptions
Catch http lib related exceptions as HpOneViewExceptions during login
2 parents b219f1a + d9a3f8e commit e97fcd5

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
# v4.1.0 (Unreleased)
1+
# v4.1.0
22

33
#### New Resources:
44
- Appliance node information
55

6+
#### Bug fixes & Enhancements
7+
- [#309](https://github.com/HewlettPackard/python-hpOneView/issues/309) HPOneViewException not raised when connection with paused VM fails
8+
69
# v4.0.0
710
#### Notes
811
Major release which extends support of the SDK to OneView Rest API version 500 (OneView v3.10).

hpOneView/connection.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from builtins import open
1515
from builtins import str
1616
from future import standard_library
17+
from future.utils import raise_from
1718

1819
standard_library.install_aliases()
1920

@@ -479,8 +480,11 @@ def change_initial_password(self, newPassword):
479480
# Login/Logout to/from appliance
480481
###########################################################################
481482
def login(self, cred, verbose=False):
482-
if self._validateVersion is False:
483-
self.validateVersion()
483+
try:
484+
if self._validateVersion is False:
485+
self.validateVersion()
486+
except Exception as e:
487+
raise_from(HPOneViewException('Failure during login attempt.'), e)
484488

485489
self._cred = cred
486490
try:

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
from setuptools import setup
2727

2828
setup(name='hpOneView',
29-
version='4.0.0',
29+
version='4.1.0',
3030
description='HPE OneView Python Library',
3131
url='https://github.com/HewlettPackard/python-hpOneView',
32-
download_url="https://github.com/HewlettPackard/python-hpOneView/tarball/v4.0.0",
32+
download_url="https://github.com/HewlettPackard/python-hpOneView/tarball/v4.1.0",
3333
author='Hewlett Packard Enterprise Development LP',
3434
author_email='[email protected]',
3535
license='MIT',

tests/unit/test_connection.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -869,6 +869,13 @@ def test_login(self, mock_post, mock_get):
869869
self.assertEqual(self.connection.get_session_id(), '123')
870870
self.assertEqual(self.connection.get_session(), True)
871871

872+
@patch.object(connection, 'get')
873+
def test_login_catches_exceptions_as_hpOneView(self, mock_get):
874+
mock_get.side_effect = [Exception('test')]
875+
876+
with self.assertRaises(HPOneViewException):
877+
self.connection.login({})
878+
872879
@patch.object(connection, 'get')
873880
@patch.object(connection, 'post')
874881
def test_login_with_exception_in_post(self, mock_post, mock_get):

0 commit comments

Comments
 (0)