Subcloud deploy fails

Deploy config generated by dcmanager does not truncate the existing
file after it has been overridden. This leaves some invalid content
at the end of the newly generated file. Fixes have been made for this.

Change-Id: I6c7e7fbacb1ee323c3675076083e046498698425
Closes-Bug: 1882826
Signed-off-by: Jessica Castelino <jessica.castelino@windriver.com>
This commit is contained in:
Jessica Castelino 2020-06-09 13:43:04 -04:00
parent bd35524bf2
commit 70f4dc8537

View File

@ -126,8 +126,8 @@ class SubcloudsController(object):
fn = os.path.join(consts.ANSIBLE_OVERRIDES_PATH, payload['name']
+ '_' + os.path.basename(filename))
try:
dst = os.open(fn, os.O_WRONLY | os.O_CREAT)
os.write(dst, contents)
with open(fn, "w") as f:
f.write(contents)
except Exception:
msg = _("Failed to upload %s file" % consts.DEPLOY_CONFIG)
LOG.exception(msg)