Browse code

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

Monty Taylor authored on 2015/09/20 00:26:18
Showing 2 changed files
... ...
@@ -67,6 +67,45 @@ function save_stackenv {
67 67
     done
68 68
 }
69 69
 
70
+# Update/create user clouds.yaml file.
71
+# clouds.yaml will have
72
+# - A `devstack` entry for the `demo` user for the `demo` project.
73
+# - A `devstack-admin` entry for the `admin` user for the `admin` project.
74
+# write_clouds_yaml
75
+function write_clouds_yaml {
76
+    # The location is a variable to allow for easier refactoring later to make it
77
+    # overridable. There is currently no usecase where doing so makes sense, so
78
+    # it's not currently configurable.
79
+    CLOUDS_YAML=~/.config/openstack/clouds.yaml
80
+
81
+    mkdir -p $(dirname $CLOUDS_YAML)
82
+
83
+    CA_CERT_ARG=''
84
+    if [ -f "$SSL_BUNDLE_FILE" ]; then
85
+        CA_CERT_ARG="--os-cacert $SSL_BUNDLE_FILE"
86
+    fi
87
+    $TOP_DIR/tools/update_clouds_yaml.py \
88
+        --file $CLOUDS_YAML \
89
+        --os-cloud devstack \
90
+        --os-region-name $REGION_NAME \
91
+        --os-identity-api-version $IDENTITY_API_VERSION \
92
+        $CA_CERT_ARG \
93
+        --os-auth-url $KEYSTONE_AUTH_URI/v$IDENTITY_API_VERSION \
94
+        --os-username demo \
95
+        --os-password $ADMIN_PASSWORD \
96
+        --os-project-name demo
97
+    $TOP_DIR/tools/update_clouds_yaml.py \
98
+        --file $CLOUDS_YAML \
99
+        --os-cloud devstack-admin \
100
+        --os-region-name $REGION_NAME \
101
+        --os-identity-api-version $IDENTITY_API_VERSION \
102
+        $CA_CERT_ARG \
103
+        --os-auth-url $KEYSTONE_AUTH_URI/v$IDENTITY_API_VERSION \
104
+        --os-username admin \
105
+        --os-password $ADMIN_PASSWORD \
106
+        --os-project-name admin
107
+}
108
+
70 109
 # Normalize config values to True or False
71 110
 # Accepts as False: 0 no No NO false False FALSE
72 111
 # Accepts as True: 1 yes Yes YES true True TRUE
... ...
@@ -1064,42 +1064,8 @@ fi
1064 1064
 # Save some values we generated for later use
1065 1065
 save_stackenv
1066 1066
 
1067
-# Update/create user clouds.yaml file.
1068
-# clouds.yaml will have
1069
-# - A `devstack` entry for the `demo` user for the `demo` project.
1070
-# - A `devstack-admin` entry for the `admin` user for the `admin` project.
1071
-
1072
-# The location is a variable to allow for easier refactoring later to make it
1073
-# overridable. There is currently no usecase where doing so makes sense, so
1074
-# it's not currently configurable.
1075
-CLOUDS_YAML=~/.config/openstack/clouds.yaml
1076
-
1077
-mkdir -p $(dirname $CLOUDS_YAML)
1078
-
1079
-CA_CERT_ARG=''
1080
-if [ -f "$SSL_BUNDLE_FILE" ]; then
1081
-    CA_CERT_ARG="--os-cacert $SSL_BUNDLE_FILE"
1082
-fi
1083
-$TOP_DIR/tools/update_clouds_yaml.py \
1084
-    --file $CLOUDS_YAML \
1085
-    --os-cloud devstack \
1086
-    --os-region-name $REGION_NAME \
1087
-    --os-identity-api-version $IDENTITY_API_VERSION \
1088
-    $CA_CERT_ARG \
1089
-    --os-auth-url $KEYSTONE_AUTH_URI/v$IDENTITY_API_VERSION \
1090
-    --os-username demo \
1091
-    --os-password $ADMIN_PASSWORD \
1092
-    --os-project-name demo
1093
-$TOP_DIR/tools/update_clouds_yaml.py \
1094
-    --file $CLOUDS_YAML \
1095
-    --os-cloud devstack-admin \
1096
-    --os-region-name $REGION_NAME \
1097
-    --os-identity-api-version $IDENTITY_API_VERSION \
1098
-    $CA_CERT_ARG \
1099
-    --os-auth-url $KEYSTONE_AUTH_URI/v$IDENTITY_API_VERSION \
1100
-    --os-username admin \
1101
-    --os-password $ADMIN_PASSWORD \
1102
-    --os-project-name admin
1067
+# Write a clouds.yaml file
1068
+write_clouds_yaml
1103 1069
 
1104 1070
 # Horizon
1105 1071
 # -------