You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by mu...@apache.org on 2013/02/07 08:43:58 UTC
[29/50] [abbrv] git commit: refs/heads/gslb - Upgrade changes for
Region schema. Made region_id not null
Upgrade changes for Region schema. Made region_id not null
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/fc925022
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/fc925022
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/fc925022
Branch: refs/heads/gslb
Commit: fc925022bdf587e7281c3fc4e405e895754c41a4
Parents: bfc4f98
Author: Kishan Kavala <ki...@cloud.com>
Authored: Fri Feb 1 13:49:45 2013 +0530
Committer: Kishan Kavala <ki...@cloud.com>
Committed: Fri Feb 1 13:49:57 2013 +0530
----------------------------------------------------------------------
developer/developer-prefill.sql | 20 ++++++------
.../com/cloud/server/ConfigurationServerImpl.java | 12 ++++----
setup/db/create-schema.sql | 6 ++--
setup/db/db/schema-40to410.sql | 23 +++++++++++++++
4 files changed, 42 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/fc925022/developer/developer-prefill.sql
----------------------------------------------------------------------
diff --git a/developer/developer-prefill.sql b/developer/developer-prefill.sql
index 6300d35..8713d73 100644
--- a/developer/developer-prefill.sql
+++ b/developer/developer-prefill.sql
@@ -18,25 +18,25 @@
-- Add a default ROOT domain
use cloud;
-INSERT INTO `cloud`.`domain` (id, uuid, name, parent, path, owner) VALUES
- (1, UUID(), 'ROOT', NULL, '/', 2);
+INSERT INTO `cloud`.`domain` (id, uuid, name, parent, path, owner, region_id) VALUES
+ (1, UUID(), 'ROOT', NULL, '/', 2, 1);
-- Add system and admin accounts
-INSERT INTO `cloud`.`account` (id, uuid, account_name, type, domain_id, state) VALUES
- (1, UUID(), 'system', 1, 1, 'enabled');
+INSERT INTO `cloud`.`account` (id, uuid, account_name, type, domain_id, state, region_id) VALUES
+ (1, UUID(), 'system', 1, 1, 'enabled', 1);
-INSERT INTO `cloud`.`account` (id, uuid, account_name, type, domain_id, state) VALUES
- (2, UUID(), 'admin', 1, 1, 'enabled');
+INSERT INTO `cloud`.`account` (id, uuid, account_name, type, domain_id, state, region_id) VALUES
+ (2, UUID(), 'admin', 1, 1, 'enabled', 1);
-- Add system user
INSERT INTO `cloud`.`user` (id, uuid, username, password, account_id, firstname,
- lastname, email, state, created) VALUES (1, UUID(), 'system', RAND(),
- '1', 'system', 'cloud', NULL, 'enabled', NOW());
+ lastname, email, state, created, region_id) VALUES (1, UUID(), 'system', RAND(),
+ '1', 'system', 'cloud', NULL, 'enabled', NOW(), 1);
-- Add system user with encrypted password=password
INSERT INTO `cloud`.`user` (id, uuid, username, password, account_id, firstname,
- lastname, email, state, created) VALUES (2, UUID(), 'admin', '5f4dcc3b5aa765d61d8327deb882cf99',
- '2', 'Admin', 'User', 'admin@mailprovider.com', 'enabled', NOW());
+ lastname, email, state, created, region_id) VALUES (2, UUID(), 'admin', '5f4dcc3b5aa765d61d8327deb882cf99',
+ '2', 'Admin', 'User', 'admin@mailprovider.com', 'enabled', NOW(), 1);
-- Add configurations
INSERT INTO `cloud`.`configuration` (category, instance, component, name, value)
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/fc925022/server/src/com/cloud/server/ConfigurationServerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ConfigurationServerImpl.java b/server/src/com/cloud/server/ConfigurationServerImpl.java
index 2ae0843..7d12412 100755
--- a/server/src/com/cloud/server/ConfigurationServerImpl.java
+++ b/server/src/com/cloud/server/ConfigurationServerImpl.java
@@ -317,7 +317,7 @@ public class ConfigurationServerImpl implements ConfigurationServer {
protected void saveUser() {
//ToDo: Add regionId to default users and accounts
// insert system account
- String insertSql = "INSERT INTO `cloud`.`account` (id, uuid, account_name, type, domain_id) VALUES (1, UUID(), 'system', '1', '1')";
+ String insertSql = "INSERT INTO `cloud`.`account` (id, uuid, account_name, type, domain_id, region_id) VALUES (1, UUID(), 'system', '1', '1', '1')";
Transaction txn = Transaction.currentTxn();
try {
PreparedStatement stmt = txn.prepareAutoCloseStatement(insertSql);
@@ -325,8 +325,8 @@ public class ConfigurationServerImpl implements ConfigurationServer {
} catch (SQLException ex) {
}
// insert system user
- insertSql = "INSERT INTO `cloud`.`user` (id, uuid, username, password, account_id, firstname, lastname, created)" +
- " VALUES (1, UUID(), 'system', RAND(), 1, 'system', 'cloud', now())";
+ insertSql = "INSERT INTO `cloud`.`user` (id, uuid, username, password, account_id, firstname, lastname, created, region_id)" +
+ " VALUES (1, UUID(), 'system', RAND(), 1, 'system', 'cloud', now(), '1')";
txn = Transaction.currentTxn();
try {
PreparedStatement stmt = txn.prepareAutoCloseStatement(insertSql);
@@ -342,7 +342,7 @@ public class ConfigurationServerImpl implements ConfigurationServer {
String lastname = "cloud";
// create an account for the admin user first
- insertSql = "INSERT INTO `cloud`.`account` (id, uuid, account_name, type, domain_id) VALUES (" + id + ", UUID(), '" + username + "', '1', '1')";
+ insertSql = "INSERT INTO `cloud`.`account` (id, uuid, account_name, type, domain_id, region_id) VALUES (" + id + ", UUID(), '" + username + "', '1', '1', '1')";
txn = Transaction.currentTxn();
try {
PreparedStatement stmt = txn.prepareAutoCloseStatement(insertSql);
@@ -351,8 +351,8 @@ public class ConfigurationServerImpl implements ConfigurationServer {
}
// now insert the user
- insertSql = "INSERT INTO `cloud`.`user` (id, username, password, account_id, firstname, lastname, created, state) " +
- "VALUES (" + id + ",'" + username + "', RAND(), 2, '" + firstname + "','" + lastname + "',now(), 'disabled')";
+ insertSql = "INSERT INTO `cloud`.`user` (id, username, password, account_id, firstname, lastname, created, state, region_id) " +
+ "VALUES (" + id + ",'" + username + "', RAND(), 2, '" + firstname + "','" + lastname + "',now(), 'disabled', '1')";
txn = Transaction.currentTxn();
try {
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/fc925022/setup/db/create-schema.sql
----------------------------------------------------------------------
diff --git a/setup/db/create-schema.sql b/setup/db/create-schema.sql
index 0a57bfd..beb9103 100755
--- a/setup/db/create-schema.sql
+++ b/setup/db/create-schema.sql
@@ -911,7 +911,7 @@ CREATE TABLE `cloud`.`user` (
`timezone` varchar(30) default NULL,
`registration_token` varchar(255) default NULL,
`is_registered` tinyint NOT NULL DEFAULT 0 COMMENT '1: yes, 0: no',
- `region_id` int unsigned,
+ `region_id` int unsigned NOT NULL,
`incorrect_login_attempts` integer unsigned NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
INDEX `i_user__removed`(`removed`),
@@ -1262,7 +1262,7 @@ CREATE TABLE `cloud`.`domain` (
`state` char(32) NOT NULL default 'Active' COMMENT 'state of the domain',
`network_domain` varchar(255),
`type` varchar(255) NOT NULL DEFAULT 'Normal' COMMENT 'type of the domain - can be Normal or Project',
- `region_id` int unsigned,
+ `region_id` int unsigned NOT NULL,
PRIMARY KEY (`id`),
UNIQUE (parent, name, removed),
INDEX `i_domain__path`(`path`),
@@ -1281,7 +1281,7 @@ CREATE TABLE `cloud`.`account` (
`cleanup_needed` tinyint(1) NOT NULL default '0',
`network_domain` varchar(255),
`default_zone_id` bigint unsigned,
- `region_id` int unsigned,
+ `region_id` int unsigned NOT NULL,
PRIMARY KEY (`id`),
INDEX i_account__removed(`removed`),
CONSTRAINT `fk_account__default_zone_id` FOREIGN KEY `fk_account__default_zone_id`(`default_zone_id`) REFERENCES `data_center`(`id`) ON DELETE CASCADE,
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/fc925022/setup/db/db/schema-40to410.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-40to410.sql b/setup/db/db/schema-40to410.sql
index 304e12c..39b686e 100644
--- a/setup/db/db/schema-40to410.sql
+++ b/setup/db/db/schema-40to410.sql
@@ -1268,3 +1268,26 @@ INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'manag
ALTER TABLE `cloud`.`op_dc_vnet_alloc` DROP INDEX i_op_dc_vnet_alloc__vnet__data_center_id;
ALTER TABLE `cloud`.`op_dc_vnet_alloc` ADD CONSTRAINT UNIQUE `i_op_dc_vnet_alloc__vnet__data_center_id`(`vnet`, `physical_network_id`, `data_center_id`);
+
+CREATE TABLE `cloud`.`region` (
+ `id` int unsigned NOT NULL UNIQUE,
+ `name` varchar(255) NOT NULL UNIQUE,
+ `end_point` varchar(255) NOT NULL,
+ `api_key` varchar(255),
+ `secret_key` varchar(255),
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE `cloud`.`region_sync` (
+ `id` bigint unsigned NOT NULL auto_increment,
+ `region_id` int unsigned NOT NULL,
+ `api` varchar(1024) NOT NULL,
+ `created` datetime NOT NULL COMMENT 'date created',
+ `processed` tinyint NOT NULL default '0',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+INSERT INTO `cloud`.`region` values ('1','Local','http://localhost:8080/client/api','','');
+ALTER TABLE `cloud`.`account` ADD COLUMN `region_id` int unsigned NOT NULL DEFAULT '1';
+ALTER TABLE `cloud`.`user` ADD COLUMN `region_id` int unsigned NOT NULL DEFAULT '1';
+ALTER TABLE `cloud`.`domain` ADD COLUMN `region_id` int unsigned NOT NULL DEFAULT '1';