From fde62528afd5c88737999a3deabeba6c2d389e88 Mon Sep 17 00:00:00 2001
From: Dmitry Tantsur <dtantsur@redhat.com>
Date: Wed, 27 Jan 2016 17:10:58 +0100
Subject: [PATCH] [devstack] Restart nova compute before checking hypervisor
 stats

Nova compute may fail if it was unable to fetch nodes list from Ironic
during startup. This change makes sure we restart it.

Change-Id: Ibddd34faa0eeb9b42fe0e8d73f14907b1df11734
Closes-Bug: #1537076
---
 devstack/lib/ironic | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/devstack/lib/ironic b/devstack/lib/ironic
index 16432411f4..72797c6222 100644
--- a/devstack/lib/ironic
+++ b/devstack/lib/ironic
@@ -703,6 +703,11 @@ function enroll_nodes {
     nova flavor-key baremetal set "cpu_arch"="$ironic_node_arch"
 
     if [ "$VIRT_DRIVER" == "ironic" ]; then
+        # NOTE(dtantsur): sometimes nova compute fails to start with ironic due
+        # to keystone restarting and not being able to authenticate us.
+        # Restart it just to be sure (and avoid gate problems like bug 1537076)
+        stop_nova_compute
+        start_nova_compute
         wait_for_nova_resources "count" $total_nodes
         wait_for_nova_resources "vcpus" $total_cpus
     fi