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
......@@ -458,14 +458,13 @@ class XenPvmHypervisor(XenHypervisor):
# just in case it exists
utils.RemoveFile("/etc/xen/auto/%s" % instance.name)
try:
f = open("/etc/xen/%s" % instance.name, "w")
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))
utils.WriteFile("/etc/xen/%s" % instance.name,
data=config.getvalue())
except EnvironmentError, err:
raise errors.HypervisorError("Cannot write Xen instance confile"
" file /etc/xen/%s: %s" %
(instance.name, err))
return True
......@@ -637,12 +636,11 @@ class XenHvmHypervisor(XenHypervisor):
# just in case it exists
utils.RemoveFile("/etc/xen/auto/%s" % instance.name)
try:
f = open("/etc/xen/%s" % instance.name, "w")
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))
utils.WriteFile("/etc/xen/%s" % instance.name,
data=config.getvalue())
except EnvironmentError, err:
raise errors.HypervisorError("Cannot write Xen instance confile"
" file /etc/xen/%s: %s" %
(instance.name, err))
return True
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment