2
0
mirror of https://opendev.org/x/pyghmi synced 2025-01-27 19:37:44 +00:00

Correct mistake with image name abbreviation

It was incorrectly trying to abbreviate names that
are already short enough, causing a problem for certain
name lengths.

Change-Id: Iebb977bef3db0131cad3d923f5943f9bfa9247a6
This commit is contained in:
Jarrod Johnson 2016-10-27 11:16:47 -04:00
parent a27d28fb0a
commit fd92a734be

View File

@ -128,7 +128,11 @@ mac_format = '{0:02x}:{1:02x}:{2:02x}:{3:02x}:{4:02x}:{5:02x}'
def _megarac_abbrev_image(name):
if len(name) <= 16:
# MegaRAC platform in some places needs an abbreviated filename
# Their scheme in such a scenario is a max of 20. Truncation is
# acheived by taking the first sixteen, then skipping ahead to the last
# 4 (presumably to try to keep '.iso' or '.img' in the name).
if len(name) <= 20:
return name
return name[:16] + name[-4:]