Fix HNAS driver confusing error message

The error message shown when the parser finds a parser error
says, 'file not found' which causes confusion on the user when
he/she needs to debug the real cause o the problem. This patch fix
this by testing first if the file exist and then throwing a
proper error message.

Closes-Bug: #1402775
Change-Id: I91c7a24d5da37735787e8fc0da544c8ba8204884
This commit is contained in:
Erlon R. Cruz 2014-12-11 08:46:31 -02:00
parent 5259bd7f60
commit 6cc497b468

View File

@ -82,11 +82,15 @@ def _read_config(xml_config_file):
:param xml_config_file: string filename containing XML configuration
"""
if not os.access(xml_config_file, os.R_OK):
raise exception.NotFound(message=_LE('Can\'t open config file: ')
+ xml_config_file)
try:
root = ETree.parse(xml_config_file).getroot()
except Exception:
raise exception.NotFound(message='config file not found: '
+ xml_config_file)
raise exception.ConfigNotFound(
message=_LE('Error parsing config file: ') + xml_config_file)
# mandatory parameters
config = {}