Skip to content

Commit 3dc2e0a

Browse files
committed
simulate more commands
1 parent 0be1510 commit 3dc2e0a

2 files changed

Lines changed: 218 additions & 0 deletions

File tree

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
DROP TABLE IF EXISTS `cloud`.`mockhost`;
2+
DROP TABLE IF EXISTS `cloud`.`mocksecstorage`;
3+
DROP TABLE IF EXISTS `cloud`.`mockstoragepool`;
4+
DROP TABLE IF EXISTS `cloud`.`mockvm`;
5+
DROP TABLE IF EXISTS `cloud`.`mockvolume`;
6+
7+
CREATE TABLE `cloud`.`mockhost` (
8+
`id` bigint unsigned NOT NULL auto_increment,
9+
`name` varchar(255) NOT NULL,
10+
`private_ip_address` char(40),
11+
`private_mac_address` varchar(17),
12+
`private_netmask` varchar(15),
13+
`storage_ip_address` char(40),
14+
`storage_netmask` varchar(15),
15+
`storage_mac_address` varchar(17),
16+
`public_ip_address` char(40),
17+
`public_netmask` varchar(15),
18+
`public_mac_address` varchar(17),
19+
`guid` varchar(255) UNIQUE,
20+
`version` varchar(40) NOT NULL,
21+
`data_center_id` bigint unsigned NOT NULL,
22+
`pod_id` bigint unsigned,
23+
`cluster_id` bigint unsigned COMMENT 'foreign key to cluster',
24+
`cpus` int(10) unsigned,
25+
`speed` int(10) unsigned,
26+
`ram` bigint unsigned,
27+
`capabilities` varchar(255) COMMENT 'host capabilities in comma separated list',
28+
`vm_id` bigint unsigned,
29+
`resource` varchar(255) DEFAULT NULL COMMENT 'If it is a local resource, this is the class name',
30+
PRIMARY KEY (`id`)
31+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
32+
33+
CREATE TABLE `cloud`.`mocksecstorage` (
34+
`id` bigint unsigned NOT NULL auto_increment,
35+
`url` varchar(255),
36+
`capacity` bigint unsigned,
37+
`mount_point` varchar(255),
38+
PRIMARY KEY (`id`)
39+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
40+
41+
CREATE TABLE `cloud`.`mockstoragepool` (
42+
`id` bigint unsigned NOT NULL auto_increment,
43+
`guid` varchar(255),
44+
`mount_point` varchar(255),
45+
`capacity` bigint,
46+
`pool_type` varchar(40),
47+
`hostguid` varchar(255) UNIQUE,
48+
PRIMARY KEY (`id`)
49+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
50+
51+
52+
CREATE TABLE `cloud`.`mockvm` (
53+
`id` bigint unsigned NOT NULL auto_increment,
54+
`name` varchar(255),
55+
`host_id` bigint unsigned,
56+
`type` varchar(40),
57+
`state` varchar(40),
58+
`vnc_port` bigint unsigned,
59+
`memory` bigint unsigned,
60+
`cpu` bigint unsigned,
61+
PRIMARY KEY (`id`)
62+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
63+
64+
65+
CREATE TABLE `cloud`.`mockvolume` (
66+
`id` bigint unsigned NOT NULL auto_increment,
67+
`name` varchar(255),
68+
`size` bigint unsigned,
69+
`path` varchar(255),
70+
`pool_id` bigint unsigned,
71+
`type` varchar(40),
72+
`status` varchar(40),
73+
PRIMARY KEY (`id`)
74+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
75+
76+
77+
CREATE TABLE `cloud`.`mockconfiguration` (
78+
`id` bigint unsigned NOT NULL auto_increment,
79+
`data_center_id` bigint unsigned,
80+
`pod_id` bigint unsigned,
81+
`cluster_id` bigint unsigned,
82+
`host_id` bigint unsigned,
83+
`name` varchar(255),
84+
`values` varchar(4095),
85+
PRIMARY KEY (`id`)
86+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
87+

setup/db/deploy-db-simulator.sh

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
#!/usr/bin/env bash
2+
3+
4+
5+
#
6+
# Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
7+
#
8+
# This software is licensed under the GNU General Public License v3 or later.
9+
#
10+
# It is free software: you can redistribute it and/or modify
11+
# it under the terms of the GNU General Public License as published by
12+
# the Free Software Foundation, either version 3 of the License, or any later version.
13+
# This program is distributed in the hope that it will be useful,
14+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
# GNU General Public License for more details.
17+
#
18+
# You should have received a copy of the GNU General Public License
19+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
20+
#
21+
22+
23+
# deploy-db.sh -- deploys the database configuration.
24+
#
25+
# set -x
26+
27+
if [ "$1" == "" ]; then
28+
printf "Usage: %s [path to server-setup.xml] [path to additional sql] [root password]\n" $(basename $0) >&2
29+
exit 1;
30+
fi
31+
32+
if [ ! -f $1 ]; then
33+
echo "Error: Unable to find $1"
34+
exit 2
35+
fi
36+
37+
if [ "$2" != "" ]; then
38+
if [ ! -f $2 ]; then
39+
echo "Error: Unable to find $2"
40+
exit 3
41+
fi
42+
fi
43+
44+
if [ ! -f create-database.sql ]; then
45+
printf "Error: Unable to find create-database.sql\n"
46+
exit 4
47+
fi
48+
49+
if [ ! -f create-schema.sql ]; then
50+
printf "Error: Unable to find create-schema.sql\n"
51+
exit 5
52+
fi
53+
54+
if [ ! -f create-index-fk.sql ]; then
55+
printf "Error: Unable to find create-index-fk.sql\n"
56+
exit 6;
57+
fi
58+
59+
PATHSEP=':'
60+
if [[ $OSTYPE == "cygwin" ]] ; then
61+
export CATALINA_HOME=`cygpath -m $CATALINA_HOME`
62+
PATHSEP=';'
63+
fi
64+
65+
echo "Recreating Database."
66+
mysql --user=root --password=$3 < create-database.sql > /dev/null 2>/dev/null
67+
mysqlout=$?
68+
if [ $mysqlout -eq 1 ]; then
69+
printf "Please enter root password for MySQL.\n"
70+
mysql --user=root --password < create-database.sql
71+
if [ $? -ne 0 ]; then
72+
printf "Error: Cannot execute create-database.sql\n"
73+
exit 10
74+
fi
75+
elif [ $mysqlout -eq 127 ]; then
76+
printf "Error: Cannot execute create-database.sql - mysql command not found.\n"
77+
exit 11
78+
elif [ $mysqlout -ne 0 ]; then
79+
printf "Error: Cannot execute create-database.sql\n"
80+
exit 11
81+
fi
82+
83+
mysql --user=cloud --password=cloud cloud < create-schema.sql
84+
if [ $? -ne 0 ]; then
85+
printf "Error: Cannot execute create-schema.sql\n"
86+
exit 11
87+
fi
88+
89+
mysql --user=cloud --password=cloud cloud < create-schema-simulator.sql
90+
if [ $? -ne 0 ]; then
91+
printf "Error: Cannot execute create-schema-simulator.sql\n"
92+
exit 11
93+
fi
94+
95+
CP=./
96+
97+
CP=${CP}$PATHSEP$CATALINA_HOME/conf
98+
99+
for file in $CATALINA_HOME/webapps/client/WEB-INF/lib/*.jar
100+
do
101+
CP=${CP}$PATHSEP$file
102+
done
103+
104+
for file in $CATALINA_HOME/lib/*.jar; do
105+
CP=${CP}$PATHSEP$file
106+
done
107+
108+
echo CP is $CP
109+
110+
java -cp $CP com.cloud.test.DatabaseConfig $*
111+
112+
if [ $? -ne 0 ]
113+
then
114+
exit 1
115+
fi
116+
117+
if [ "$2" != "" ]; then
118+
mysql --user=cloud --password=cloud cloud < $2
119+
if [ $? -ne 0 ]; then
120+
printf "Error: Cannot execute $2\n"
121+
exit 12
122+
fi
123+
fi
124+
125+
126+
echo "Creating Indice and Foreign Keys"
127+
mysql --user=cloud --password=cloud cloud < create-index-fk.sql
128+
if [ $? -ne 0 ]; then
129+
printf "Error: Cannot execute create-index-fk.sql\n"
130+
exit 13
131+
fi

0 commit comments

Comments
 (0)