From b0ba58d5360bb42ed9dffa347c44dd8530ade3e0 Mon Sep 17 00:00:00 2001
From: Jorge Niedbalski <jorge.niedbalski@linaro.org>
Date: Mon, 30 Apr 2018 14:27:29 -0300
Subject: [PATCH] List and map compute hosts by service instead of by compute
 node.

This commit adds the --by-service flag in the discover_hosts
command of the nova cell subsystem, using this flag,
hosts are mapped based on the existing nova-compute services instead
of using the compute node reference.

In this way, we can ensure that the host mappings exists
for this new host (and create it if not) preventing the
HostMappingNotFound exception to loop over and over.

Bug: #1768094
Change-Id: I948004031bc3e125f929ed3e6c670aea11e73a31
Signed-off-by: Jorge Niedbalski <jorge.niedbalski@linaro.org>
---
 ansible/roles/nova/tasks/simple_cell_setup.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ansible/roles/nova/tasks/simple_cell_setup.yml b/ansible/roles/nova/tasks/simple_cell_setup.yml
index bbebfb5930..775842bda6 100644
--- a/ansible/roles/nova/tasks/simple_cell_setup.yml
+++ b/ansible/roles/nova/tasks/simple_cell_setup.yml
@@ -50,7 +50,7 @@
 
 - name: Discovering nova hosts
   command: >
-    docker exec nova_api nova-manage cell_v2 discover_hosts
+    docker exec nova_api nova-manage cell_v2 discover_hosts --by-service
   register: discover_hosts
   changed_when: False
   run_once: True