From f4691faa65c542654d776aeb0614d35c41ab42fd Mon Sep 17 00:00:00 2001
From: Juan Vidal <juan.vidal.allende@ericsson.com>
Date: Tue, 21 Feb 2017 13:10:47 +0000
Subject: [odl-sfc] Fix wait_for_vnf returning vnf_id on timeout

If the VNF does not properly boot after timeout, wait_for_vnf
should return "None" to flag the error.

Also, refresh the VNF on every iteration.

Change-Id: I9ed7c399e689dfbace7c5c8914552e77bf45fc8f
Signed-off-by: Juan Vidal <juan.vidal.allende@ericsson.com>
---
 functest/utils/openstack_tacker.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/functest/utils/openstack_tacker.py b/functest/utils/openstack_tacker.py
index 07acc8b3a..8327fdbe2 100644
--- a/functest/utils/openstack_tacker.py
+++ b/functest/utils/openstack_tacker.py
@@ -176,6 +176,11 @@ def wait_for_vnf(tacker_client, vnf_id=None, vnf_name=None, timeout=60):
             elif vnf['status'] == 'PENDING_CREATE':
                 time.sleep(3)
                 timeout -= 3
+            vnf = get_vnf(tacker_client, vnf_id, vnf_name)
+
+        if (timeout < 0):
+            raise Exception('Timeout when booting vnf %s' % vnf['id'])
+
         return vnf['id']
     except Exception, e:
         logger.error("error [wait_for_vnf(tacker_client, '%s', '%s')]: %s"
-- 
cgit