-for slice in GetSlices():
- """ Create dictionary of the slice's attributes """
- attrs ={}
- topo_attr = {}
- for attribute in GetSliceAttributes(slice['slice_attribute_ids']):
- 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:
- #print "Virtual topology for %s:" % slice['name']
- 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
- the rspec.
- """
- for node in slicenodes:
- topo = []
- for adj in adjacencies[get_site(node)]:
- for adj_node in get_sitenodes(adj):
- 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
- #print node, topo_str
- if node in topo_attr:
- UpdateSliceAttribute(topo_attr[node], topo_str)
- del topo_attr[node]
+def main():
+
+ for slice in GetSlices():
+ """ Create dictionary of the slice's attributes """
+ attrs ={}
+ topo_attr = {}
+ for attribute in GetSliceAttributes(slice['slice_attribute_ids']):
+ 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:
+ #print "Virtual topology for %s:" % slice['name']
+ 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
+ the rspec.
+ """
+ for node in slicenodes:
+ topo = []
+ for adj in adjacencies[get_site(node)]:
+ for adj_node in get_sitenodes(adj):
+ 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
+ #print node, topo_str
+ if node in topo_attr:
+ UpdateSliceAttribute(topo_attr[node], topo_str)
+ del topo_attr[node]
+ else:
+ id = slice['slice_id']
+ AddSliceAttribute(id, 'topo_rspec', topo_str, node)
+
+ #print hosts
+ if 'hosts' in attrs:
+ UpdateSliceAttribute(attrs['hosts'], hosts)