Skip to content
Snippets Groups Projects
Commit 73cd67f4 authored by Guido Trotter's avatar Guido Trotter
Browse files

Xen: use utils.WriteFile for the instance configs

Also raise HypervisorError rather than OpExecError.

Reviewed-by: iustinp
parent 78f66a17
No related branches found
No related tags found
No related merge requests found
...@@ -458,14 +458,13 @@ class XenPvmHypervisor(XenHypervisor): ...@@ -458,14 +458,13 @@ class XenPvmHypervisor(XenHypervisor):
# 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)
try: try:
f = open("/etc/xen/%s" % instance.name, "w") utils.WriteFile("/etc/xen/%s" % instance.name,
try: data=config.getvalue())
f.write(config.getvalue()) except EnvironmentError, err:
finally: raise errors.HypervisorError("Cannot write Xen instance confile"
f.close() " file /etc/xen/%s: %s" %
except IOError, err: (instance.name, err))
raise errors.OpExecError("Cannot write Xen instance confile"
" file /etc/xen/%s: %s" % (instance.name, err))
return True return True
...@@ -637,12 +636,11 @@ class XenHvmHypervisor(XenHypervisor): ...@@ -637,12 +636,11 @@ class XenHvmHypervisor(XenHypervisor):
# 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)
try: try:
f = open("/etc/xen/%s" % instance.name, "w") utils.WriteFile("/etc/xen/%s" % instance.name,
try: data=config.getvalue())
f.write(config.getvalue()) except EnvironmentError, err:
finally: raise errors.HypervisorError("Cannot write Xen instance confile"
f.close() " file /etc/xen/%s: %s" %
except IOError, err: (instance.name, err))
raise errors.OpExecError("Cannot write Xen instance confile"
" file /etc/xen/%s: %s" % (instance.name, err))
return True return True
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