Skip to content
Snippets Groups Projects
Commit 01121d61 authored by Alexander Schreiber's avatar Alexander Schreiber
Browse files

Error handling for instance config file creation

Wrap error handling around creating the instance config file.

Reviewed-by: iustinp
parent 631eb662
No related branches found
No related tags found
No related merge requests found
...@@ -347,9 +347,15 @@ class XenPvmHypervisor(XenHypervisor): ...@@ -347,9 +347,15 @@ class XenPvmHypervisor(XenHypervisor):
config.write("extra = '%s'\n" % extra_args) config.write("extra = '%s'\n" % extra_args)
# just in case it exists # just in case it exists
utils.RemoveFile("/etc/xen/auto/%s" % instance.name) utils.RemoveFile("/etc/xen/auto/%s" % instance.name)
f = open("/etc/xen/%s" % instance.name, "w") try:
f.write(config.getvalue()) f = open("/etc/xen/%s" % instance.name, "w")
f.close() try:
f.write(config.getvalue())
finally:
f.close()
except IOError, err:
raise errors.OpExecError("Cannot write Xen instance confile"
" file /etc/xen/%s: %s" % (instance.name, err))
return True return True
@staticmethod @staticmethod
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment