- # Request OK
-
- nodes = rspec_to_nodeset(rspec)
- create_slice_vini_aggregate(api, hrn, nodes)
-
- # Add VINI-specific topology attributes to slice here
- try:
- linkspecs = rspec['Rspec']['Request'][0]['NetSpec'][0]['LinkSpec']
- if linkspecs:
- slicename = hrn_to_pl_slicename(hrn)
-
- # Grab all the PLC info we'll need at once
- slice = get_slice(api, slicename)
- if slice:
- nodes = get_nodes(api)
- tags = get_slice_tags(api)
-
- slice.update_tag('vini_topo', 'manual', tags)
- slice.assign_egre_key(tags)
- slice.turn_on_netns(tags)
- slice.add_cap_net_admin(tags)
-
- nodedict = {}
- for (k, v) in get_nodedict(rspec).iteritems():
- for id in nodes:
- if v == nodes[id].hostname:
- nodedict[k] = nodes[id]
-
- for l in linkspecs:
- n1 = nodedict[l['endpoint'][0]]
- n2 = nodedict[l['endpoint'][1]]
- bw = l['bw'][0]
- n1.add_link(n2, bw)
- n2.add_link(n1, bw)
-
- for node in slice.get_nodes(nodes):
- if node.links:
- topo_str = "%s" % node.links
- slice.update_tag('topo_rspec', topo_str, tags, node)
-
- # Update slice tags in database
- for i in tags:
- tag = tags[i]
- if tag.slice_id == slice.id:
- if tag.tagname == 'topo_rspec' and not tag.updated:
- tag.delete()
- tag.write(api)
- except KeyError:
- # Bad Rspec
- pass