diff --git a/watcher/decision_engine/model/collector/nova.py b/watcher/decision_engine/model/collector/nova.py index 88e4909f8..c580c7462 100644 --- a/watcher/decision_engine/model/collector/nova.py +++ b/watcher/decision_engine/model/collector/nova.py @@ -341,23 +341,6 @@ class NovaModelBuilder(base.BaseModelBuilder): disk_gb_reserved = 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. node_attributes = { # The id of the hypervisor as a UUID from version 2.53. @@ -366,7 +349,6 @@ class NovaModelBuilder(base.BaseModelBuilder): "memory": memory_mb, "memory_ratio": memory_ratio, "memory_mb_reserved": memory_mb_reserved, - "memory_mb_used": memory_used, # 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 @@ -374,13 +356,11 @@ class NovaModelBuilder(base.BaseModelBuilder): "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, "disk_ratio": disk_ratio, "vcpus": vcpus, "vcpu_reserved": vcpu_reserved, "vcpu_ratio": vcpu_ratio, - "vcpus_used": vcpus_used, "state": node.state, "status": node.status, "disabled_reason": node.service["disabled_reason"]} diff --git a/watcher/decision_engine/model/element/node.py b/watcher/decision_engine/model/element/node.py index ba15d1078..a8d6aa308 100644 --- a/watcher/decision_engine/model/element/node.py +++ b/watcher/decision_engine/model/element/node.py @@ -40,13 +40,10 @@ class ComputeNode(compute_resource.ComputeResource): "state": wfields.StringField(default=ServiceState.ONLINE.value), "memory": wfields.NonNegativeIntegerField(), "memory_mb_reserved": wfields.NonNegativeIntegerField(), - "memory_mb_used": wfields.NonNegativeIntegerField(), "disk": wfields.IntegerField(), "disk_capacity": wfields.NonNegativeIntegerField(), "disk_gb_reserved": wfields.NonNegativeIntegerField(), - "disk_gb_used": wfields.NonNegativeIntegerField(), "vcpus": wfields.NonNegativeIntegerField(), - "vcpus_used": wfields.NonNegativeIntegerField(), "vcpu_reserved": wfields.NonNegativeIntegerField(), "memory_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 @property - def vcpus_capacity(self): + def vcpu_capacity(self): 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) class StorageNode(storage_resource.StorageResource): diff --git a/watcher/decision_engine/model/notification/nova.py b/watcher/decision_engine/model/notification/nova.py index 1109a9802..4871cb41d 100644 --- a/watcher/decision_engine/model/notification/nova.py +++ b/watcher/decision_engine/model/notification/nova.py @@ -165,23 +165,6 @@ class NovaNotification(base.NotificationEndpoint): disk_gb_reserved = 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. node_attributes = { # The id of the hypervisor as a UUID from version 2.53. @@ -190,7 +173,6 @@ class NovaNotification(base.NotificationEndpoint): "memory": memory_mb, "memory_ratio": memory_ratio, "memory_mb_reserved": memory_mb_reserved, - "memory_mb_used": memory_used, # 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 @@ -198,13 +180,11 @@ class NovaNotification(base.NotificationEndpoint): "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, "disk_ratio": disk_ratio, "vcpus": vcpus, "vcpu_reserved": vcpu_reserved, "vcpu_ratio": vcpu_ratio, - "vcpus_used": vcpus_used, "state": _node.state, "status": _node.status, "disabled_reason": _node.service["disabled_reason"]} diff --git a/watcher/tests/decision_engine/cluster/test_nova_cdmc.py b/watcher/tests/decision_engine/cluster/test_nova_cdmc.py index 131636e1f..1468fa308 100644 --- a/watcher/tests/decision_engine/cluster/test_nova_cdmc.py +++ b/watcher/tests/decision_engine/cluster/test_nova_cdmc.py @@ -154,18 +154,12 @@ class TestNovaClusterDataModelCollector(base.TestCase): memory_total = (node.memory-node.memory_mb_reserved)*node.memory_ratio 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 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 - self.assertEqual(node.vcpus_capacity, vcpus_total) - vcpus_free = vcpus_total - node.vcpus_used - self.assertEqual(node.vcpus_free, vcpus_free) + self.assertEqual(node.vcpu_capacity, vcpus_total) m_nova_helper.get_compute_node_by_name.assert_called_once_with( minimal_node['hypervisor_hostname'], servers=True, detailed=True)