From 18427b1682e8f7d3bf10f85987687ee6a64f11fa Mon Sep 17 00:00:00 2001 From: Prasanna Santhanam Date: Thu, 23 Aug 2012 21:12:51 +0530 Subject: [PATCH] Simulator specific schema and db objects Seperating the simulator entities into a seperate database. During performance tests this helps isolate connection losses happening in cloud from those happening in the simulator. reviewed-by : Marvin (vm lifecycle test) --- setup/db/create-database-simulator.sql | 11 +++++++++++ setup/db/create-schema-simulator.sql | 26 +++++++++++++------------- setup/db/deploy-db-simulator.sh | 22 ++++++++++++++++++++++ 3 files changed, 46 insertions(+), 13 deletions(-) create mode 100644 setup/db/create-database-simulator.sql diff --git a/setup/db/create-database-simulator.sql b/setup/db/create-database-simulator.sql new file mode 100644 index 00000000000..fe170ee7e37 --- /dev/null +++ b/setup/db/create-database-simulator.sql @@ -0,0 +1,11 @@ +DROP DATABASE IF EXISTS `simulator`; + +CREATE DATABASE `simulator`; + +GRANT ALL ON simulator.* to cloud@`localhost` identified by 'cloud'; +GRANT ALL ON simulator.* to cloud@`%` identified by 'cloud'; + +GRANT process ON *.* TO cloud@`localhost`; +GRANT process ON *.* TO cloud@`%`; + +commit; diff --git a/setup/db/create-schema-simulator.sql b/setup/db/create-schema-simulator.sql index 70e40b9c347..c9146c95b4b 100644 --- a/setup/db/create-schema-simulator.sql +++ b/setup/db/create-schema-simulator.sql @@ -10,14 +10,14 @@ # limitations under the License. # # Automatically generated by addcopyright.py at 04/03/2012 -DROP TABLE IF EXISTS `cloud`.`mockhost`; -DROP TABLE IF EXISTS `cloud`.`mocksecstorage`; -DROP TABLE IF EXISTS `cloud`.`mockstoragepool`; -DROP TABLE IF EXISTS `cloud`.`mockvm`; -DROP TABLE IF EXISTS `cloud`.`mockvolume`; -DROP TABLE IF EXISTS `cloud`.`mocksecurityrules`; +DROP TABLE IF EXISTS `simulator`.`mockhost`; +DROP TABLE IF EXISTS `simulator`.`mocksecstorage`; +DROP TABLE IF EXISTS `simulator`.`mockstoragepool`; +DROP TABLE IF EXISTS `simulator`.`mockvm`; +DROP TABLE IF EXISTS `simulator`.`mockvolume`; +DROP TABLE IF EXISTS `simulator`.`mocksecurityrules`; -CREATE TABLE `cloud`.`mockhost` ( +CREATE TABLE `simulator`.`mockhost` ( `id` bigint unsigned NOT NULL auto_increment, `name` varchar(255) NOT NULL, `private_ip_address` char(40), @@ -43,7 +43,7 @@ CREATE TABLE `cloud`.`mockhost` ( PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -CREATE TABLE `cloud`.`mocksecstorage` ( +CREATE TABLE `simulator`.`mocksecstorage` ( `id` bigint unsigned NOT NULL auto_increment, `url` varchar(255), `capacity` bigint unsigned, @@ -51,7 +51,7 @@ CREATE TABLE `cloud`.`mocksecstorage` ( PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -CREATE TABLE `cloud`.`mockstoragepool` ( +CREATE TABLE `simulator`.`mockstoragepool` ( `id` bigint unsigned NOT NULL auto_increment, `guid` varchar(255), `mount_point` varchar(255), @@ -62,7 +62,7 @@ CREATE TABLE `cloud`.`mockstoragepool` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -CREATE TABLE `cloud`.`mockvm` ( +CREATE TABLE `simulator`.`mockvm` ( `id` bigint unsigned NOT NULL auto_increment, `name` varchar(255), `host_id` bigint unsigned, @@ -78,7 +78,7 @@ CREATE TABLE `cloud`.`mockvm` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -CREATE TABLE `cloud`.`mockvolume` ( +CREATE TABLE `simulator`.`mockvolume` ( `id` bigint unsigned NOT NULL auto_increment, `name` varchar(255), `size` bigint unsigned, @@ -92,7 +92,7 @@ CREATE TABLE `cloud`.`mockvolume` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -CREATE TABLE `cloud`.`mockconfiguration` ( +CREATE TABLE `simulator`.`mockconfiguration` ( `id` bigint unsigned NOT NULL auto_increment, `data_center_id` bigint unsigned, `pod_id` bigint unsigned, @@ -103,7 +103,7 @@ CREATE TABLE `cloud`.`mockconfiguration` ( PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -CREATE TABLE `cloud`.`mocksecurityrules` ( +CREATE TABLE `simulator`.`mocksecurityrules` ( `id` bigint unsigned NOT NULL auto_increment, `vmid` bigint unsigned, `signature` varchar(255), diff --git a/setup/db/deploy-db-simulator.sh b/setup/db/deploy-db-simulator.sh index c7ff914d486..5b5af6d90c9 100644 --- a/setup/db/deploy-db-simulator.sh +++ b/setup/db/deploy-db-simulator.sh @@ -51,6 +51,11 @@ if [ ! -f create-index-fk.sql ]; then exit 6; fi +if [ ! -f create-database-simulator.sql ]; then + printf "Error: Unable to find create-database-simulator.sql\n" + exit 7; +fi + PATHSEP=':' if [[ $OSTYPE == "cygwin" ]] ; then export CATALINA_HOME=`cygpath -m $CATALINA_HOME` @@ -75,6 +80,23 @@ elif [ $mysqlout -ne 0 ]; then exit 11 fi +mysql --user=root --password=$3 < create-database-simulator.sql > /dev/null 2>/dev/null +mysqlout=$? +if [ $mysqlout -eq 1 ]; then + printf "Please enter root password for MySQL.\n" + mysql --user=root --password < create-database-simulator.sql + if [ $? -ne 0 ]; then + printf "Error: Cannot execute create-database-simulator.sql\n" + exit 10 + fi +elif [ $mysqlout -eq 127 ]; then + printf "Error: Cannot execute create-database-simulator.sql - mysql command not found.\n" + exit 11 +elif [ $mysqlout -ne 0 ]; then + printf "Error: Cannot execute create-database-simulator.sql\n" + exit 11 +fi + mysql --user=cloud --password=cloud cloud < create-schema.sql if [ $? -ne 0 ]; then printf "Error: Cannot execute create-schema.sql\n"