Merge "Fix damodel list return None error When has a compute node"
This commit is contained in:
commit
d13adb4e3c
|
@ -257,6 +257,10 @@ class ModelRoot(nx.DiGraph, base.Model):
|
|||
new_name = "node_"+str(field)
|
||||
in_dict[new_name] = cn[field]
|
||||
node_instances = self.get_node_instances(cn)
|
||||
if not node_instances:
|
||||
deep_in_dict = in_dict.copy()
|
||||
ret_list.append(deep_in_dict)
|
||||
continue
|
||||
for instance in sorted(node_instances, key=lambda x: x.uuid):
|
||||
for field in instance.fields:
|
||||
new_name = "server_"+str(field)
|
||||
|
|
|
@ -85,6 +85,17 @@ class TestModel(base.TestCase):
|
|||
result_keys = result[0].keys()
|
||||
self.assertEqual(sorted(expected_keys), sorted(result_keys))
|
||||
|
||||
# test compute node has no instance
|
||||
mock_instances.return_value = []
|
||||
|
||||
expected_keys = ['node_uuid']
|
||||
|
||||
result = model_root.ModelRoot().to_list()
|
||||
self.assertEqual(1, len(result))
|
||||
|
||||
result_keys = result[0].keys()
|
||||
self.assertEqual(expected_keys, list(result_keys))
|
||||
|
||||
def test_get_node_by_instance_uuid(self):
|
||||
model = model_root.ModelRoot()
|
||||
uuid_ = "{0}".format(uuidutils.generate_uuid())
|
||||
|
|
Loading…
Reference in New Issue