scheduler.py 335 Bytes
Newer Older
1 2
def get_node(instance, nodes):
    ''' Select a node for hosting an instance based on its requirements.
tarokkk committed
3 4 5
    '''
    # Return first Node or None
    try:
6 7
        req_traits = set(instance.req_traits.all())
        nodes = [n for n in nodes if req_traits.issubset(n.traits.all())]
8
        return nodes[0]
tarokkk committed
9 10
    except:
        return None