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
This commit is contained in:
mvpnitesh 2018-04-13 10:26:54 +00:00
parent a9678fcbda
commit da0c7b3db9
4 changed files with 13 additions and 8 deletions

View File

@ -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') %

View File

@ -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')

View File

@ -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):

View File

@ -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