-prepare_script() {
- echo '#!/usr/bin/env python
-import pika
-connection = pika.BlockingConnection(pika.ConnectionParameters(host="127.0.0.1"))
-channel = connection.channel()
-channel.queue_declare(queue="notifications.info")
-test=r'"'"'{"event_type": "compute.instance.update", "_unique_id": "fake", "payload": {"ephemeral_gb": 0, "instance_id": "fake", "user_id": "fake", "root_gb": 0, "tenant_id": "fake", "memory_mb": 64, "vcpus": 1}, "priority": "INFO"}'"'"'
-channel.basic_publish(exchange="nova", routing_key="notifications.info",
- properties=pika.BasicProperties(priority=0, delivery_mode=2, headers="", content_encoding="utf-8", content_type="application/json"),
- body=test)
-print " [x] Message was sent!"
-connection.close()' > $(pwd)/send.py
+prepare_vm() {
+ install_packages ${packages_list}
+}
+
+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@localhost/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://localhost:5000/ | grep '^{"versions":')" ]; then
+ cat ${keystone_log_file}
+ exit_on_error 1 "Failed to get to keystone API.\nTests failed because of keystone problem"
+ fi
+}
+
+install_and_setup_mysql() {
+ 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-5.6 mysql-client-core-5.6 python-mysqldb
+ if [ -f "/etc/mysql/conf.d/wsrep.cnf" ]; then
+ rm -f /etc/mysql/conf.d/wsrep.cnf
+ fi
+
+ service ${mysql_service} restart
+ sleep 5
+
+ if [ -z "$(service ${mysql_service} status | grep "start/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 "flush privileges"
+}
+
+install_and_setup_rabbit() {
+ install_packages rabbitmq-server
+ echo "127.0.10.1 $(hostname)" >> /etc/hosts
+ service rabbitmq-server restart
+ sleep 5
+
+ if [ ! -z "$(service rabbitmq-server status | grep "Error: unable to connect to node")" ]; then
+ cat /var/log/rabbitmq/startup_log
+ cat /var/log/rabbitmq/startup_err
+
+ exit_on_error 1 "DB sync command has failures"
+ fi