diff --git a/server/src/com/cloud/capacity/dao/CapacityDaoImpl.java b/server/src/com/cloud/capacity/dao/CapacityDaoImpl.java index ac09da421aa..7ee1d90894f 100755 --- a/server/src/com/cloud/capacity/dao/CapacityDaoImpl.java +++ b/server/src/com/cloud/capacity/dao/CapacityDaoImpl.java @@ -55,8 +55,8 @@ public class CapacityDaoImpl extends GenericDaoBase implements private SearchBuilder _hostOrPoolIdSearch; private static final String LIST_HOSTS_IN_CLUSTER_WITH_ENOUGH_CAPACITY = "SELECT a.host_id FROM (host JOIN op_host_capacity a ON host.id = a.host_id AND host.cluster_id = ? AND host.type = ? " + - "AND a.total_capacity - (a.used_capacity + a.reserved_capacity) >= ? and a.capacity_type = 1) " + - "JOIN op_host_capacity b ON a.host_id = b.host_id AND b.total_capacity - (b.used_capacity + b.reserved_capacity) >= ? AND b.capacity_type = 0"; + "AND a.total_capacity - a.used_capacity >= ? and a.capacity_type = 1) " + + "JOIN op_host_capacity b ON a.host_id = b.host_id AND b.total_capacity - b.used_capacity >= ? AND b.capacity_type = 0"; public CapacityDaoImpl() { _hostIdTypeSearch = createSearchBuilder(); diff --git a/setup/db/create-schema.sql b/setup/db/create-schema.sql index 993bd289e60..4c9e704f9aa 100755 --- a/setup/db/create-schema.sql +++ b/setup/db/create-schema.sql @@ -1007,9 +1007,9 @@ CREATE TABLE `cloud`.`op_host_capacity` ( `data_center_id` bigint unsigned NOT NULL, `pod_id` bigint unsigned, `cluster_id` bigint unsigned COMMENT 'foreign key to cluster', - `used_capacity` bigint unsigned NOT NULL, - `reserved_capacity` bigint unsigned NOT NULL, - `total_capacity` bigint unsigned NOT NULL, + `used_capacity` bigint signed NOT NULL, + `reserved_capacity` bigint signed NOT NULL, + `total_capacity` bigint signed NOT NULL, `capacity_type` int(1) unsigned NOT NULL, PRIMARY KEY (`id`), INDEX `i_op_host_capacity__host_type`(`host_id`, `capacity_type`), diff --git a/setup/db/db/schema-222to224.sql b/setup/db/db/schema-222to224.sql index a8eac64960f..7054d13d842 100644 --- a/setup/db/db/schema-222to224.sql +++ b/setup/db/db/schema-222to224.sql @@ -70,6 +70,10 @@ CREATE TABLE `cloud`.`data_center_details` ( CONSTRAINT `fk_dc_details__dc_id` FOREIGN KEY (`dc_id`) REFERENCES `data_center`(`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +ALTER TABLE `cloud`.`op_host_capacity` MODIFY `used_capacity` bigint signed NOT NULL; +ALTER TABLE `cloud`.`op_host_capacity` MODIFY `reserved_capacity` bigint signed NOT NULL; +ALTER TABLE `cloud`.`op_host_capacity` MODIFY `total_capacity` bigint signed NOT NULL; + #('Advanced','DEFAULT','management-server','management.network.cidr','192.168.130.0/24','The cidr of management server network'),; INSERT INTO `cloud`.`configuration` VALUES ('Advanced','DEFAULT','management-server','control.cidr','169.254.0.0/16','Changes the cidr for the control network traffic. Defaults to using link local. Must be unique within pods'),