Bug 9309 - In Manual migration, do not consider 'reserved_capacity' when computing available memory in destination

Changes:
- Now while listing hosts for migration, capacity is calculated as total_capacity -used_capacity
 instead of total_capacity -(used_capacity + reserved_capacity)
- Also, the capacity columns in op_host_capacity are now 'signed' type so that the subtractions in queries does not overflow.
- Added this to DB upgrade 222 to 224 change as well.
This commit is contained in:
prachi 2011-04-05 13:57:55 -07:00
parent c31330b6d9
commit 9f10d9957e
3 changed files with 9 additions and 5 deletions

View File

@ -55,8 +55,8 @@ public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements
private SearchBuilder<CapacityVO> _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();

View File

@ -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`),

View File

@ -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'),