Fix the missing _get_disk_allocation_ratio() in disk constraint

Add back the missing _get_disk_allocation_ratio() method and related calls
which are supposed to be in disk_constraint.py.

Change-Id: I69fbc02387c9c4735568af126eae6c7d6e2e84f1
This commit is contained in:
Xinyuan Huang 2015-05-28 21:11:25 +08:00
parent 0113f831ba
commit 1f8b9723e6
1 changed files with 6 additions and 1 deletions

View File

@ -29,6 +29,9 @@ LOG = logging.getLogger(__name__)
class DiskConstraint(constraints.BaseLinearConstraint):
"""Constraint of the maximum total disk demand acceptable on each host."""
def _get_disk_allocation_ratio(self, host_state, filter_properties):
return CONF.disk_allocation_ratio
def get_constraint_matrix(self, hosts, filter_properties):
num_hosts = len(hosts)
num_instances = filter_properties.get('num_instances')
@ -52,10 +55,12 @@ class DiskConstraint(constraints.BaseLinearConstraint):
return constraint_matrix
for i in xrange(num_hosts):
disk_allocation_ratio = self._get_disk_allocation_ratio(
hosts[i], filter_properties)
# get usable disk
free_disk_mb = hosts[i].free_disk_mb
total_usable_disk_mb = hosts[i].total_usable_disk_gb * 1024
disk_mb_limit = total_usable_disk_mb * CONF.disk_allocation_ratio
disk_mb_limit = total_usable_disk_mb * disk_allocation_ratio
used_disk_mb = total_usable_disk_mb - free_disk_mb
usable_disk_mb = disk_mb_limit - used_disk_mb