set disk field to disk capacity

The node.free_disk_gb does not take allocation ratios used
for overcommit into account so this value may be negative.
We do not need this field and plan to set disk to total disk
capacity and then remove disk_capacity.

Partially Implements: blueprint improve-compute-data-model

Change-Id: I72c4490f5a8d0fbd1039f70ff20f07b743b6bb2d
This commit is contained in:
licanwei
2019-07-26 17:23:18 +08:00
parent e0f70cb87c
commit 6cc9ea7cfb
3 changed files with 13 additions and 3 deletions

View File

@@ -356,7 +356,12 @@ class NovaModelBuilder(base.BaseModelBuilder):
"memory_ratio": memory_ratio,
"memory_mb_reserved": memory_mb_reserved,
"memory_mb_used": memory_used,
"disk": node.free_disk_gb,
# The node.free_disk_gb does not take allocation ratios used
# for overcommit into account so this value may be negative.
# We do not need this field and plan to set disk to total disk
# capacity and then remove disk_capacity.
"disk": disk_capacity,
# TODO(licanwei): remove and replace by disk field
"disk_capacity": disk_capacity,
"disk_gb_used": disk_used,
"disk_gb_reserved": disk_gb_reserved,

View File

@@ -133,7 +133,12 @@ class NovaNotification(base.NotificationEndpoint):
status=_node.status,
memory=_node.memory_mb,
vcpus=_node.vcpus,
disk=_node.free_disk_gb,
# The node.free_disk_gb does not take allocation ratios used
# for overcommit into account so this value may be negative.
# We do not need this field and plan to set disk to total disk
# capacity and then remove disk_capacity.
disk=_node.local_gb,
# TODO(licanwei): remove and replace by disk field
disk_capacity=_node.local_gb,
)
self.cluster_data_model.add_node(node)

View File

@@ -313,7 +313,7 @@ class TestNovaNotifications(NotificationTestCase):
node_2 = compute_model.get_node_by_name('Node_2')
self.assertEqual(7777, node_2.memory)
self.assertEqual(42, node_2.vcpus)
self.assertEqual(974, node_2.disk)
self.assertEqual(1337, node_2.disk)
self.assertEqual(1337, node_2.disk_capacity)
@mock.patch.object(nova_helper, "NovaHelper")