From 3bcd25727fe5ff9596c7902316e6b58570a57d60 Mon Sep 17 00:00:00 2001 From: licanwei Date: Mon, 29 Jul 2019 16:37:35 +0800 Subject: [PATCH] update host_maintenance 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: I2bb230b5f5a573fb3045261dfdee73f1a8434e0d --- .../strategy/strategies/host_maintenance.py | 6 +++--- .../tests/decision_engine/model/data/scenario_1.xml | 10 +++++----- .../model/data/scenario_1_with_all_nodes_disable.xml | 4 ++-- .../scenario_9_with_3_active_plus_1_disabled_nodes.xml | 8 ++++---- .../tests/decision_engine/model/faker_cluster_state.py | 6 ++++++ 5 files changed, 20 insertions(+), 14 deletions(-) diff --git a/watcher/decision_engine/strategy/strategies/host_maintenance.py b/watcher/decision_engine/strategy/strategies/host_maintenance.py index ccd3a306b..5e5479cfb 100644 --- a/watcher/decision_engine/strategy/strategies/host_maintenance.py +++ b/watcher/decision_engine/strategy/strategies/host_maintenance.py @@ -133,9 +133,9 @@ class HostMaintenance(base.HostMaintenanceBaseStrategy): :param node: node object :return: dict(cpu(cores), ram(MB), disk(B)) """ - return dict(cpu=node.vcpus, - ram=node.memory, - disk=node.disk) + return dict(cpu=node.vcpu_capacity, + ram=node.memory_mb_capacity, + disk=node.disk_gb_capacity) def get_node_used(self, node): """Collect cpu, ram and disk used of a node. diff --git a/watcher/tests/decision_engine/model/data/scenario_1.xml b/watcher/tests/decision_engine/model/data/scenario_1.xml index 933399961..83cc43496 100644 --- a/watcher/tests/decision_engine/model/data/scenario_1.xml +++ b/watcher/tests/decision_engine/model/data/scenario_1.xml @@ -1,20 +1,20 @@ - + - + - + - + - + diff --git a/watcher/tests/decision_engine/model/data/scenario_1_with_all_nodes_disable.xml b/watcher/tests/decision_engine/model/data/scenario_1_with_all_nodes_disable.xml index a2f9ea2a9..7ee44a612 100644 --- a/watcher/tests/decision_engine/model/data/scenario_1_with_all_nodes_disable.xml +++ b/watcher/tests/decision_engine/model/data/scenario_1_with_all_nodes_disable.xml @@ -1,8 +1,8 @@ - + - + diff --git a/watcher/tests/decision_engine/model/data/scenario_9_with_3_active_plus_1_disabled_nodes.xml b/watcher/tests/decision_engine/model/data/scenario_9_with_3_active_plus_1_disabled_nodes.xml index bdc602a0d..9c7b66afb 100644 --- a/watcher/tests/decision_engine/model/data/scenario_9_with_3_active_plus_1_disabled_nodes.xml +++ b/watcher/tests/decision_engine/model/data/scenario_9_with_3_active_plus_1_disabled_nodes.xml @@ -1,16 +1,16 @@ - + - + - + - + diff --git a/watcher/tests/decision_engine/model/faker_cluster_state.py b/watcher/tests/decision_engine/model/faker_cluster_state.py index a64f2a7bb..51ca228c5 100644 --- a/watcher/tests/decision_engine/model/faker_cluster_state.py +++ b/watcher/tests/decision_engine/model/faker_cluster_state.py @@ -82,9 +82,15 @@ class FakerModelCollector(base.BaseClusterDataModelCollector): "uuid": node_uuid, "hostname": hostname, "memory": 132, + "memory_mb_reserved": 0, + "memory_ratio": 1, "disk": 250, "disk_capacity": 250, + "disk_gb_reserved": 0, + "disk_ratio": 1, "vcpus": 40, + "vcpu_reserved": 0, + "vcpu_ratio": 1, } node = element.ComputeNode(**node_attributes) model.add_node(node)