Fixed missing attribute in the data model

Querying compute.node.* with Ceilometer requires some additional
information in the cluster data model in order to build the
resource_id. This patchset add the attribute hostname and change
the query.

Change-Id: Ifcefcd70a6d0f5967ab4f638ce077e38ef214f64
Closes-Bug: #1521559
This commit is contained in:
Jean-Emile DARTOIS
2015-12-01 12:21:47 +01:00
parent ee82531314
commit da4c9125f7
8 changed files with 44 additions and 19 deletions

View File

@@ -58,8 +58,11 @@ class FakerModelCollector(BaseClusterModelCollector):
for i in range(0, count_node):
node_uuid = "Node_{0}".format(i)
hypervisor = Hypervisor()
hypervisor.uuid = node_uuid
hypervisor.hostname = "host_{0}".format(i)
mem.set_capacity(hypervisor, 132)
disk.set_capacity(hypervisor, 250)
num_cores.set_capacity(hypervisor, 40)
@@ -111,6 +114,7 @@ class FakerModelCollector(BaseClusterModelCollector):
node_uuid = "Node_{0}".format(i)
node = Hypervisor()
node.uuid = node_uuid
node.hostname = "hostname_{0}".format(i)
mem.set_capacity(node, 132)
disk.set_capacity(node, 250)
@@ -182,6 +186,7 @@ class FakerModelCollector(BaseClusterModelCollector):
node_uuid = "Node_{0}".format(i)
node = Hypervisor()
node.uuid = node_uuid
node.hostname = "hostname_{0}".format(i)
mem.set_capacity(node, 132)
disk.set_capacity(node, 250)
num_cores.set_capacity(node, 40)
@@ -219,6 +224,8 @@ class FakerModelCollector(BaseClusterModelCollector):
node_uuid = "Node_{0}".format(i)
node = Hypervisor()
node.uuid = node_uuid
node.hostname = "hostname_{0}".format(i)
mem.set_capacity(node, 132)
disk.set_capacity(node, 250)
num_cores.set_capacity(node, 40)
@@ -281,6 +288,7 @@ class FakerModelCollector(BaseClusterModelCollector):
node_uuid = "Node_{0}".format(i)
node = Hypervisor()
node.uuid = node_uuid
node.hostname = "hostname_{0}".format(i)
mem.set_capacity(node, 132)
disk.set_capacity(node, 250)
@@ -328,6 +336,7 @@ class FakerModelCollector(BaseClusterModelCollector):
node_uuid = "Node_{0}".format(i)
node = Hypervisor()
node.uuid = node_uuid
node.hostname = "hostname_{0}".format(i)
mem.set_capacity(node, 1)
disk.set_capacity(node, 1)
@@ -359,6 +368,7 @@ class FakerModelCollector(BaseClusterModelCollector):
node_uuid = "Node_" + str(i)
node = Hypervisor()
node.uuid = node_uuid
node.hostname = "hostname_{0}".format(i)
mem.set_capacity(node, 4)
disk.set_capacity(node, 4)

View File

@@ -49,20 +49,20 @@ class FakerMetricsCollector(object):
# Normalize
mock = {}
# node 0
mock['Node_0'] = 7
mock['Node_1'] = 7
mock['Node_0_hostname_0'] = 7
mock['Node_1_hostname_1'] = 7
# node 1
mock['Node_2'] = 80
mock['Node_2_hostname_2'] = 80
# node 2
mock['Node_3'] = 5
mock['Node_4'] = 5
mock['Node_5'] = 10
mock['Node_3_hostname_3'] = 5
mock['Node_4_hostname_4'] = 5
mock['Node_5_hostname_5'] = 10
# node 3
mock['Node_6'] = 8
mock['Node_19'] = 10
mock['Node_6_hostname_6'] = 8
mock['Node_19_hostname_19'] = 10
# node 4
mock['VM_7'] = 4
mock['VM_7_hostname_7'] = 4
if uuid not in mock.keys():
# mock[uuid] = random.randint(1, 4)

View File

@@ -16,17 +16,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
from watcher.decision_engine.model.named_element import NamedElement
from watcher.decision_engine.model.compute_resource import ComputeResource
from watcher.tests import base
class TestNamedElement(base.BaseTestCase):
def test_namedelement(self):
id = NamedElement()
id = ComputeResource()
id.uuid = "BLABLABLA"
self.assertEqual(id.uuid, "BLABLABLA")
def test_set_get_human_id(self):
id = NamedElement()
id = ComputeResource()
id.human_id = "BLABLABLA"
self.assertEqual(id.human_id, "BLABLABLA")