Bugfix: Dovetail tool will crash when hosts.yaml file with incorrect format 05/52705/2
authorxudan <xudan16@huawei.com>
Tue, 27 Feb 2018 06:54:02 +0000 (01:54 -0500)
committerGeorg Kunz <georg.kunz@ericsson.com>
Thu, 1 Mar 2018 14:21:03 +0000 (14:21 +0000)
commitc729d5c0b053eb7762426b78682fc0eeca033e81
tree35d82d22502e3cd577d7a08be84a1ac55c770bf7
parent5640d95a5d4ba0781ef66518dff57cf97a0a6431
Bugfix: Dovetail tool will crash when hosts.yaml file with incorrect format

If the hosts.yaml file is like,

hosts_info:
192.168.141.101:

it will raise an exception,
File "/usr/local/lib/python2.7/dist-packages/dovetail/utils/dovetail_utils.py",
line 227, in add_hosts_info
names=hostnames)
File "/usr/local/lib/python2.7/dist-packages/python_hosts/hosts.py",
line 54, in _init_
raise Exception('Address and Name(s) must be specified.')
Exception: Address and Name(s) must be specified.

If the hosts.yaml file is empty, it will crash with,
File "/usr/local/lib/python2.7/dist-packages/dovetail/container.py",
line 174, in create
if hosts_yaml['hosts_info']:
TypeError: 'NoneType' object has no attribute '_getitem_'

JIRA: DOVETAIL-621

Change-Id: I547928e514b3294c048379459c07df89879fbb03
Signed-off-by: xudan <xudan16@huawei.com>
dovetail/container.py
dovetail/utils/dovetail_utils.py