Extract writing clouds.yaml to function
It's a bit wordy to be directly in stack.sh and not in a function.
Change-Id: Ibddfd8018d861191f1b1dc3270e0e81c274733cd
diff --git a/functions-common b/functions-common
index 446de53..4fca80e 100644
--- a/functions-common
+++ b/functions-common
@@ -67,6 +67,45 @@
done
}
+# Update/create user clouds.yaml file.
+# clouds.yaml will have
+# - A `devstack` entry for the `demo` user for the `demo` project.
+# - A `devstack-admin` entry for the `admin` user for the `admin` project.
+# write_clouds_yaml
+function write_clouds_yaml {
+ # The location is a variable to allow for easier refactoring later to make it
+ # overridable. There is currently no usecase where doing so makes sense, so
+ # it's not currently configurable.
+ CLOUDS_YAML=~/.config/openstack/clouds.yaml
+
+ mkdir -p $(dirname $CLOUDS_YAML)
+
+ CA_CERT_ARG=''
+ if [ -f "$SSL_BUNDLE_FILE" ]; then
+ CA_CERT_ARG="--os-cacert $SSL_BUNDLE_FILE"
+ fi
+ $TOP_DIR/tools/update_clouds_yaml.py \
+ --file $CLOUDS_YAML \
+ --os-cloud devstack \
+ --os-region-name $REGION_NAME \
+ --os-identity-api-version $IDENTITY_API_VERSION \
+ $CA_CERT_ARG \
+ --os-auth-url $KEYSTONE_AUTH_URI/v$IDENTITY_API_VERSION \
+ --os-username demo \
+ --os-password $ADMIN_PASSWORD \
+ --os-project-name demo
+ $TOP_DIR/tools/update_clouds_yaml.py \
+ --file $CLOUDS_YAML \
+ --os-cloud devstack-admin \
+ --os-region-name $REGION_NAME \
+ --os-identity-api-version $IDENTITY_API_VERSION \
+ $CA_CERT_ARG \
+ --os-auth-url $KEYSTONE_AUTH_URI/v$IDENTITY_API_VERSION \
+ --os-username admin \
+ --os-password $ADMIN_PASSWORD \
+ --os-project-name admin
+}
+
# Normalize config values to True or False
# Accepts as False: 0 no No NO false False FALSE
# Accepts as True: 1 yes Yes YES true True TRUE
diff --git a/stack.sh b/stack.sh
index 7184e59..2176021 100755
--- a/stack.sh
+++ b/stack.sh
@@ -1064,42 +1064,8 @@
# Save some values we generated for later use
save_stackenv
-# Update/create user clouds.yaml file.
-# clouds.yaml will have
-# - A `devstack` entry for the `demo` user for the `demo` project.
-# - A `devstack-admin` entry for the `admin` user for the `admin` project.
-
-# The location is a variable to allow for easier refactoring later to make it
-# overridable. There is currently no usecase where doing so makes sense, so
-# it's not currently configurable.
-CLOUDS_YAML=~/.config/openstack/clouds.yaml
-
-mkdir -p $(dirname $CLOUDS_YAML)
-
-CA_CERT_ARG=''
-if [ -f "$SSL_BUNDLE_FILE" ]; then
- CA_CERT_ARG="--os-cacert $SSL_BUNDLE_FILE"
-fi
-$TOP_DIR/tools/update_clouds_yaml.py \
- --file $CLOUDS_YAML \
- --os-cloud devstack \
- --os-region-name $REGION_NAME \
- --os-identity-api-version $IDENTITY_API_VERSION \
- $CA_CERT_ARG \
- --os-auth-url $KEYSTONE_AUTH_URI/v$IDENTITY_API_VERSION \
- --os-username demo \
- --os-password $ADMIN_PASSWORD \
- --os-project-name demo
-$TOP_DIR/tools/update_clouds_yaml.py \
- --file $CLOUDS_YAML \
- --os-cloud devstack-admin \
- --os-region-name $REGION_NAME \
- --os-identity-api-version $IDENTITY_API_VERSION \
- $CA_CERT_ARG \
- --os-auth-url $KEYSTONE_AUTH_URI/v$IDENTITY_API_VERSION \
- --os-username admin \
- --os-password $ADMIN_PASSWORD \
- --os-project-name admin
+# Write a clouds.yaml file
+write_clouds_yaml
# Horizon
# -------