Redfish: fix for model number string for Gen9 and above.

update_firmware failed to upload firmware binaries to web server
for Gen10 server. This patch makes upload to work for all Gen9
and above.

Change-Id: If88342309a8db85864691ff00aede599f15cadac
Closes-Bug: 1712260
This commit is contained in:
Anshul Jain 2017-08-21 12:31:18 +00:00
parent 4d58e21184
commit b448d89897
2 changed files with 20 additions and 1 deletions

View File

@ -115,6 +115,23 @@ class UtilsTestCase(testtools.TestCase):
self.assertEqual('core_fw_file.bin', raw_fw_file)
self.assertTrue(to_upload)
@mock.patch.object(firmware_controller, 'get_fw_extractor',
spec_set=True, autospec=True)
def test_process_firmware_image_asks_to_upload_firmware_file_Gen10(
self, get_extractor_mock):
# if fw_version is greater than or equal to 2.0
# | GIVEN |
get_extractor_mock.return_value.extract.return_value = (
'core_fw_file.bin', True)
self.client.model = 'Gen10'
# | WHEN |
raw_fw_file, to_upload, is_extracted = (
utils.process_firmware_image(self.some_compact_fw_file,
self.client))
# | THEN |
self.assertEqual('core_fw_file.bin', raw_fw_file)
self.assertTrue(to_upload)
@mock.patch.object(utils, 'hashlib', autospec=True)
def test__get_hash_object(self, hashlib_mock):
algorithms_available = ('md5', 'sha1', 'sha224',

View File

@ -16,6 +16,7 @@
Non-iLO related utilities and helper functions.
"""
import hashlib
import re
import requests
import six
@ -57,7 +58,8 @@ def process_firmware_image(compact_firmware_file, ilo_object):
# to be on a http store, and hence requires the upload to happen for the
# firmware file.
to_upload = False
if 'Gen9' in ilo_object.model:
m = re.search('Gen(\d+)', ilo_object.model)
if int(m.group(1)) > 8:
to_upload = True
LOG.debug('Extracting firmware file: %s ... done', compact_firmware_file)