git://git.onelab.eu
/
sfa.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
0c0bf2e
)
Added free_egre_key()
author
Andy Bavier
<acb@cs.princeton.edu>
Wed, 10 Feb 2010 18:01:49 +0000
(18:01 +0000)
committer
Andy Bavier
<acb@cs.princeton.edu>
Wed, 10 Feb 2010 18:01:49 +0000
(18:01 +0000)
sfa/managers/vini/vini_network.py
patch
|
blob
|
history
diff --git
a/sfa/managers/vini/vini_network.py
b/sfa/managers/vini/vini_network.py
index
06f135d
..
5ccf57c
100644
(file)
--- a/
sfa/managers/vini/vini_network.py
+++ b/
sfa/managers/vini/vini_network.py
@@
-157,10
+157,9
@@
class ViniSlice(Slice):
tag = self.get_tag('egre_key')
if not tag:
try:
tag = self.get_tag('egre_key')
if not tag:
try:
- key = free_egre_key()
+ key =
self.network.
free_egre_key()
except:
except:
- # Should handle this case...
- raise Error("ran out of EGRE keys!")
+ raise InvalidRSpec("ran out of EGRE keys!")
tag = self.update_tag('egre_key', key, None, 10)
return
tag = self.update_tag('egre_key', key, None, 10)
return
@@
-393,6
+392,24
@@
class ViniNetwork(Network):
Network.updateSliceTags(self)
Network.updateSliceTags(self)
+ """
+ Find a free EGRE key
+ """
+ def free_egre_key(self):
+ used = set()
+ for tag in self.getSliceTags():
+ if tag.tagname == 'egre_key':
+ used.add(int(tag.value))
+
+ for i in range(1, 256):
+ if i not in used:
+ key = i
+ break
+ else:
+ raise KeyError("No more EGRE keys available")
+
+ return str(key)
+
"""
Produce XML directly from the topology specification.
"""
"""
Produce XML directly from the topology specification.
"""