You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by al...@apache.org on 2014/07/08 01:36:29 UTC

[1/2] git commit: updated refs/heads/master to 5a96d8e

Repository: cloudstack
Updated Branches:
  refs/heads/master 62e005b97 -> 5a96d8ef5


Fixed deploydb for 4.5 branch


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/b87a5ce5
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/b87a5ce5
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/b87a5ce5

Branch: refs/heads/master
Commit: b87a5ce5fe6b3ed5002aaacdd39e045dd4eca803
Parents: 62e005b
Author: Alena Prokharchyk <al...@citrix.com>
Authored: Mon Jul 7 15:11:53 2014 -0700
Committer: Alena Prokharchyk <al...@citrix.com>
Committed: Mon Jul 7 16:06:46 2014 -0700

----------------------------------------------------------------------
 setup/db/create-schema.sql      | 60 ++++++++++++++++++------------------
 setup/db/db/schema-440to450.sql |  2 +-
 2 files changed, 31 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b87a5ce5/setup/db/create-schema.sql
----------------------------------------------------------------------
diff --git a/setup/db/create-schema.sql b/setup/db/create-schema.sql
index fe5cd0a..f95b02f 100755
--- a/setup/db/create-schema.sql
+++ b/setup/db/create-schema.sql
@@ -246,7 +246,7 @@ CREATE TABLE `cloud`.`networks` (
   `broadcast_domain_type` varchar(32) NOT NULL COMMENT 'type of broadcast domain used',
   `broadcast_uri` varchar(255) COMMENT 'broadcast domain specifier',
   `gateway` varchar(15) COMMENT 'gateway for this network configuration',
-  `cidr` varchar(18) COMMENT 'network cidr', 
+  `cidr` varchar(18) COMMENT 'network cidr',
   `mode` varchar(32) COMMENT 'How to retrieve ip address in this network',
   `network_offering_id` bigint unsigned NOT NULL COMMENT 'network offering id that this configuration is created from',
   `physical_network_id` bigint unsigned COMMENT 'physical network id that this configuration is based on',
@@ -270,14 +270,14 @@ CREATE TABLE `cloud`.`networks` (
   `specify_ip_ranges` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'true if the network provides an ability to define ip ranges',
   `vpc_id` bigint unsigned COMMENT 'vpc this network belongs to',
   PRIMARY KEY (`id`),
-  CONSTRAINT `fk_networks__network_offering_id` FOREIGN KEY (`network_offering_id`) REFERENCES `network_offerings`(`id`),  
+  CONSTRAINT `fk_networks__network_offering_id` FOREIGN KEY (`network_offering_id`) REFERENCES `network_offerings`(`id`),
   CONSTRAINT `fk_networks__data_center_id` FOREIGN KEY (`data_center_id`) REFERENCES `data_center`(`id`) ON DELETE CASCADE,
   CONSTRAINT `fk_networks__related` FOREIGN KEY(`related`) REFERENCES `networks`(`id`) ON DELETE CASCADE,
   CONSTRAINT `fk_networks__account_id` FOREIGN KEY(`account_id`) REFERENCES `account`(`id`),
   CONSTRAINT `fk_networks__domain_id` FOREIGN KEY(`domain_id`) REFERENCES `domain`(`id`),
   CONSTRAINT `fk_networks__vpc_id` FOREIGN KEY(`vpc_id`) REFERENCES `vpc`(`id`),
   CONSTRAINT `uc_networks__uuid` UNIQUE (`uuid`),
-  INDEX `i_networks__removed`(`removed`) 
+  INDEX `i_networks__removed`(`removed`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
 CREATE TABLE `cloud`.`account_network_ref` (
@@ -301,7 +301,7 @@ CREATE TABLE `cloud`.`nics` (
   `ip_type` varchar(32) COMMENT 'type of ip',
   `broadcast_uri` varchar(255) COMMENT 'broadcast uri',
   `network_id` bigint unsigned NOT NULL COMMENT 'network configuration id',
-  `mode` varchar(32) COMMENT 'mode of getting ip address',  
+  `mode` varchar(32) COMMENT 'mode of getting ip address',
   `state` varchar(32) NOT NULL COMMENT 'state of the creation',
   `strategy` varchar(32) NOT NULL COMMENT 'reservation strategy',
   `reserver_name` varchar(255) COMMENT 'Name of the component that reserved the ip address',
@@ -431,11 +431,11 @@ CREATE TABLE `cloud`.`op_ha_work` (
   `time_to_try` bigint COMMENT 'time to try do this work',
   `updated` bigint unsigned NOT NULL COMMENT 'time the VM state was updated when it was stored into work queue',
   PRIMARY KEY (`id`),
-  CONSTRAINT `fk_op_ha_work__instance_id` FOREIGN KEY `fk_op_ha_work__instance_id` (`instance_id`) REFERENCES `vm_instance` (`id`) ON DELETE CASCADE, 
+  CONSTRAINT `fk_op_ha_work__instance_id` FOREIGN KEY `fk_op_ha_work__instance_id` (`instance_id`) REFERENCES `vm_instance` (`id`) ON DELETE CASCADE,
   INDEX `i_op_ha_work__instance_id`(`instance_id`),
   CONSTRAINT `fk_op_ha_work__host_id` FOREIGN KEY `fk_op_ha_work__host_id` (`host_id`) REFERENCES `host` (`id`),
-  INDEX `i_op_ha_work__host_id`(`host_id`), 
-  INDEX `i_op_ha_work__step`(`step`), 
+  INDEX `i_op_ha_work__host_id`(`host_id`),
+  INDEX `i_op_ha_work__step`(`step`),
   INDEX `i_op_ha_work__type`(`type`),
   CONSTRAINT `fk_op_ha_work__mgmt_server_id` FOREIGN KEY `fk_op_ha_work__mgmt_server_id`(`mgmt_server_id`) REFERENCES `mshost`(`msid`),
   INDEX `i_op_ha_work__mgmt_server_id`(`mgmt_server_id`)
@@ -682,7 +682,7 @@ CREATE TABLE  `cloud`.`host_pod_ref` (
   `gateway` varchar(255) NOT NULL COMMENT 'gateway for the pod',
   `cidr_address` varchar(15) NOT NULL COMMENT 'CIDR address for the pod',
   `cidr_size` bigint unsigned NOT NULL COMMENT 'CIDR size for the pod',
-  `description` varchar(255) COMMENT 'store private ip range in startIP-endIP format',  
+  `description` varchar(255) COMMENT 'store private ip range in startIP-endIP format',
   `allocation_state` varchar(32) NOT NULL DEFAULT 'Enabled' COMMENT 'Is this Pod enabled for allocation for new resources',
   `external_dhcp` tinyint NOT NULL DEFAULT 0 COMMENT 'Is this Pod using external DHCP',
   `removed` datetime COMMENT 'date removed if not null',
@@ -692,13 +692,13 @@ CREATE TABLE  `cloud`.`host_pod_ref` (
   INDEX `i_host_pod_ref__allocation_state`(`allocation_state`),
   INDEX `i_host_pod_ref__removed`(`removed`),
   CONSTRAINT `uc_host_pod_ref__uuid` UNIQUE (`uuid`)
-  
+
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
 CREATE TABLE `cloud`.`op_dc_vnet_alloc` (
     `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'primary id',
     `vnet` varchar(18) NOT NULL COMMENT 'vnet',
-	`physical_network_id` bigint unsigned NOT NULL COMMENT 'physical network the vnet belongs to',	
+	`physical_network_id` bigint unsigned NOT NULL COMMENT 'physical network the vnet belongs to',
     `data_center_id` bigint unsigned NOT NULL COMMENT 'data center the vnet belongs to',
     `reservation_id` char(40) NULL COMMENT 'reservation id',
     `account_id` bigint unsigned NULL COMMENT 'account the vnet belongs to right now',
@@ -812,7 +812,7 @@ CREATE TABLE `cloud`.`port_forwarding_rules` (
 CREATE TABLE  `cloud`.`host` (
   `id` bigint unsigned NOT NULL auto_increment,
   `name` varchar(255) NOT NULL,
-  `uuid` varchar(40) COMMENT 'this uuid is different with guid below, the later one is used by hypervisor resource',  
+  `uuid` varchar(40) COMMENT 'this uuid is different with guid below, the later one is used by hypervisor resource',
   `status` varchar(32) NOT NULL,
   `type` varchar(32) NOT NULL,
   `private_ip_address` char(40) NOT NULL,
@@ -869,7 +869,7 @@ CREATE TABLE `cloud`.`op_host` (
   `id` bigint unsigned NOT NULL UNIQUE COMMENT 'host id',
   `sequence` bigint unsigned DEFAULT 1 NOT NULL COMMENT 'sequence for the host communication',
   PRIMARY KEY (`id`),
-  CONSTRAINT `fk_op_host__id` FOREIGN KEY (`id`) REFERENCES `host`(`id`) ON DELETE CASCADE 
+  CONSTRAINT `fk_op_host__id` FOREIGN KEY (`id`) REFERENCES `host`(`id`) ON DELETE CASCADE
 ) ENGINE = InnoDB DEFAULT CHARSET=utf8;
 
 CREATE TABLE `cloud`.`account_details` (
@@ -915,7 +915,7 @@ CREATE TABLE  `cloud`.`mshost_peer` (
   `peer_runid` bigint NOT NULL,
   `peer_state` varchar(10) NOT NULL DEFAULT 'Down',
   `last_update` DATETIME NULL COMMENT 'Last record update time',
-  
+
   PRIMARY KEY  (`id`),
   CONSTRAINT `fk_mshost_peer__owner_mshost` FOREIGN KEY (`owner_mshost`) REFERENCES `mshost`(`id`) ON DELETE CASCADE,
   CONSTRAINT `fk_mshost_peer__peer_mshost` FOREIGN KEY (`peer_mshost`) REFERENCES `mshost`(`id`),
@@ -965,7 +965,7 @@ CREATE TABLE  `cloud`.`event` (
   `description` varchar(1024) NOT NULL,
   `user_id` bigint unsigned NOT NULL,
   `account_id` bigint unsigned NOT NULL,
-  `domain_id` bigint unsigned NOT NULL,  
+  `domain_id` bigint unsigned NOT NULL,
   `created` datetime NOT NULL,
   `level` varchar(16) NOT NULL,
   `start_id` bigint unsigned NOT NULL DEFAULT 0,
@@ -1046,7 +1046,7 @@ CREATE TABLE  `cloud`.`vm_template` (
   `hvm`  int(1) unsigned NOT NULL COMMENT 'requires HVM',
   `bits` int(6) unsigned NOT NULL COMMENT '32 bit or 64 bit',
   `url` varchar(255) NULL COMMENT 'the url where the template exists externally',
-  `format` varchar(32) NOT NULL COMMENT 'format for the template', 
+  `format` varchar(32) NOT NULL COMMENT 'format for the template',
   `created` datetime NOT NULL COMMENT 'Date created',
   `removed` datetime COMMENT 'Date removed if not null',
   `account_id` bigint unsigned NOT NULL COMMENT 'id of the account that created this template',
@@ -1153,7 +1153,7 @@ CREATE TABLE `cloud`.`domain_router` (
   `public_ip_address` char(40)  COMMENT 'public ip address used for source net',
   `public_netmask` varchar(15)  COMMENT 'netmask used for the domR',
   `guest_netmask` varchar(15) COMMENT 'netmask used for the guest network',
-  `guest_ip_address` char(40) COMMENT ' ip address in the guest network',   
+  `guest_ip_address` char(40) COMMENT ' ip address in the guest network',
   `is_redundant_router` int(1) unsigned NOT NULL COMMENT 'if in redundant router mode',
   `priority` int(4) unsigned COMMENT 'priority of router in the redundant router mode',
   `is_priority_bumpup` int(1) unsigned NOT NULL COMMENT 'if the priority has been bumped up',
@@ -1230,7 +1230,7 @@ CREATE TABLE  `cloud`.`volume_host_ref` (
   `local_path` varchar(255),
   `install_path` varchar(255),
   `url` varchar(255),
-  `format` varchar(32) NOT NULL COMMENT 'format for the volume', 
+  `format` varchar(32) NOT NULL COMMENT 'format for the volume',
   `destroyed` tinyint(1) COMMENT 'indicates whether the volume_host entry was destroyed by the user or not',
   PRIMARY KEY  (`id`),
   CONSTRAINT `fk_volume_host_ref__host_id` FOREIGN KEY `fk_volume_host_ref__host_id` (`host_id`) REFERENCES `host` (`id`) ON DELETE CASCADE,
@@ -1330,9 +1330,9 @@ CREATE TABLE  `cloud`.`account` (
   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,
   INDEX `i_account__cleanup_needed`(`cleanup_needed`),
-  INDEX `i_account__account_name__domain_id__removed`(`account_name`, `domain_id`, `removed`), 
+  INDEX `i_account__account_name__domain_id__removed`(`account_name`, `domain_id`, `removed`),
   CONSTRAINT `fk_account__domain_id` FOREIGN KEY(`domain_id`) REFERENCES `domain` (`id`),
-  INDEX `i_account__domain_id`(`domain_id`),  
+  INDEX `i_account__domain_id`(`domain_id`),
   CONSTRAINT `uc_account__uuid` UNIQUE (`uuid`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
@@ -1380,7 +1380,7 @@ CREATE TABLE `cloud`.`op_host_capacity` (
   INDEX `i_op_host_capacity__host_type`(`host_id`, `capacity_type`),
   INDEX `i_op_host_capacity__pod_id`(`pod_id`),
   INDEX `i_op_host_capacity__data_center_id`(`data_center_id`),
-  INDEX `i_op_host_capacity__cluster_id`(`cluster_id`)  
+  INDEX `i_op_host_capacity__cluster_id`(`cluster_id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
 CREATE TABLE `cloud`.`alert` (
@@ -1404,7 +1404,7 @@ CREATE TABLE `cloud`.`async_job` (
   `user_id` bigint unsigned NOT NULL,
   `account_id` bigint unsigned NOT NULL,
   `session_key` varchar(64) COMMENT 'all async-job manage to apply session based security enforcement',
-  `instance_type` varchar(64) COMMENT 'instance_type and instance_id work together to allow attaching an instance object to a job',			
+  `instance_type` varchar(64) COMMENT 'instance_type and instance_id work together to allow attaching an instance object to a job',
   `instance_id` bigint unsigned,
   `job_cmd` varchar(64) NOT NULL COMMENT 'command name',
   `job_cmd_originator` varchar(64) COMMENT 'command originator',
@@ -1437,7 +1437,7 @@ CREATE TABLE `cloud`.`async_job` (
 
 CREATE TABLE `cloud`.`sync_queue` (
   `id` bigint unsigned NOT NULL auto_increment,
-  `sync_objtype` varchar(64) NOT NULL, 
+  `sync_objtype` varchar(64) NOT NULL,
   `sync_objid` bigint unsigned NOT NULL,
   `queue_proc_msid` bigint,
   `queue_proc_number` bigint COMMENT 'process number, increase 1 for each iteration',
@@ -1815,7 +1815,7 @@ CREATE TABLE `cloud`.`instance_group` (
   `created` datetime COMMENT 'date the group was created',
   PRIMARY KEY  (`id`),
   INDEX `i_instance_group__removed`(`removed`),
-  CONSTRAINT `uc_instance_group__uuid` UNIQUE (`uuid`),  
+  CONSTRAINT `uc_instance_group__uuid` UNIQUE (`uuid`),
   CONSTRAINT `fk_instance_group__account_id` FOREIGN KEY(`account_id`) REFERENCES `account` (`id`)
 ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
 
@@ -1850,7 +1850,7 @@ CREATE TABLE  `cloud`.`usage_event` (
   `resource_name` varchar(255),
   `offering_id` bigint unsigned,
   `template_id` bigint unsigned,
-  `size` bigint unsigned,  
+  `size` bigint unsigned,
   `resource_type` varchar(32),
   `processed` tinyint NOT NULL default '0',
   PRIMARY KEY  (`id`),
@@ -2055,9 +2055,9 @@ CREATE TABLE `cloud`.`physical_network` (
   `name` varchar(255) NOT NULL,
   `data_center_id` bigint unsigned NOT NULL COMMENT 'data center id that this physical network belongs to',
   `vnet` varchar(255),
-  `speed` varchar(32),  
+  `speed` varchar(32),
   `domain_id` bigint unsigned COMMENT 'foreign key to domain id',
-  `broadcast_domain_range` varchar(32) NOT NULL DEFAULT 'POD' COMMENT 'range of broadcast domain : POD/ZONE', 
+  `broadcast_domain_range` varchar(32) NOT NULL DEFAULT 'POD' COMMENT 'range of broadcast domain : POD/ZONE',
   `state` varchar(32) NOT NULL DEFAULT 'Disabled' COMMENT 'what state is this configuration in',
   `created` datetime COMMENT 'date created',
   `removed` datetime COMMENT 'date removed if not null',
@@ -2065,7 +2065,7 @@ CREATE TABLE `cloud`.`physical_network` (
   CONSTRAINT `fk_physical_network__data_center_id` FOREIGN KEY (`data_center_id`) REFERENCES `data_center`(`id`) ON DELETE CASCADE,
   CONSTRAINT `fk_physical_network__domain_id` FOREIGN KEY(`domain_id`) REFERENCES `domain`(`id`),
   CONSTRAINT `uc_physical_networks__uuid` UNIQUE (`uuid`),
-  INDEX `i_physical_network__removed`(`removed`) 
+  INDEX `i_physical_network__removed`(`removed`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
 CREATE TABLE `cloud`.`physical_network_tags` (
@@ -2091,7 +2091,7 @@ CREATE TABLE `cloud`.`physical_network_traffic_types` (
   `uuid` varchar(40),
   `physical_network_id` bigint unsigned NOT NULL COMMENT 'id of the physical network',
   `traffic_type` varchar(32) NOT NULL COMMENT 'type of traffic going through this network',
-  `xenserver_network_label` varchar(255) COMMENT 'The network name label of the physical device dedicated to this traffic on a XenServer host',
+  `xen_network_label` varchar(255) COMMENT 'The network name label of the physical device dedicated to this traffic on a XenServer host',
   `kvm_network_label` varchar(255) DEFAULT 'cloudbr0' COMMENT 'The network name label of the physical device dedicated to this traffic on a KVM host',
   `vmware_network_label` varchar(255) DEFAULT 'vSwitch0' COMMENT 'The network name label of the physical device dedicated to this traffic on a VMware host',
   `simulator_network_label` varchar(255) COMMENT 'The name labels needed for identifying the simulator',
@@ -2333,7 +2333,7 @@ CREATE TABLE `cloud`.`vpc` (
   PRIMARY KEY  (`id`),
   INDEX `i_vpc__removed`(`removed`),
   CONSTRAINT `fk_vpc__zone_id` FOREIGN KEY `fk_vpc__zone_id` (`zone_id`) REFERENCES `data_center` (`id`) ON DELETE CASCADE,
-  CONSTRAINT `fk_vpc__vpc_offering_id` FOREIGN KEY (`vpc_offering_id`) REFERENCES `vpc_offerings`(`id`), 
+  CONSTRAINT `fk_vpc__vpc_offering_id` FOREIGN KEY (`vpc_offering_id`) REFERENCES `vpc_offerings`(`id`),
   CONSTRAINT `fk_vpc__account_id` FOREIGN KEY `fk_vpc__account_id` (`account_id`) REFERENCES `account`(`id`) ON DELETE CASCADE,
   CONSTRAINT `fk_vpc__domain_id` FOREIGN KEY `fk_vpc__domain_id` (`domain_id`) REFERENCES `domain`(`id`) ON DELETE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -2423,7 +2423,7 @@ CREATE TABLE `cloud`.`static_routes` (
   `id` bigint unsigned NOT NULL auto_increment COMMENT 'id',
   `uuid` varchar(40),
   `vpc_gateway_id` bigint unsigned COMMENT 'id of the corresponding ip address',
-  `cidr` varchar(18) COMMENT 'cidr for the static route', 
+  `cidr` varchar(18) COMMENT 'cidr for the static route',
   `state` char(32) NOT NULL COMMENT 'current state of this rule',
   `vpc_id` bigint unsigned COMMENT 'vpc the firewall rule is associated with',
   `account_id` bigint unsigned NOT NULL COMMENT 'owner id',

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b87a5ce5/setup/db/db/schema-440to450.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-440to450.sql b/setup/db/db/schema-440to450.sql
index c88a18a..1a019dd 100644
--- a/setup/db/db/schema-440to450.sql
+++ b/setup/db/db/schema-440to450.sql
@@ -233,4 +233,4 @@ CREATE VIEW `cloud`.`volume_view` AS
             and async_job.job_status = 0;
 
 /* As part of the separation of Xen and XenServer, update the column for the network labels */
-ALTER TABLE `cloud`.`physical_network_traffic_types` CHANGE `xen_network_label` `xenserver_network_label` varchar(255) COMMENT 'The network name label of the physical device dedicated to this traffic on a XenServer host'
+ALTER TABLE `cloud`.`physical_network_traffic_types` CHANGE `xen_network_label` `xenserver_network_label` varchar(255) COMMENT 'The network name label of the physical device dedicated to this traffic on a XenServer host';


[2/2] git commit: updated refs/heads/master to 5a96d8e

Posted by al...@apache.org.
CLOUDSTACK-7073: Added domainId field to the user table in order to restrict duplicated users creation on the db level


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/5a96d8ef
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/5a96d8ef
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/5a96d8ef

Branch: refs/heads/master
Commit: 5a96d8ef5cbc88df366016ae9dd7ee46e4ca417a
Parents: b87a5ce
Author: Alena Prokharchyk <al...@citrix.com>
Authored: Mon Jul 7 15:12:36 2014 -0700
Committer: Alena Prokharchyk <al...@citrix.com>
Committed: Mon Jul 7 16:21:38 2014 -0700

----------------------------------------------------------------------
 engine/schema/src/com/cloud/user/UserVO.java          |  6 ++++++
 engine/schema/src/com/cloud/user/dao/UserDaoImpl.java | 13 +++++++++++++
 setup/db/db/schema-440to450.sql                       |  6 ++++++
 3 files changed, 25 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a96d8ef/engine/schema/src/com/cloud/user/UserVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/user/UserVO.java b/engine/schema/src/com/cloud/user/UserVO.java
index 68879f6..8ab450d 100644
--- a/engine/schema/src/com/cloud/user/UserVO.java
+++ b/engine/schema/src/com/cloud/user/UserVO.java
@@ -97,6 +97,9 @@ public class UserVO implements User, Identity, InternalIdentity {
     @Column(name = "default")
     boolean isDefault;
 
+    @Column(name = "domain_id")
+    private long domainId;
+
     public UserVO() {
         this.uuid = UUID.randomUUID().toString();
     }
@@ -270,4 +273,7 @@ public class UserVO implements User, Identity, InternalIdentity {
         return isDefault;
     }
 
+    public void setDomainId(long domainId) {
+        this.domainId = domainId;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a96d8ef/engine/schema/src/com/cloud/user/dao/UserDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/user/dao/UserDaoImpl.java b/engine/schema/src/com/cloud/user/dao/UserDaoImpl.java
index 6ac398d..d39177e 100644
--- a/engine/schema/src/com/cloud/user/dao/UserDaoImpl.java
+++ b/engine/schema/src/com/cloud/user/dao/UserDaoImpl.java
@@ -19,9 +19,11 @@ package com.cloud.user.dao;
 import java.util.List;
 
 import javax.ejb.Local;
+import javax.inject.Inject;
 
 import org.springframework.stereotype.Component;
 
+import com.cloud.user.Account;
 import com.cloud.user.UserVO;
 import com.cloud.utils.db.DB;
 import com.cloud.utils.db.GenericDaoBase;
@@ -40,6 +42,9 @@ public class UserDaoImpl extends GenericDaoBase<UserVO, Long> implements UserDao
     protected SearchBuilder<UserVO> SecretKeySearch;
     protected SearchBuilder<UserVO> RegistrationTokenSearch;
 
+    @Inject
+    AccountDao _accountDao;
+
     protected UserDaoImpl() {
         UsernameSearch = createSearchBuilder();
         UsernameSearch.and("username", UsernameSearch.entity().getUsername(), SearchCriteria.Op.EQ);
@@ -128,4 +133,12 @@ public class UserDaoImpl extends GenericDaoBase<UserVO, Long> implements UserDao
         return listBy(sc);
     }
 
+    @Override
+    @DB
+    public UserVO persist(UserVO user) {
+        Account account = _accountDao.findById(user.getAccountId());
+        user.setDomainId(account.getDomainId());
+        return super.persist(user);
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a96d8ef/setup/db/db/schema-440to450.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-440to450.sql b/setup/db/db/schema-440to450.sql
index 1a019dd..5fd6200 100644
--- a/setup/db/db/schema-440to450.sql
+++ b/setup/db/db/schema-440to450.sql
@@ -234,3 +234,9 @@ CREATE VIEW `cloud`.`volume_view` AS
 
 /* As part of the separation of Xen and XenServer, update the column for the network labels */
 ALTER TABLE `cloud`.`physical_network_traffic_types` CHANGE `xen_network_label` `xenserver_network_label` varchar(255) COMMENT 'The network name label of the physical device dedicated to this traffic on a XenServer host';
+
+/*Adding domainId field to the user table in order to restrict duplicated users creation on the db level*/
+ALTER TABLE `cloud`.`user` ADD COLUMN domain_id bigint(20) unsigned DEFAULT NULL;
+ALTER TABLE `cloud`.`user` ADD CONSTRAINT `fk_user__domain_id` FOREIGN KEY `fk_user__domain_id`(`domain_id`) REFERENCES `domain`(`id`) ON DELETE CASCADE;
+UPDATE `cloud`.`user` SET `cloud`.`user`.domain_id=(SELECT `cloud`.`account`.domain_id   FROM `cloud`.`account`   WHERE `cloud`.`account`.id=`cloud`.`user`.account_id) where id > 0;
+ALTER TABLE `cloud`.`user` ADD UNIQUE KEY `username_domain_id` (`username`,`domain_id`);