Merge "Change how upload process acquire release id"

This commit is contained in:
Zuul 2024-04-19 18:18:10 +00:00 committed by Gerrit Code Review
commit c5a7d1d336
2 changed files with 6 additions and 7 deletions

View File

@ -73,6 +73,7 @@ from software.software_functions import audit_log_info
from software.software_functions import repo_root_dir
from software.software_functions import is_deploy_state_in_sync
from software.software_functions import is_deployment_in_progress
from software.software_functions import get_release_from_patch
from software.release_state import ReleaseState
from software.deploy_host_state import DeployHostState
from software.deploy_state import DeployState
@ -1343,11 +1344,9 @@ class PatchController(PatchService):
base_patch_filename = os.path.basename(patch_file)
# NOTE(bqian) does it make sense to link the release_id to name of the patch?
# Get the release_id from the filename
# Get the release_id from the patch's metadata
# and check to see if it's already uploaded
# todo(abailey) We should not require the ID as part of the file
(release_id, _) = os.path.splitext(base_patch_filename)
release_id = get_release_from_patch(patch_file,'id')
release = self.release_collection.get_release_by_id(release_id)

View File

@ -162,19 +162,19 @@ def write_xml_file(top,
outfile.write(minidom.parseString(rough_xml).toprettyxml(indent=" "))
def get_release_from_patch(patchfile):
def get_release_from_patch(patchfile, key="sw_version"):
rel = ""
try:
metadata_str = subprocess.check_output(['tar', '--to-command=tar -xO', '-xf', patchfile, 'metadata.tar'])
root = ElementTree.fromstring(metadata_str)
# Extract release version
rel = root.findtext('sw_version')
rel = root.findtext(key)
except subprocess.CalledProcessError as e:
LOG.error("Failed to run tar command")
LOG.error("Command output: %s", e.output)
raise e
except Exception as e:
print("Failed to parse patch software version")
print("Failed to parse patch %s" % key)
raise e
return rel