From 78f66a17b2b32270e3dd705295e652a95724b8e3 Mon Sep 17 00:00:00 2001 From: Guido Trotter <ultrotter@google.com> Date: Tue, 27 Jan 2009 16:44:23 +0000 Subject: [PATCH] Xen: use utils.Readfile to read the VNC password Also raise HypervisorError rather than OpExecError. Reviewed-by: iustinp --- lib/hypervisor/hv_xen.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/hypervisor/hv_xen.py b/lib/hypervisor/hv_xen.py index 5b71ff234..8007a5bd2 100644 --- a/lib/hypervisor/hv_xen.py +++ b/lib/hypervisor/hv_xen.py @@ -587,14 +587,10 @@ class XenHvmHypervisor(XenHypervisor): config.write("vncunused = 1\n") try: - password_file = open(constants.VNC_PASSWORD_FILE, "r") - try: - password = password_file.readline() - finally: - password_file.close() - except IOError: - raise errors.OpExecError("failed to open VNC password file %s " % - constants.VNC_PASSWORD_FILE) + password = utils.ReadFile(constants.VNC_PASSWORD_FILE) + except EnvironmentError, err: + raise errors.HypervisorError("Failed to open VNC password file %s: %s" % + (constants.VNC_PASSWORD_FILE, err)) config.write("vncpasswd = '%s'\n" % password.rstrip()) -- GitLab