Commit 5ba9701d authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

cmdlib: Use common function to list instances on node



This will be used by another new function, too.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 2d9005d8
......@@ -711,30 +711,24 @@ def _CheckInstanceBridgesExist(lu, instance, node=None):
_CheckNicsBridgesExist(lu, instance.nics, node)
def _GetNodeInstancesInner(cfg, fn):
return [i for i in cfg.GetAllInstancesInfo().values() if fn(i)]
def _GetNodePrimaryInstances(cfg, node_name):
"""Returns primary instances on a node.
"""
instances = []
for (_, inst) in cfg.GetAllInstancesInfo().iteritems():
if node_name == inst.primary_node:
instances.append(inst)
return instances
return _GetNodeInstancesInner(cfg,
lambda inst: node_name == inst.primary_node)
def _GetNodeSecondaryInstances(cfg, node_name):
"""Returns secondary instances on a node.
"""
instances = []
for (_, inst) in cfg.GetAllInstancesInfo().iteritems():
if node_name in inst.secondary_nodes:
instances.append(inst)
return instances
return _GetNodeInstancesInner(cfg,
lambda inst: node_name in inst.secondary_nodes)
def _GetStorageTypeArgs(cfg, storage_type):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment