
While ongoing management is a matter of API use, we have a specific use case for automation: we want controlled access to just TripleO ATC's (vs self-signup via a portal), as part of the TripleO CD cloud. I decided not to do something fancy for passwords (like GPG encrypting to the user) and instead just capture an initial password for the user on disk, which any admin can log in and give to the user, because thats sufficient to get folk going. Until we have state preservation we need to recreate the users each time, which is another reason to keep the passwords around: that way it's not new every time for users. Change-Id: Ie5b0f92f204af467fe3159cc2a05860d01608310
67 lines
1.7 KiB
Bash
Executable File
67 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Copyright 2013 Hewlett-Packard Development Company, L.P.
|
|
# All Rights Reserved.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
set -eu
|
|
|
|
SCRIPT_NAME=$(basename $0)
|
|
SCRIPT_HOME=$(dirname $0)
|
|
|
|
function show_options () {
|
|
echo "Usage: $SCRIPT_NAME [options] LISTFILE"
|
|
echo
|
|
echo "Ensure that every user listed in LISTFILE has a cloud account."
|
|
echo
|
|
echo "Options:"
|
|
echo " -h -- this help"
|
|
echo " -t -- Choose a tenant. Defaults to the usercode"
|
|
echo
|
|
exit $1
|
|
}
|
|
|
|
TENANT=''
|
|
|
|
TEMP=`getopt -o ht: -n $SCRIPT_NAME -- "$@"`
|
|
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
|
|
|
|
# Note the quotes around `$TEMP': they are essential!
|
|
eval set -- "$TEMP"
|
|
|
|
while true ; do
|
|
case "$1" in
|
|
-h) show_options 0;;
|
|
-t) TENANT=$2; shift 2 ;;
|
|
--) shift ; break ;;
|
|
*) echo "Error: unsupported option $1." ; exit 1 ;;
|
|
esac
|
|
done
|
|
|
|
LISTFILE=${1:-''}
|
|
EXTRA_ARGS=${2:-''}
|
|
|
|
if [ -z "$LISTFILE" -o -n "$EXTRA_ARGS" ]; then
|
|
show_options 1
|
|
fi
|
|
|
|
while IFS=, read -ra DETAILS; do
|
|
if [ -z "$TENANT" ] ; then
|
|
USER_TENANT=${DETAILS[0]}
|
|
else
|
|
USER_TENANT=$TENANT
|
|
fi
|
|
assert-user -u ${DETAILS[0]} -e ${DETAILS[1]} -t $USER_TENANT -n "${DETAILS[2]}"
|
|
done < $LISTFILE
|