Rename GA metadata file to fix upload/delete issue
Due to commit [1], the "software delete" command now fails with
"file not found" error when deleting an upgrade GA iso, the cause
being the dependence that currently exists between the release id
and the release metadata filename, i.e. for a release named "X",
the metadata file is expected to be called "X-metadata.xml" (refer
to [2] for example).
This commit renames the GA metadata file to match the expected
release id. Since "software upload" also uses the expected name
format to copy the GA metadata, it had to be changed as well.
[1] https://review.opendev.org/c/starlingx/update/+/898132
[2] 5c125d4225/software/software/software_controller.py (L1288)
Test Plan:
PASS: build the iso, install and verify the GA release id and
the GA metadata filename matches the expected format
PASS: upload and delete an upgrade GA iso successfully
Story: 2010676
Task: 49128
Change-Id: I87a7fdf87cb2932ef3fd2d5b506270a844a38087
Signed-off-by: Heitor Matsui <heitorvieira.matsui@windriver.com>
This commit is contained in:
parent
4e295baec4
commit
a77914160d
@ -6,13 +6,13 @@ PMONDIR := ${ROOT}/usr/share/starlingx/pmon.d
|
||||
|
||||
ROOT := $(CURDIR)/debian/tmp
|
||||
export PLATFORM_RELEASE="$(shell grep SW_VERSION /usr/include/build_info.h | cut -d ' ' -f 3)"
|
||||
export METADATA_FILE="STX_${PLATFORM_RELEASE}_GA-metadata.xml"
|
||||
export METADATA_FILE="starlingx-${PLATFORM_RELEASE}.0-metadata.xml"
|
||||
|
||||
%:
|
||||
dh $@ --with python3 --buildsystem=pybuild
|
||||
|
||||
override_dh_auto_build:
|
||||
cp service-files/STX_GA-metadata.xml ${METADATA_FILE}
|
||||
cp service-files/starlingx-GA-metadata.xml ${METADATA_FILE}
|
||||
sed -i "s/xxxPLATFORM_RELEASExxx/${PLATFORM_RELEASE}/g" ${METADATA_FILE}
|
||||
|
||||
override_dh_install:
|
||||
|
@ -100,7 +100,7 @@ SIG_EXTENSION = ".sig"
|
||||
PATCH_EXTENSION = ".patch"
|
||||
SUPPORTED_UPLOAD_FILE_EXT = [ISO_EXTENSION, SIG_EXTENSION, PATCH_EXTENSION]
|
||||
SCRATCH_DIR = "/scratch"
|
||||
RELEASE_METADATA_FILE = "STX_%s_GA-metadata.xml"
|
||||
RELEASE_GA_NAME = "starlingx-%s.0"
|
||||
|
||||
CONTROLLER_HOSTNAME = 'controller'
|
||||
CONTROLLER_0_HOSTNAME = '%s-0' % CONTROLLER_HOSTNAME
|
||||
|
@ -1006,12 +1006,13 @@ class PatchController(PatchService):
|
||||
|
||||
# After successful validation, copy metadata.xml to /opt/software/metadata/available
|
||||
os.makedirs(constants.AVAILABLE_DIR, exist_ok=True)
|
||||
stx_release_metadata_file = "STX_%s_GA-metadata.xml" % to_release
|
||||
abs_stx_release_metadata_file = os.path.join(iso_mount_dir,
|
||||
'upgrades',
|
||||
to_release_name = constants.RELEASE_GA_NAME % to_release
|
||||
stx_release_metadata_file = "%s-metadata.xml" % to_release_name
|
||||
abs_stx_release_metadata_file = os.path.join(iso_mount_dir, 'upgrades',
|
||||
stx_release_metadata_file)
|
||||
|
||||
# Copy stx release metadata.xml to available metadata dir
|
||||
# TODO(heitormatsui): treat the prepatched iso scenario
|
||||
shutil.copyfile(abs_stx_release_metadata_file,
|
||||
os.path.join(constants.AVAILABLE_DIR, stx_release_metadata_file))
|
||||
LOG.info("Copied %s to %s", abs_stx_release_metadata_file, constants.AVAILABLE_DIR)
|
||||
|
@ -68,11 +68,11 @@ class TestSoftwareController(unittest.TestCase):
|
||||
self.assertEqual(error, '')
|
||||
|
||||
# Verify that the expected methods were called on the ReleaseData object
|
||||
release_data.parse_metadata.assert_called_once_with('/mnt/iso/upgrades/STX_2.0_GA-metadata.xml', state='available')
|
||||
release_data.parse_metadata.assert_called_once_with('/mnt/iso/upgrades/starlingx-2.0.0-metadata.xml', state='available')
|
||||
|
||||
# Verify that the expected files were copied to the expected directories
|
||||
mock_copyfile.assert_called_once_with('/mnt/iso/upgrades/STX_2.0_GA-metadata.xml',
|
||||
constants.AVAILABLE_DIR + '/STX_2.0_GA-metadata.xml')
|
||||
mock_copyfile.assert_called_once_with('/mnt/iso/upgrades/starlingx-2.0.0-metadata.xml',
|
||||
constants.AVAILABLE_DIR + '/starlingx-2.0.0-metadata.xml')
|
||||
expected_calls = [call(constants.AVAILABLE_DIR, exist_ok=True),
|
||||
call(constants.FEED_OSTREE_BASE_DIR, exist_ok=True)]
|
||||
self.assertEqual(mock_makedirs.call_count, 2)
|
||||
|
Loading…
Reference in New Issue
Block a user