Change how upload process acquire release id
Upload process should not require the release id to be part of patch filename. This change allows us to directly get release id from the metadata inside the patch file. Test Plan: PASS: Successfully upload patch with different filename from release id using software upload command. PASS: Successfully upload patch with filename same as release id using software upload command. PASS: Successfully upload multiple patches with different filename from release id using software upload-dir command. PASS: Successfully upload multiple patches with filename same as release id using software upload-dir command. Story: 2010676 Task: 49868 Change-Id: Ibd5bcf9b8797b5de0eef3e46313055cc141da0b2 Signed-off-by: Dostoievski Batista <dostoievski.albinobatista@windriver.com>
This commit is contained in:
parent
24016bd363
commit
0670d53b44
|
@ -72,6 +72,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
|
||||
|
@ -1342,11 +1343,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)
|
||||
|
||||
|
|
|
@ -160,19 +160,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
|
||||
|
||||
|
|
Loading…
Reference in New Issue