PR to fix the issue of keyerror in Nios api (#49183)

* ipv4addr keyerror fix

Signed-off-by: Sumit Jaiswal <sjaiswal@redhat.com>

* fix review comment

Signed-off-by: Sumit Jaiswal <sjaiswal@redhat.com>
This commit is contained in:
Sumit Jaiswal 2019-01-10 09:50:48 +05:30 committed by GitHub
parent 3784abc96a
commit 40a806d156
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -230,7 +230,8 @@ class WapiModule(WapiBase):
if ib_obj_ref:
if len(ib_obj_ref) > 1:
for each in ib_obj_ref:
if each['ipv4addr'] == proposed_object['ipv4addr']:
if ('ipv4addr' in each) and ('ipv4addr' in proposed_object)\
and each['ipv4addr'] == proposed_object['ipv4addr']:
current_object = each
else:
current_object = ib_obj_ref[0]