* Put all config files in /etc/keystone
* keystone.conf rewritten
* logging.conf.sample rewritten to logging.conf
* default_catalog.templates copied from devstack/files
* iniset() now properly adds options that do not previously exist
Fixed to re-configure the catalog templated backend; sql is the
default in trunk now but DevStack needs a bit more work before
it can use it.
Change-Id: Ic7060ef897e47495cd08ca3786e49fdebadf6723
| 1 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,99 +0,0 @@ |
| 1 |
-[DEFAULT] |
|
| 2 |
-bind_host = 0.0.0.0 |
|
| 3 |
-public_port = 5000 |
|
| 4 |
-admin_port = 35357 |
|
| 5 |
-admin_token = %SERVICE_TOKEN% |
|
| 6 |
-compute_port = 3000 |
|
| 7 |
-verbose = True |
|
| 8 |
-debug = True |
|
| 9 |
-# commented out so devstack logs to stdout |
|
| 10 |
-# log_file = %DEST%/keystone/keystone.log |
|
| 11 |
- |
|
| 12 |
-# ================= Syslog Options ============================ |
|
| 13 |
-# Send logs to syslog (/dev/log) instead of to file specified |
|
| 14 |
-# by `log-file` |
|
| 15 |
-use_syslog = False |
|
| 16 |
- |
|
| 17 |
-# Facility to use. If unset defaults to LOG_USER. |
|
| 18 |
-# syslog_log_facility = LOG_LOCAL0 |
|
| 19 |
- |
|
| 20 |
-[sql] |
|
| 21 |
-connection = %SQL_CONN% |
|
| 22 |
-idle_timeout = 30 |
|
| 23 |
-min_pool_size = 5 |
|
| 24 |
-max_pool_size = 10 |
|
| 25 |
-pool_timeout = 200 |
|
| 26 |
- |
|
| 27 |
-[identity] |
|
| 28 |
-driver = keystone.identity.backends.sql.Identity |
|
| 29 |
- |
|
| 30 |
-[catalog] |
|
| 31 |
-driver = keystone.catalog.backends.templated.TemplatedCatalog |
|
| 32 |
-template_file = %KEYSTONE_DIR%/etc/default_catalog.templates |
|
| 33 |
- |
|
| 34 |
-[token] |
|
| 35 |
-driver = keystone.token.backends.kvs.Token |
|
| 36 |
- |
|
| 37 |
-[policy] |
|
| 38 |
-driver = keystone.policy.backends.rules.Policy |
|
| 39 |
- |
|
| 40 |
-[ec2] |
|
| 41 |
-driver = keystone.contrib.ec2.backends.sql.Ec2 |
|
| 42 |
- |
|
| 43 |
-[filter:debug] |
|
| 44 |
-paste.filter_factory = keystone.common.wsgi:Debug.factory |
|
| 45 |
- |
|
| 46 |
-[filter:token_auth] |
|
| 47 |
-paste.filter_factory = keystone.middleware:TokenAuthMiddleware.factory |
|
| 48 |
- |
|
| 49 |
-[filter:admin_token_auth] |
|
| 50 |
-paste.filter_factory = keystone.middleware:AdminTokenAuthMiddleware.factory |
|
| 51 |
- |
|
| 52 |
-[filter:xml_body] |
|
| 53 |
-paste.filter_factory = keystone.middleware:XmlBodyMiddleware.factory |
|
| 54 |
- |
|
| 55 |
-[filter:json_body] |
|
| 56 |
-paste.filter_factory = keystone.middleware:JsonBodyMiddleware.factory |
|
| 57 |
- |
|
| 58 |
-[filter:crud_extension] |
|
| 59 |
-paste.filter_factory = keystone.contrib.admin_crud:CrudExtension.factory |
|
| 60 |
- |
|
| 61 |
-[filter:ec2_extension] |
|
| 62 |
-paste.filter_factory = keystone.contrib.ec2:Ec2Extension.factory |
|
| 63 |
- |
|
| 64 |
-[filter:s3_extension] |
|
| 65 |
-paste.filter_factory = keystone.contrib.s3:S3Extension.factory |
|
| 66 |
- |
|
| 67 |
-[app:public_service] |
|
| 68 |
-paste.app_factory = keystone.service:public_app_factory |
|
| 69 |
- |
|
| 70 |
-[app:admin_service] |
|
| 71 |
-paste.app_factory = keystone.service:admin_app_factory |
|
| 72 |
- |
|
| 73 |
-[pipeline:public_api] |
|
| 74 |
-pipeline = token_auth admin_token_auth xml_body json_body debug ec2_extension public_service |
|
| 75 |
- |
|
| 76 |
-[pipeline:admin_api] |
|
| 77 |
-pipeline = token_auth admin_token_auth xml_body json_body debug ec2_extension s3_extension crud_extension admin_service |
|
| 78 |
- |
|
| 79 |
-[app:public_version_service] |
|
| 80 |
-paste.app_factory = keystone.service:public_version_app_factory |
|
| 81 |
- |
|
| 82 |
-[app:admin_version_service] |
|
| 83 |
-paste.app_factory = keystone.service:admin_version_app_factory |
|
| 84 |
- |
|
| 85 |
-[pipeline:public_version_api] |
|
| 86 |
-pipeline = xml_body public_version_service |
|
| 87 |
- |
|
| 88 |
-[pipeline:admin_version_api] |
|
| 89 |
-pipeline = xml_body admin_version_service |
|
| 90 |
- |
|
| 91 |
-[composite:main] |
|
| 92 |
-use = egg:Paste#urlmap |
|
| 93 |
-/v2.0 = public_api |
|
| 94 |
-/ = public_version_api |
|
| 95 |
- |
|
| 96 |
-[composite:admin] |
|
| 97 |
-use = egg:Paste#urlmap |
|
| 98 |
-/v2.0 = admin_api |
|
| 99 |
-/ = admin_version_api |
| ... | ... |
@@ -184,7 +184,7 @@ function git_clone {
|
| 184 | 184 |
|
| 185 | 185 |
|
| 186 | 186 |
# Comment an option in an INI file |
| 187 |
-# optset config-file section option |
|
| 187 |
+# iniset config-file section option |
|
| 188 | 188 |
function inicomment() {
|
| 189 | 189 |
local file=$1 |
| 190 | 190 |
local section=$2 |
| ... | ... |
@@ -194,7 +194,7 @@ function inicomment() {
|
| 194 | 194 |
|
| 195 | 195 |
|
| 196 | 196 |
# Get an option from an INI file |
| 197 |
-# optget config-file section option |
|
| 197 |
+# iniget config-file section option |
|
| 198 | 198 |
function iniget() {
|
| 199 | 199 |
local file=$1 |
| 200 | 200 |
local section=$2 |
| ... | ... |
@@ -206,16 +206,25 @@ function iniget() {
|
| 206 | 206 |
|
| 207 | 207 |
|
| 208 | 208 |
# Set an option in an INI file |
| 209 |
-# This is NOT a complete option setter, it assumes that the section and |
|
| 210 |
-# option already exist in the INI file. If the section does not exist, |
|
| 211 |
-# nothing happens. |
|
| 212 |
-# optset config-file section option value |
|
| 209 |
+# iniset config-file section option value |
|
| 213 | 210 |
function iniset() {
|
| 214 | 211 |
local file=$1 |
| 215 | 212 |
local section=$2 |
| 216 | 213 |
local option=$3 |
| 217 | 214 |
local value=$4 |
| 218 |
- sed -i -e "/^\[$section\]/,/^\[.*\]/ s|^\($option[ \t]*=[ \t]*\).*$|\1$value|" $file |
|
| 215 |
+ if ! grep -q "^\[$section\]" $file; then |
|
| 216 |
+ # Add section at the end |
|
| 217 |
+ echo -e "\n[$section]" >>$file |
|
| 218 |
+ fi |
|
| 219 |
+ if [[ -z "$(iniget $file $section $option)" ]]; then |
|
| 220 |
+ # Add it |
|
| 221 |
+ sed -i -e "/^\[$section\]/ a\\ |
|
| 222 |
+$option = $value |
|
| 223 |
+" $file |
|
| 224 |
+ else |
|
| 225 |
+ # Replace it |
|
| 226 |
+ sed -i -e "/^\[$section\]/,/^\[.*\]/ s|^\($option[ \t]*=[ \t]*\).*$|\1$value|" $file |
|
| 227 |
+ fi |
|
| 219 | 228 |
} |
| 220 | 229 |
|
| 221 | 230 |
|
| ... | ... |
@@ -1514,16 +1514,42 @@ if is_service_enabled key; then |
| 1514 | 1514 |
mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'DROP DATABASE IF EXISTS keystone;' |
| 1515 | 1515 |
mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'CREATE DATABASE keystone CHARACTER SET utf8;' |
| 1516 | 1516 |
|
| 1517 |
- # Configure keystone.conf |
|
| 1518 |
- KEYSTONE_CONF=$KEYSTONE_DIR/etc/keystone.conf |
|
| 1519 |
- cp $FILES/keystone.conf $KEYSTONE_CONF |
|
| 1520 |
- sudo sed -e "s,%SQL_CONN%,$BASE_SQL_CONN/keystone?charset=utf8,g" -i $KEYSTONE_CONF |
|
| 1521 |
- sudo sed -e "s,%DEST%,$DEST,g" -i $KEYSTONE_CONF |
|
| 1522 |
- sudo sed -e "s,%SERVICE_TOKEN%,$SERVICE_TOKEN,g" -i $KEYSTONE_CONF |
|
| 1523 |
- sudo sed -e "s,%KEYSTONE_DIR%,$KEYSTONE_DIR,g" -i $KEYSTONE_CONF |
|
| 1517 |
+ KEYSTONE_CONF_DIR=${KEYSTONE_CONF_DIR:-/etc/keystone}
|
|
| 1518 |
+ KEYSTONE_CONF=$KEYSTONE_CONF_DIR/keystone.conf |
|
| 1519 |
+ KEYSTONE_CATALOG=$KEYSTONE_CONF_DIR/default_catalog.templates |
|
| 1524 | 1520 |
|
| 1525 |
- KEYSTONE_CATALOG=$KEYSTONE_DIR/etc/default_catalog.templates |
|
| 1526 |
- cp $FILES/default_catalog.templates $KEYSTONE_CATALOG |
|
| 1521 |
+ if [[ ! -d $KEYSTONE_CONF_DIR ]]; then |
|
| 1522 |
+ sudo mkdir -p $KEYSTONE_CONF_DIR |
|
| 1523 |
+ sudo chown `whoami` $KEYSTONE_CONF_DIR |
|
| 1524 |
+ fi |
|
| 1525 |
+ |
|
| 1526 |
+ if [[ "$KEYSTONE_CONF_DIR" != "$KEYSTONE_DIR/etc" ]]; then |
|
| 1527 |
+ # FIXME(dtroyer): etc/keystone.conf causes trouble if the config files |
|
| 1528 |
+ # are located anywhere else (say, /etc/keystone). |
|
| 1529 |
+ # LP 966670 fixes this in keystone, we fix it |
|
| 1530 |
+ # here until the bug fix is committed. |
|
| 1531 |
+ if [[ -r $KEYSTONE_DIR/etc/keystone.conf ]]; then |
|
| 1532 |
+ # Get the sample config file out of the way |
|
| 1533 |
+ mv $KEYSTONE_DIR/etc/keystone.conf $KEYSTONE_DIR/etc/keystone.conf.sample |
|
| 1534 |
+ fi |
|
| 1535 |
+ cp -p $KEYSTONE_DIR/etc/keystone.conf.sample $KEYSTONE_CONF |
|
| 1536 |
+ cp -p $KEYSTONE_DIR/etc/policy.json $KEYSTONE_CONF_DIR |
|
| 1537 |
+ fi |
|
| 1538 |
+ cp -p $FILES/default_catalog.templates $KEYSTONE_CATALOG |
|
| 1539 |
+ |
|
| 1540 |
+ # Rewrite stock keystone.conf: |
|
| 1541 |
+ iniset $KEYSTONE_CONF DEFAULT admin_token "$SERVICE_TOKEN" |
|
| 1542 |
+ iniset $KEYSTONE_CONF sql connection "$BASE_SQL_CONN/keystone?charset=utf8" |
|
| 1543 |
+ iniset $KEYSTONE_CONF catalog template_file "$KEYSTONE_CATALOG" |
|
| 1544 |
+ iniset $KEYSTONE_CONF ec2 driver "keystone.contrib.ec2.backends.sql.Ec2" |
|
| 1545 |
+ # Configure keystone.conf to use templates |
|
| 1546 |
+ iniset $KEYSTONE_CONF catalog driver "keystone.catalog.backends.templated.TemplatedCatalog" |
|
| 1547 |
+ iniset $KEYSTONE_CONF catalog template_file "$KEYSTONE_CATALOG" |
|
| 1548 |
+ sed -e " |
|
| 1549 |
+ /^pipeline.*ec2_extension crud_/s|ec2_extension crud_extension|ec2_extension s3_extension crud_extension|; |
|
| 1550 |
+ " -i $KEYSTONE_CONF |
|
| 1551 |
+ # Append the S3 bits |
|
| 1552 |
+ iniset $KEYSTONE_CONF filter:s3_extension paste.filter_factory "keystone.contrib.s3:S3Extension.factory" |
|
| 1527 | 1553 |
|
| 1528 | 1554 |
# Add swift endpoints to service catalog if swift is enabled |
| 1529 | 1555 |
if is_service_enabled swift; then |
| ... | ... |
@@ -1541,34 +1567,32 @@ if is_service_enabled key; then |
| 1541 | 1541 |
echo "catalog.RegionOne.network.name = Quantum Service" >> $KEYSTONE_CATALOG |
| 1542 | 1542 |
fi |
| 1543 | 1543 |
|
| 1544 |
- sudo sed -e "s,%SERVICE_HOST%,$SERVICE_HOST,g" -i $KEYSTONE_CATALOG |
|
| 1545 |
- |
|
| 1546 |
- sudo sed -e "s,%S3_SERVICE_PORT%,$S3_SERVICE_PORT,g" -i $KEYSTONE_CATALOG |
|
| 1544 |
+ sudo sed -e " |
|
| 1545 |
+ s,%SERVICE_HOST%,$SERVICE_HOST,g; |
|
| 1546 |
+ s,%S3_SERVICE_PORT%,$S3_SERVICE_PORT,g; |
|
| 1547 |
+ " -i $KEYSTONE_CATALOG |
|
| 1547 | 1548 |
|
| 1549 |
+ # Set up logging |
|
| 1550 |
+ LOGGING_ROOT="devel" |
|
| 1548 | 1551 |
if [ "$SYSLOG" != "False" ]; then |
| 1549 |
- cp $KEYSTONE_DIR/etc/logging.conf.sample $KEYSTONE_DIR/etc/logging.conf |
|
| 1550 |
- sed -i -e '/^handlers=devel$/s/=devel/=production/' \ |
|
| 1551 |
- $KEYSTONE_DIR/etc/logging.conf |
|
| 1552 |
- sed -i -e "/^log_file/s/log_file/\#log_file/" \ |
|
| 1553 |
- $KEYSTONE_DIR/etc/keystone.conf |
|
| 1554 |
- KEYSTONE_LOG_CONFIG="--log-config $KEYSTONE_DIR/etc/logging.conf" |
|
| 1552 |
+ LOGGING_ROOT="$LOGGING_ROOT,production" |
|
| 1555 | 1553 |
fi |
| 1556 |
-fi |
|
| 1554 |
+ KEYSTONE_LOG_CONFIG="--log-config $KEYSTONE_CONF_DIR/logging.conf" |
|
| 1555 |
+ cp $KEYSTONE_DIR/etc/logging.conf.sample $KEYSTONE_CONF_DIR/logging.conf |
|
| 1556 |
+ iniset $KEYSTONE_CONF_DIR/logging.conf logger_root level "DEBUG" |
|
| 1557 |
+ iniset $KEYSTONE_CONF_DIR/logging.conf logger_root handlers "devel,production" |
|
| 1557 | 1558 |
|
| 1558 |
-# launch the keystone and wait for it to answer before continuing |
|
| 1559 |
-if is_service_enabled key; then |
|
| 1559 |
+ # initialize keystone database |
|
| 1560 |
+ $KEYSTONE_DIR/bin/keystone-manage db_sync |
|
| 1561 |
+ |
|
| 1562 |
+ # launch keystone and wait for it to answer before continuing |
|
| 1560 | 1563 |
screen_it key "cd $KEYSTONE_DIR && $KEYSTONE_DIR/bin/keystone-all --config-file $KEYSTONE_CONF $KEYSTONE_LOG_CONFIG -d --debug" |
| 1561 | 1564 |
echo "Waiting for keystone to start..." |
| 1562 |
- if ! timeout $SERVICE_TIMEOUT sh -c "while ! http_proxy= wget -q -O- $KEYSTONE_AUTH_PROTOCOL://$SERVICE_HOST:$KEYSTONE_API_PORT/v2.0/; do sleep 1; done"; then |
|
| 1565 |
+ if ! timeout $SERVICE_TIMEOUT sh -c "while http_proxy= wget -O- $KEYSTONE_AUTH_PROTOCOL://$SERVICE_HOST:$KEYSTONE_API_PORT/v2.0/ 2>&1 | grep -q 'refused'; do sleep 1; done"; then |
|
| 1563 | 1566 |
echo "keystone did not start" |
| 1564 | 1567 |
exit 1 |
| 1565 | 1568 |
fi |
| 1566 | 1569 |
|
| 1567 |
- # initialize keystone with default users/endpoints |
|
| 1568 |
- pushd $KEYSTONE_DIR |
|
| 1569 |
- $KEYSTONE_DIR/bin/keystone-manage db_sync |
|
| 1570 |
- popd |
|
| 1571 |
- |
|
| 1572 | 1570 |
# keystone_data.sh creates services, admin and demo users, and roles. |
| 1573 | 1571 |
SERVICE_ENDPOINT=$KEYSTONE_AUTH_PROTOCOL://$KEYSTONE_AUTH_HOST:$KEYSTONE_AUTH_PORT/v2.0 |
| 1574 | 1572 |
ADMIN_PASSWORD=$ADMIN_PASSWORD SERVICE_TENANT_NAME=$SERVICE_TENANT_NAME SERVICE_PASSWORD=$SERVICE_PASSWORD SERVICE_TOKEN=$SERVICE_TOKEN SERVICE_ENDPOINT=$SERVICE_ENDPOINT DEVSTACK_DIR=$TOP_DIR ENABLED_SERVICES=$ENABLED_SERVICES \ |
| ... | ... |
@@ -98,7 +98,7 @@ fi |
| 98 | 98 |
|
| 99 | 99 |
VAL=$(iniget test.ini zzz handlers) |
| 100 | 100 |
if [[ -z "$VAL" ]]; then |
| 101 |
- echo "OK" |
|
| 101 |
+ echo "OK: zzz not present" |
|
| 102 | 102 |
else |
| 103 | 103 |
echo "iniget failed: $VAL" |
| 104 | 104 |
fi |
| ... | ... |
@@ -106,12 +106,30 @@ fi |
| 106 | 106 |
iniset test.ini zzz handlers "999" |
| 107 | 107 |
|
| 108 | 108 |
VAL=$(iniget test.ini zzz handlers) |
| 109 |
+if [[ -n "$VAL" ]]; then |
|
| 110 |
+ echo "OK: zzz not present" |
|
| 111 |
+else |
|
| 112 |
+ echo "iniget failed: $VAL" |
|
| 113 |
+fi |
|
| 114 |
+ |
|
| 115 |
+ |
|
| 116 |
+# Test option not exist |
|
| 117 |
+ |
|
| 118 |
+VAL=$(iniget test.ini aaa debug) |
|
| 109 | 119 |
if [[ -z "$VAL" ]]; then |
| 110 |
- echo "OK" |
|
| 120 |
+ echo "OK aaa.debug not present" |
|
| 111 | 121 |
else |
| 112 | 122 |
echo "iniget failed: $VAL" |
| 113 | 123 |
fi |
| 114 | 124 |
|
| 125 |
+iniset test.ini aaa debug "999" |
|
| 126 |
+ |
|
| 127 |
+VAL=$(iniget test.ini aaa debug) |
|
| 128 |
+if [[ -n "$VAL" ]]; then |
|
| 129 |
+ echo "OK aaa.debug present" |
|
| 130 |
+else |
|
| 131 |
+ echo "iniget failed: $VAL" |
|
| 132 |
+fi |
|
| 115 | 133 |
|
| 116 | 134 |
# Test comments |
| 117 | 135 |
|