Revert "Optimize list express to list generator" 97/38797/1
authorZhijiang Hu <hu.zhijiang@zte.com.cn>
Sat, 5 Aug 2017 00:25:35 +0000 (08:25 +0800)
committerZhijiang Hu <hu.zhijiang@zte.com.cn>
Sat, 5 Aug 2017 00:25:35 +0000 (08:25 +0800)
This reverts commit e5a787046aff97a9925a35874d2b6535a9a41c0c.

Trying to solve [1]

Deploy failed!!!.Traceback (most recent call last):
  File "/home/daisy/deploy/tempest.py", line 94, in prepare_install
    host_interface_map, vip, isbare)
  File "/home/daisy/deploy/tempest.py", line 216, in add_hosts_interface
    add_host_role(cluster_id, host['id'], host_name, host['name'], vip)
  File "/home/daisy/deploy/tempest.py", line 225, in add_host_role
    role.name == "COMPUTER"][0]
IndexError: list index out of range

[1] https://build.opnfv.org/ci/job/daisy-deploy-daily-master/626/consoleFull

Change-Id: I4017b4b38fa350a28d9e9dd5b157caab885a80d0
Signed-off-by: Zhijiang Hu <hu.zhijiang@zte.com.cn>
deploy/tempest.py

index f9f9e97..b154e72 100644 (file)
@@ -219,9 +219,10 @@ def add_hosts_interface(cluster_id, hosts_info, hosts_name, mac_address_map,
 def add_host_role(cluster_id, host_id, host_exp_name, host_real_name, vip):
     role_meta = {'filters': {'cluster_id': cluster_id}}
     role_list_generator = client.roles.list(**role_meta)
-    lb_role_id = [role.id for role in role_list_generator if
+    role_list = [role for role in role_list_generator]
+    lb_role_id = [role.id for role in role_list if
                   role.name == "CONTROLLER_LB"][0]
-    computer_role_id = [role.id for role in role_list_generator if
+    computer_role_id = [role.id for role in role_list if
                         role.name == "COMPUTER"][0]
     if host_exp_name in ['all_in_one']:
         role_lb_update_meta = {'nodes': [host_id],