Fix subcloud fields update
This commit addresses the issue encountered when updating the subcloud fields directly with a file. This caused issues because the file would be closed, making the content inaccessible. Now, we create a variable containing the content and update the fields using only this content. Test Plan: PASS: Create a subcloud PASS: Update a subcloud PASS: Create a subcloud backup PASS: Subcloud deploy create PASS: Subcloud deploy upload Closes-bug: 2055446 Change-Id: Ib8b831353dba9d073131eb1c12ccd57513c63e7f Signed-off-by: Hugo Brito <hugo.brito@windriver.com>
This commit is contained in:
parent
a507c6449d
commit
ae9bae8680
|
@ -28,7 +28,8 @@ class phased_subcloud_deploy_manager(base.ResourceManager):
|
|||
fields = {}
|
||||
for k, v in body.items():
|
||||
with open(v, "rb") as file:
|
||||
fields.update({k: (v, file)})
|
||||
file_content = file.read()
|
||||
fields.update({k: (v, file_content)})
|
||||
fields.update(data)
|
||||
enc = MultipartEncoder(fields=fields)
|
||||
headers = {"content-type": enc.content_type}
|
||||
|
|
|
@ -24,7 +24,8 @@ class subcloud_backup_manager(base.ResourceManager):
|
|||
if files:
|
||||
for k, v in files.items():
|
||||
with open(v, "rb") as file:
|
||||
fields.update({k: (v, file)})
|
||||
file_content = file.read()
|
||||
fields.update({k: (v, file_content)})
|
||||
fields.update(data)
|
||||
enc = MultipartEncoder(fields=fields)
|
||||
headers = {"content-type": enc.content_type}
|
||||
|
@ -57,7 +58,8 @@ class subcloud_backup_manager(base.ResourceManager):
|
|||
if files:
|
||||
for k, v in files.items():
|
||||
with open(v, "rb") as file:
|
||||
fields.update({k: (v, file)})
|
||||
file_content = file.read()
|
||||
fields.update({k: (v, file_content)})
|
||||
fields.update(data)
|
||||
enc = MultipartEncoder(fields=fields)
|
||||
headers = {"content-type": enc.content_type}
|
||||
|
|
|
@ -74,7 +74,8 @@ class subcloud_deploy_manager(base.ResourceManager):
|
|||
fields = {}
|
||||
for k, v in files.items():
|
||||
with open(v, "rb") as file:
|
||||
fields.update({k: (v, file)})
|
||||
file_content = file.read()
|
||||
fields.update({k: (v, file_content)})
|
||||
fields.update(data)
|
||||
enc = MultipartEncoder(fields=fields)
|
||||
headers = {"content-type": enc.content_type}
|
||||
|
|
|
@ -33,7 +33,8 @@ class subcloud_manager(base.ResourceManager):
|
|||
fields = {}
|
||||
for k, v in body.items():
|
||||
with open(v, "rb") as file:
|
||||
fields.update({k: (v, file)})
|
||||
file_content = file.read()
|
||||
fields.update({k: (v, file_content)})
|
||||
fields.update(data)
|
||||
enc = MultipartEncoder(fields=fields)
|
||||
headers = {"content-type": enc.content_type}
|
||||
|
@ -50,7 +51,8 @@ class subcloud_manager(base.ResourceManager):
|
|||
if body:
|
||||
for k, v in body.items():
|
||||
with open(v, "rb") as file:
|
||||
fields.update({k: (v, file)})
|
||||
file_content = file.read()
|
||||
fields.update({k: (v, file_content)})
|
||||
fields.update(data)
|
||||
enc = MultipartEncoder(fields=fields)
|
||||
headers = {"content-type": enc.content_type}
|
||||
|
@ -66,7 +68,8 @@ class subcloud_manager(base.ResourceManager):
|
|||
fields = {}
|
||||
for k, v in body.items():
|
||||
with open(v, "rb") as file:
|
||||
fields.update({k: (v, file)})
|
||||
file_content = file.read()
|
||||
fields.update({k: (v, file_content)})
|
||||
fields.update(data)
|
||||
enc = MultipartEncoder(fields=fields)
|
||||
headers = {"content-type": enc.content_type}
|
||||
|
|
Loading…
Reference in New Issue