From da0c7b3db906f375f1f09a31433f46b1c553c95f Mon Sep 17 00:00:00 2001 From: mvpnitesh Date: Fri, 13 Apr 2018 10:26:54 +0000 Subject: [PATCH] Fixes session issue for Gen10 servers For HPE Gen10 servers we are not able to receive consistent response while accessing the System with id: "/redfish/v1/Systems/1". The reason was related to multiple Sushy object creation which in turn will create multiple active sessions for the same Redfish controller at any given point. Instead of using session based authentication (the default behaviour in Sushy) we use basic authentication at the time of Sushy object creation. This fixes the session issue for Gen10 servers. Change-Id: Ic13da26a77863f8c383fa8ba185e05a8fc2e9fcf Closes-Bug: #1764395 --- proliantutils/redfish/redfish.py | 6 ++++-- .../tests/redfish/resources/test_update_service.py | 2 -- proliantutils/tests/redfish/test_redfish.py | 11 ++++++++--- requirements.txt | 2 +- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/proliantutils/redfish/redfish.py b/proliantutils/redfish/redfish.py index f356eee0..237b6445 100644 --- a/proliantutils/redfish/redfish.py +++ b/proliantutils/redfish/redfish.py @@ -18,6 +18,7 @@ import json from six.moves.urllib import parse import sushy +from sushy import auth from sushy.resources.system import mappings as sushy_map from sushy import utils @@ -141,9 +142,10 @@ class RedfishOperations(operations.IloOperations): self._username = username try: + basic_auth = auth.BasicAuth(username=username, password=password) self._sushy = main.HPESushy( - address, username=username, password=password, - root_prefix=root_prefix, verify=verify) + address, root_prefix=root_prefix, verify=verify, + auth=basic_auth) except sushy.exceptions.SushyError as e: msg = (self._('The Redfish controller at "%(controller)s" has ' 'thrown error. Error %(error)s') % diff --git a/proliantutils/tests/redfish/resources/test_update_service.py b/proliantutils/tests/redfish/resources/test_update_service.py index 9f7284d3..1728c757 100644 --- a/proliantutils/tests/redfish/resources/test_update_service.py +++ b/proliantutils/tests/redfish/resources/test_update_service.py @@ -40,8 +40,6 @@ class HPEUpdateServiceTestCase(testtools.TestCase): self.rf_client = redfish.RedfishOperations( '1.2.3.4', username='foo', password='bar') - sushy_mock.assert_called_once_with( - 'https://1.2.3.4', 'foo', 'bar', '/redfish/v1/', False) self.us_inst = update_service.HPEUpdateService( self.conn, '/redfish/v1/UpdateService/1', redfish_version='1.0.2') diff --git a/proliantutils/tests/redfish/test_redfish.py b/proliantutils/tests/redfish/test_redfish.py index d8a97583..50ca77df 100644 --- a/proliantutils/tests/redfish/test_redfish.py +++ b/proliantutils/tests/redfish/test_redfish.py @@ -21,6 +21,9 @@ import mock import sushy import testtools +from sushy import auth +from sushy.resources.system import system + from proliantutils import exception from proliantutils.ilo import constants as ilo_cons from proliantutils.redfish import main @@ -38,7 +41,6 @@ from proliantutils.redfish.resources.system.storage import array_controller from proliantutils.redfish.resources.system.storage \ import common as common_storage from proliantutils.redfish.resources.system import system as pro_sys -from sushy.resources.system import system @ddt.ddt @@ -59,8 +61,11 @@ class RedfishOperationsTestCase(testtools.TestCase): self.rf_client = redfish.RedfishOperations( '1.2.3.4', username='foo', password='bar') - sushy_mock.assert_called_once_with( - 'https://1.2.3.4', 'foo', 'bar', '/redfish/v1/', False) + args, kwargs = sushy_mock.call_args + self.assertEqual(('https://1.2.3.4',), args) + self.assertFalse(kwargs.get('verify')) + self.assertEqual('/redfish/v1/', kwargs.get('root_prefix')) + self.assertIsInstance(kwargs.get('auth'), auth.BasicAuth) @mock.patch.object(main, 'HPESushy', autospec=True) def test_sushy_init_fail(self, sushy_mock): diff --git a/requirements.txt b/requirements.txt index 1ce97522..048ceb1e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,4 +9,4 @@ retrying!=1.3.0,>=1.2.3 # Apache-2.0 pysnmp>=4.2.3,<5.0.0 # BSD # Redfish communication uses the Sushy library -sushy +sushy>=1.3.1