예제 #1
0
파일: execute.py 프로젝트: nfvproject/nepi
 def genreqs(node, filter_slice_id=None):
     # Try existing nodes first
     # If we have only one candidate, simply use it
     candidates = node.find_candidates(
         filter_slice_id = filter_slice_id)
     for r in reserved:
         if candidates.has_key(r):
             del candidates[r]
     reqs.append(candidates.values())
     nodes.append(node)
예제 #2
0
파일: execute.py 프로젝트: nfvproject/nepi
 def assignifunique(guid, node):
     # Try existing nodes first
     # If we have only one candidate, simply use it
     candidates = node.find_candidates(
         filter_slice_id = self.slice_id)
     
     node_id = None
     candidate_hosts = set(candidates.keys() if candidates else [])
     reserve_lock.acquire()
     try:
         candidate_hosts -= reserved
         if len(candidate_hosts) == 1:
             hostname = iter(candidate_hosts).next()
             node_id = candidates[hostname]
             reserved.add(hostname)
         elif not candidate_hosts:
             # Try again including unassigned nodes
             reserve_lock.release()
             try:
                 candidates = node.find_candidates()
             finally:
                 reserve_lock.acquire()
             candidate_hosts = set(candidates.keys() if candidates else [])
             candidate_hosts -= reserved
             if len(candidate_hosts) > 1:
                 return
             if len(candidate_hosts) == 1:
                 hostname = iter(candidate_hosts).next()
                 node_id = candidates[hostname]
                 to_provision.add(node_id)
                 reserved.add(hostname)
             elif not candidates:
                 raise RuntimeError, "Cannot assign resources for node %s, no candidates with %s" % (guid,
                     node.make_filter_description())
     finally:
         reserve_lock.release()
    
     if node_id is not None:
         node.assign_node_id(node_id)