git://git.onelab.eu
/
nodemanager-topo.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
40d88bf
)
Generate 'hosts' attribute for the slice
author
Andy Bavier
<acb@cs.princeton.edu>
Wed, 25 Feb 2009 16:55:30 +0000
(16:55 +0000)
committer
Andy Bavier
<acb@cs.princeton.edu>
Wed, 25 Feb 2009 16:55:30 +0000
(16:55 +0000)
create-topo-attributes.py
patch
|
blob
|
history
diff --git
a/create-topo-attributes.py
b/create-topo-attributes.py
index
6d64d99
..
8f26ff8
100755
(executable)
--- a/
create-topo-attributes.py
+++ b/
create-topo-attributes.py
@@
-67,6
+67,18
@@
def get_sitenodes(siteid):
raise Exception("Siteid %s not found." % siteid)
raise Exception("Siteid %s not found." % siteid)
+"""
+Find the IP address assigned to a virtual interface in the topology
+(for creating /etc/hosts)
+"""
+def get_virt_ip(myid, nodeid):
+ if myid < nodeid:
+ virtip = "10.%d.%d.2" % (myid, nodeid)
+ else:
+ virtip = "10.%d.%d.3" % (nodeid, myid)
+ return virtip
+
+
"""
Create a dictionary of site records keyed by site ID
"""
"""
Create a dictionary of site records keyed by site ID
"""
@@
-97,16
+109,17
@@
nodes = get_nodes()
for slice in GetSlices():
""" Create dictionary of the slice's attributes """
for slice in GetSlices():
""" Create dictionary of the slice's attributes """
- attrs =
[]
+ attrs =
{}
topo_attr = {}
for attribute in GetSliceAttributes(slice['slice_attribute_ids']):
topo_attr = {}
for attribute in GetSliceAttributes(slice['slice_attribute_ids']):
- attrs
.append(attribute['name'])
+ attrs
[attribute['name']] = attribute['slice_attribute_id']
if attribute['name'] == 'topo_rspec' and attribute['node_id']:
topo_attr[attribute['node_id']] = attribute['slice_attribute_id']
if 'egre_key' in attrs:
if attribute['name'] == 'topo_rspec' and attribute['node_id']:
topo_attr[attribute['node_id']] = attribute['slice_attribute_id']
if 'egre_key' in attrs:
- print "Virtual topology for %s:" % slice['name']
+
#
print "Virtual topology for %s:" % slice['name']
slicenodes = set(slice['node_ids'])
slicenodes = set(slice['node_ids'])
+ hosts = "127.0.0.1\t\tlocalhost\n"
"""
For each node in the slice, check whether nodes at adjacent sites
are also in the slice's node set. If so, add a virtual link to
"""
For each node in the slice, check whether nodes at adjacent sites
are also in the slice's node set. If so, add a virtual link to
@@
-119,8
+132,11
@@
for slice in GetSlices():
if node != adj_node and adj_node in slicenodes:
link = adj_node, get_ipaddr(adj_node), "1Mbit"
topo.append(link)
if node != adj_node and adj_node in slicenodes:
link = adj_node, get_ipaddr(adj_node), "1Mbit"
topo.append(link)
+ shortname = nodes[node]['hostname'].replace('.vini-veritas.net', '')
+ hosts += "%s\t\t%s\n" % (get_virt_ip(node, adj_node),
+ shortname)
topo_str = "%s" % topo
topo_str = "%s" % topo
- print node, topo_str
+
#
print node, topo_str
if node in topo_attr:
UpdateSliceAttribute(topo_attr[node], topo_str)
del topo_attr[node]
if node in topo_attr:
UpdateSliceAttribute(topo_attr[node], topo_str)
del topo_attr[node]
@@
-128,10
+144,17
@@
for slice in GetSlices():
id = slice['slice_id']
AddSliceAttribute(id, 'topo_rspec', topo_str, node)
id = slice['slice_id']
AddSliceAttribute(id, 'topo_rspec', topo_str, node)
- else:
- print "No EGRE key for %s" % slice['name']
+ #print hosts
+ if 'hosts' in attrs:
+ UpdateSliceAttribute(attrs['hosts'], hosts)
+ else:
+ id = slice['slice_id']
+ AddSliceAttribute(id, 'hosts', hosts)
+ #else:
+ #print "No EGRE key for %s" % slice['name']
""" Remove old topo_rspec entries """
for node in topo_attr:
DeleteSliceAttribute(topo_attr[node])
""" Remove old topo_rspec entries """
for node in topo_attr:
DeleteSliceAttribute(topo_attr[node])
+