+install_and_setup_keystone() {
+ install_packages ${keystone_package}
+ service ${keystone_service} stop
+
+ cat > /etc/keystone/keystone.conf << EOF
+[DEFAULT]
+admin_token=${token}
+log_file=${keystone_log_file}
+rabbit_password = guest
+rabbit_hosts = 127.0.0.1
+notification_driver = messaging
+notification_topics = notifications
+[database]
+connection=mysql://keystone:keystone@127.0.0.1/keystone
+[token]
+provider=keystone.token.providers.uuid.Provider
+EOF
+ [ -d "/var/log/keystone/" ] || mkdir /var/log/keystone/
+ touch ${keystone_log_file}
+ chown -R keystone:keystone /var/log/keystone/
+ chown -R keystone:keystone /etc/keystone
+ keystone-manage db_sync
+ service ${keystone_service} restart
+ sleep 5
+ if [ -z "$(curl -s http://127.0.0.1:5000/ | grep '^{"versions":')" ]; then
+ exit_on_error 1 "Failed to get to keystone API.\nTests failed because of keystone problem"
+ fi
+}
+
+install_and_setup_mysql() {
+ if [[ "$os" == "ubuntu" ]]; then
+ echo "mysql-server mysql-server/root_password select ${mysql_pass}" | debconf-set-selections
+ echo "mysql-server mysql-server/root_password_again select ${mysql_pass}" | debconf-set-selections
+ ${command_to_install} mysql-server mysql-client python-mysqldb
+ MYSQL_PASSWORD=''
+ else
+ ${command_to_install} mysql-client mysql-server mysql-libs MySQL-python
+ MYSQL_PASSWORD=$(cat /root/.mysql_secret | head -1 | awk -F': ' '{print $2}')
+ fi
+ mycnf=$(find /etc/ -name my.cnf)
+ cat $mycnf
+ service mysql restart
+ sleep 10
+ if [ ! -z "${MYSQL_PASSWORD}" ]; then
+ mysqladmin -u root -p${MYSQL_PASSWORD} password ${mysql_pass}
+ fi
+ if [ -z "$(service ${mysql_service} status | grep "running" )" ]; then
+ exit_on_error 1 "Mysql service has failed to start"
+ fi
+
+ mysql -uroot -p${mysql_pass} -Bse "drop database if exists keystone"
+ mysql -uroot -p${mysql_pass} -Bse "create database keystone"
+ mysql -uroot -p${mysql_pass} -Bse "GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' IDENTIFIED BY 'keystone'"
+ mysql -uroot -p${mysql_pass} -Bse "drop database if exists ceilometer"
+ mysql -uroot -p${mysql_pass} -Bse "create database ceilometer"
+ mysql -uroot -p${mysql_pass} -Bse "GRANT ALL PRIVILEGES ON ceilometer.* TO 'ceilometer'@'localhost' IDENTIFIED BY 'ceilometer'"
+ mysql -uroot -p${mysql_pass} -Bse "flush privileges"
+}
+
+install_and_setup_rabbit() {
+ install_packages rabbitmq-server
+ echo "127.0.0.1 $(hostname)" >> /etc/hosts
+ if [[ "$os" == "ubuntu" ]]; then
+ update-rc.d rabbitmq-server defaults
+ else
+ systemctl enable rabbitmq-server
+ fi
+ service rabbitmq-server restart
+ sleep 5
+}
+
+ceilometer_configuration() {
+ cat > /etc/ceilometer/ceilometer.conf << EOF
+[DEFAULT]