Merge "Add get_node_by_name"
This commit is contained in:
@@ -149,6 +149,19 @@ class ModelRoot(nx.DiGraph, base.Model):
|
||||
except exception.ComputeResourceNotFound:
|
||||
raise exception.ComputeNodeNotFound(name=uuid)
|
||||
|
||||
@lockutils.synchronized("model_root")
|
||||
def get_node_by_name(self, name):
|
||||
try:
|
||||
node_list = [cn['attr'] for uuid, cn in self.nodes(data=True)
|
||||
if (isinstance(cn['attr'], element.ComputeNode) and
|
||||
cn['attr']['hostname'] == name)]
|
||||
if node_list:
|
||||
return node_list[0]
|
||||
else:
|
||||
raise exception.ComputeResourceNotFound
|
||||
except exception.ComputeResourceNotFound:
|
||||
raise exception.ComputeNodeNotFound(name=name)
|
||||
|
||||
@lockutils.synchronized("model_root")
|
||||
def get_instance_by_uuid(self, uuid):
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user