From 20e2ac9cbd666ea1e856c24d3ccd6f44e99d2df1 Mon Sep 17 00:00:00 2001
From: Rafal Lewandowski <rafal@stackhpc.com>
Date: Wed, 14 Sep 2022 11:01:53 +0200
Subject: [PATCH] Update write_bifrost_clouds_yaml logic

This is changed in order to facilitate running Ironic checks before
OpenStack is deployed.

Change-Id: Ibc4c9c93f52414c23cd7d8b4f1b32c85cb233681
---
 dev/functions | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/dev/functions b/dev/functions
index 32baa331..3b9f3be2 100644
--- a/dev/functions
+++ b/dev/functions
@@ -621,16 +621,22 @@ function overcloud_test {
 }
 
 function write_bifrost_clouds_yaml {
-    # Generate a clouds.yaml for accessing the Ironic API in Bifrost.
+    SEED_IP="192.168.33.5"
+    
+    # Pull clouds.yaml from Bifrost container and change certificate path.
     if [[ ! -f ~/.config/openstack/clouds.yaml ]]; then
         mkdir -p ~/.config/openstack
-        cat << EOF > ~/.config/openstack/clouds.yaml
----
-clouds:
-  bifrost:
-    auth_type: "none"
-    endpoint: http://192.168.33.5:6385
-EOF
+        scp stack@$SEED_IP:/home/stack/.config/openstack/clouds.yaml ~/.config/openstack/clouds.yaml
+        sed -i 's|/home/stack/.config/openstack/bifrost.crt|~/.config/bifrost/bifrost.crt|g' ~/.config/openstack/clouds.yaml
+    else
+        echo "Not updating clouds.yaml file because it already exists at $HOME/.config/openstack/clouds.yaml. Try removing it if authentication against Bifrost fails."
+    fi
+    #Pull Bifrost PEM certificate from seed.
+    if [[ ! -f ~/.config/openstack/bifrost.crt ]]; then
+        mkdir -p ~/.config/openstack
+        scp stack@$SEED_IP:/home/stack/.config/openstack/bifrost.crt ~/.config/openstack/bifrost.crt
+    else
+        echo "Not updating Bifrost certificate file because it already exists at $HOME/.config/openstack/bifrost.crt. Try removing it if authentication against Bifrost fails."
     fi
 }
 
-- 
GitLab