From 5a26ceb1b94eeafdffaba06703aaa857a981a4b1 Mon Sep 17 00:00:00 2001
From: licanwei
Date: Mon, 29 Jul 2019 20:24:35 +0800
Subject: [PATCH] update workload_balance strategy
For Compute node, we can use the new property to calculate
resource(VCPU, memory and disk).
Partially Implements: blueprint improve-compute-data-model
Depends-on: I3f9a3279a26f3df444117d9265e74cca57b38d6e
Change-Id: I9fe58603692a9850e86a2c36ad7a31c473070100
---
.../decision_engine/strategy/strategies/workload_balance.py | 6 +++---
.../model/data/scenario_4_with_1_node_no_instance.xml | 2 +-
.../decision_engine/model/data/scenario_6_with_2_nodes.xml | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/watcher/decision_engine/strategy/strategies/workload_balance.py b/watcher/decision_engine/strategy/strategies/workload_balance.py
index bc3b6bffe..f54792f4c 100644
--- a/watcher/decision_engine/strategy/strategies/workload_balance.py
+++ b/watcher/decision_engine/strategy/strategies/workload_balance.py
@@ -205,9 +205,9 @@ class WorkloadBalance(base.WorkloadStabilizationBaseStrategy):
# calculate the available resources
cores_used, mem_used, disk_used = self.calculate_used_resource(
host)
- cores_available = host.vcpus - cores_used
- disk_available = host.disk - disk_used
- mem_available = host.memory - mem_used
+ cores_available = host.vcpu_capacity - cores_used
+ disk_available = host.disk_gb_capacity - disk_used
+ mem_available = host.memory_mb_capacity - mem_used
if (cores_available >= required_cores and
mem_available >= required_mem and
disk_available >= required_disk):
diff --git a/watcher/tests/decision_engine/model/data/scenario_4_with_1_node_no_instance.xml b/watcher/tests/decision_engine/model/data/scenario_4_with_1_node_no_instance.xml
index 722b59250..1132e698c 100644
--- a/watcher/tests/decision_engine/model/data/scenario_4_with_1_node_no_instance.xml
+++ b/watcher/tests/decision_engine/model/data/scenario_4_with_1_node_no_instance.xml
@@ -1,3 +1,3 @@
-
+
diff --git a/watcher/tests/decision_engine/model/data/scenario_6_with_2_nodes.xml b/watcher/tests/decision_engine/model/data/scenario_6_with_2_nodes.xml
index 83189fc32..3d2ac24c6 100644
--- a/watcher/tests/decision_engine/model/data/scenario_6_with_2_nodes.xml
+++ b/watcher/tests/decision_engine/model/data/scenario_6_with_2_nodes.xml
@@ -1,9 +1,9 @@
-
+
-
+