Remove resource used fields from ComputeNode
The node resource(vcpu, memory and disk) used infomation need to change when creating or deleting instances. Now Placement do not send notifications, so there is not a good way to capture the change. We remove these fields and leave the process to strategy. Partially Implements: blueprint improve-compute-data-model Change-Id: I3f9a3279a26f3df444117d9265e74cca57b38d6e
This commit is contained in:
@@ -341,23 +341,6 @@ class NovaModelBuilder(base.BaseModelBuilder):
|
|||||||
disk_gb_reserved = 0
|
disk_gb_reserved = 0
|
||||||
disk_ratio = 1.0
|
disk_ratio = 1.0
|
||||||
|
|
||||||
usages = self.placement_helper.get_usages_for_resource_provider(
|
|
||||||
node.id)
|
|
||||||
if usages and orc.VCPU in usages:
|
|
||||||
vcpus_used = usages[orc.VCPU]
|
|
||||||
else:
|
|
||||||
vcpus_used = node.vcpus_used
|
|
||||||
|
|
||||||
if usages and orc.MEMORY_MB in usages:
|
|
||||||
memory_used = usages[orc.MEMORY_MB]
|
|
||||||
else:
|
|
||||||
memory_used = node.memory_mb_used
|
|
||||||
|
|
||||||
if usages and orc.DISK_GB in usages:
|
|
||||||
disk_used = usages[orc.DISK_GB]
|
|
||||||
else:
|
|
||||||
disk_used = node.local_gb_used
|
|
||||||
|
|
||||||
# build up the compute node.
|
# build up the compute node.
|
||||||
node_attributes = {
|
node_attributes = {
|
||||||
# The id of the hypervisor as a UUID from version 2.53.
|
# The id of the hypervisor as a UUID from version 2.53.
|
||||||
@@ -366,7 +349,6 @@ class NovaModelBuilder(base.BaseModelBuilder):
|
|||||||
"memory": memory_mb,
|
"memory": memory_mb,
|
||||||
"memory_ratio": memory_ratio,
|
"memory_ratio": memory_ratio,
|
||||||
"memory_mb_reserved": memory_mb_reserved,
|
"memory_mb_reserved": memory_mb_reserved,
|
||||||
"memory_mb_used": memory_used,
|
|
||||||
# The node.free_disk_gb does not take allocation ratios used
|
# The node.free_disk_gb does not take allocation ratios used
|
||||||
# for overcommit into account so this value may be negative.
|
# for overcommit into account so this value may be negative.
|
||||||
# We do not need this field and plan to set disk to total disk
|
# We do not need this field and plan to set disk to total disk
|
||||||
@@ -374,13 +356,11 @@ class NovaModelBuilder(base.BaseModelBuilder):
|
|||||||
"disk": disk_capacity,
|
"disk": disk_capacity,
|
||||||
# TODO(licanwei): remove and replace by disk field
|
# TODO(licanwei): remove and replace by disk field
|
||||||
"disk_capacity": disk_capacity,
|
"disk_capacity": disk_capacity,
|
||||||
"disk_gb_used": disk_used,
|
|
||||||
"disk_gb_reserved": disk_gb_reserved,
|
"disk_gb_reserved": disk_gb_reserved,
|
||||||
"disk_ratio": disk_ratio,
|
"disk_ratio": disk_ratio,
|
||||||
"vcpus": vcpus,
|
"vcpus": vcpus,
|
||||||
"vcpu_reserved": vcpu_reserved,
|
"vcpu_reserved": vcpu_reserved,
|
||||||
"vcpu_ratio": vcpu_ratio,
|
"vcpu_ratio": vcpu_ratio,
|
||||||
"vcpus_used": vcpus_used,
|
|
||||||
"state": node.state,
|
"state": node.state,
|
||||||
"status": node.status,
|
"status": node.status,
|
||||||
"disabled_reason": node.service["disabled_reason"]}
|
"disabled_reason": node.service["disabled_reason"]}
|
||||||
|
|||||||
@@ -40,13 +40,10 @@ class ComputeNode(compute_resource.ComputeResource):
|
|||||||
"state": wfields.StringField(default=ServiceState.ONLINE.value),
|
"state": wfields.StringField(default=ServiceState.ONLINE.value),
|
||||||
"memory": wfields.NonNegativeIntegerField(),
|
"memory": wfields.NonNegativeIntegerField(),
|
||||||
"memory_mb_reserved": wfields.NonNegativeIntegerField(),
|
"memory_mb_reserved": wfields.NonNegativeIntegerField(),
|
||||||
"memory_mb_used": wfields.NonNegativeIntegerField(),
|
|
||||||
"disk": wfields.IntegerField(),
|
"disk": wfields.IntegerField(),
|
||||||
"disk_capacity": wfields.NonNegativeIntegerField(),
|
"disk_capacity": wfields.NonNegativeIntegerField(),
|
||||||
"disk_gb_reserved": wfields.NonNegativeIntegerField(),
|
"disk_gb_reserved": wfields.NonNegativeIntegerField(),
|
||||||
"disk_gb_used": wfields.NonNegativeIntegerField(),
|
|
||||||
"vcpus": wfields.NonNegativeIntegerField(),
|
"vcpus": wfields.NonNegativeIntegerField(),
|
||||||
"vcpus_used": wfields.NonNegativeIntegerField(),
|
|
||||||
"vcpu_reserved": wfields.NonNegativeIntegerField(),
|
"vcpu_reserved": wfields.NonNegativeIntegerField(),
|
||||||
"memory_ratio": wfields.NonNegativeFloatField(),
|
"memory_ratio": wfields.NonNegativeFloatField(),
|
||||||
"vcpu_ratio": wfields.NonNegativeFloatField(),
|
"vcpu_ratio": wfields.NonNegativeFloatField(),
|
||||||
@@ -65,24 +62,9 @@ class ComputeNode(compute_resource.ComputeResource):
|
|||||||
return (self.disk-self.disk_gb_reserved)*self.disk_ratio
|
return (self.disk-self.disk_gb_reserved)*self.disk_ratio
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def vcpus_capacity(self):
|
def vcpu_capacity(self):
|
||||||
return (self.vcpus-self.vcpu_reserved)*self.vcpu_ratio
|
return (self.vcpus-self.vcpu_reserved)*self.vcpu_ratio
|
||||||
|
|
||||||
@property
|
|
||||||
def memory_mb_free(self):
|
|
||||||
total = (self.memory-self.memory_mb_reserved)*self.memory_ratio
|
|
||||||
return total-self.memory_mb_used
|
|
||||||
|
|
||||||
@property
|
|
||||||
def disk_gb_free(self):
|
|
||||||
total = (self.disk-self.disk_gb_reserved)*self.disk_ratio
|
|
||||||
return total-self.disk_gb_used
|
|
||||||
|
|
||||||
@property
|
|
||||||
def vcpus_free(self):
|
|
||||||
total = (self.vcpus-self.vcpu_reserved)*self.vcpu_ratio
|
|
||||||
return total-self.vcpus_used
|
|
||||||
|
|
||||||
|
|
||||||
@base.WatcherObjectRegistry.register_if(False)
|
@base.WatcherObjectRegistry.register_if(False)
|
||||||
class StorageNode(storage_resource.StorageResource):
|
class StorageNode(storage_resource.StorageResource):
|
||||||
|
|||||||
@@ -165,23 +165,6 @@ class NovaNotification(base.NotificationEndpoint):
|
|||||||
disk_gb_reserved = 0
|
disk_gb_reserved = 0
|
||||||
disk_ratio = 1.0
|
disk_ratio = 1.0
|
||||||
|
|
||||||
usages = self.placement_helper.get_usages_for_resource_provider(
|
|
||||||
_node.id)
|
|
||||||
if usages and orc.VCPU in usages:
|
|
||||||
vcpus_used = usages[orc.VCPU]
|
|
||||||
else:
|
|
||||||
vcpus_used = _node.vcpus_used
|
|
||||||
|
|
||||||
if usages and orc.MEMORY_MB in usages:
|
|
||||||
memory_used = usages[orc.MEMORY_MB]
|
|
||||||
else:
|
|
||||||
memory_used = _node.memory_mb_used
|
|
||||||
|
|
||||||
if usages and orc.DISK_GB in usages:
|
|
||||||
disk_used = usages[orc.DISK_GB]
|
|
||||||
else:
|
|
||||||
disk_used = _node.local_gb_used
|
|
||||||
|
|
||||||
# build up the compute node.
|
# build up the compute node.
|
||||||
node_attributes = {
|
node_attributes = {
|
||||||
# The id of the hypervisor as a UUID from version 2.53.
|
# The id of the hypervisor as a UUID from version 2.53.
|
||||||
@@ -190,7 +173,6 @@ class NovaNotification(base.NotificationEndpoint):
|
|||||||
"memory": memory_mb,
|
"memory": memory_mb,
|
||||||
"memory_ratio": memory_ratio,
|
"memory_ratio": memory_ratio,
|
||||||
"memory_mb_reserved": memory_mb_reserved,
|
"memory_mb_reserved": memory_mb_reserved,
|
||||||
"memory_mb_used": memory_used,
|
|
||||||
# The node.free_disk_gb does not take allocation ratios used
|
# The node.free_disk_gb does not take allocation ratios used
|
||||||
# for overcommit into account so this value may be negative.
|
# for overcommit into account so this value may be negative.
|
||||||
# We do not need this field and plan to set disk to total disk
|
# We do not need this field and plan to set disk to total disk
|
||||||
@@ -198,13 +180,11 @@ class NovaNotification(base.NotificationEndpoint):
|
|||||||
"disk": disk_capacity,
|
"disk": disk_capacity,
|
||||||
# TODO(licanwei): remove and replace by disk field
|
# TODO(licanwei): remove and replace by disk field
|
||||||
"disk_capacity": disk_capacity,
|
"disk_capacity": disk_capacity,
|
||||||
"disk_gb_used": disk_used,
|
|
||||||
"disk_gb_reserved": disk_gb_reserved,
|
"disk_gb_reserved": disk_gb_reserved,
|
||||||
"disk_ratio": disk_ratio,
|
"disk_ratio": disk_ratio,
|
||||||
"vcpus": vcpus,
|
"vcpus": vcpus,
|
||||||
"vcpu_reserved": vcpu_reserved,
|
"vcpu_reserved": vcpu_reserved,
|
||||||
"vcpu_ratio": vcpu_ratio,
|
"vcpu_ratio": vcpu_ratio,
|
||||||
"vcpus_used": vcpus_used,
|
|
||||||
"state": _node.state,
|
"state": _node.state,
|
||||||
"status": _node.status,
|
"status": _node.status,
|
||||||
"disabled_reason": _node.service["disabled_reason"]}
|
"disabled_reason": _node.service["disabled_reason"]}
|
||||||
|
|||||||
@@ -154,18 +154,12 @@ class TestNovaClusterDataModelCollector(base.TestCase):
|
|||||||
|
|
||||||
memory_total = (node.memory-node.memory_mb_reserved)*node.memory_ratio
|
memory_total = (node.memory-node.memory_mb_reserved)*node.memory_ratio
|
||||||
self.assertEqual(node.memory_mb_capacity, memory_total)
|
self.assertEqual(node.memory_mb_capacity, memory_total)
|
||||||
memory_free = memory_total - node.memory_mb_used
|
|
||||||
self.assertEqual(node.memory_mb_free, memory_free)
|
|
||||||
|
|
||||||
disk_total = (node.disk_capacity-node.disk_gb_reserved)*node.disk_ratio
|
disk_total = (node.disk_capacity-node.disk_gb_reserved)*node.disk_ratio
|
||||||
self.assertEqual(node.disk_gb_capacity, disk_total)
|
self.assertEqual(node.disk_gb_capacity, disk_total)
|
||||||
disk_free = disk_total - node.disk_gb_used
|
|
||||||
self.assertEqual(node.disk_gb_free, disk_free)
|
|
||||||
|
|
||||||
vcpus_total = (node.vcpus-node.vcpu_reserved)*node.vcpu_ratio
|
vcpus_total = (node.vcpus-node.vcpu_reserved)*node.vcpu_ratio
|
||||||
self.assertEqual(node.vcpus_capacity, vcpus_total)
|
self.assertEqual(node.vcpu_capacity, vcpus_total)
|
||||||
vcpus_free = vcpus_total - node.vcpus_used
|
|
||||||
self.assertEqual(node.vcpus_free, vcpus_free)
|
|
||||||
|
|
||||||
m_nova_helper.get_compute_node_by_name.assert_called_once_with(
|
m_nova_helper.get_compute_node_by_name.assert_called_once_with(
|
||||||
minimal_node['hypervisor_hostname'], servers=True, detailed=True)
|
minimal_node['hypervisor_hostname'], servers=True, detailed=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user