1 from sfa.util.rspec import Rspec
2 from sfa.rspecs.aggregates.vini.utils import *
5 SFA_VINI_DEFAULT_RSPEC = '/etc/sfa/vini.rspec'
7 class ViniRspec(Rspec):
10 self.parseFile(SFA_VINI_DEFAULT_RSPEC)
12 def updateCapacity(self, sites, nodes):
22 for node in site.get_sitenodes(nodes):
26 ndict['hostname'] = [node.hostname]
27 ndict['name'] = node.tag
28 ndict['bw'] = ['999Mbit']
29 nodespecs.append(ndict)
30 sdict['NodeSpec'] = nodespecs
31 sdict['name'] = site.name
32 sitespecs.append(sdict)
34 for sl in site.sitelinks:
37 sldict['endpoint'] = [sl.site1.name, sl.site2.name]
38 sldict['bw'] = [str(sl.availMbps) + "Mbit"]
39 sitelinkspecs.append(sldict)
41 d['Rspec']['Capacity'][0]['NetSpec'][0]['SiteSpec'] = sitespecs
42 d['Rspec']['Capacity'][0]['NetSpec'][0]['SiteLinkSpec'] = sitelinkspecs
46 def updateRequest(self, slice, nodes, tags):
48 for node in slice.get_nodes(nodes):
49 linktag = slice.get_tag('topo_rspec', tags, node)
51 l = eval(linktag.value)
52 for (id, realip, bw, lvip, rvip, vnet) in l:
53 endpoints.append((node.id, id, bw))
57 for (l, r, bw) in endpoints:
58 if (r, l, bw) in endpoints:
61 edict['endpoint'] = [nodes[l].tag, nodes[r].tag]
63 linkspecs.append(edict)
66 d['Rspec']['Request'][0]['NetSpec'][0]['LinkSpec'] = linkspecs
67 d['Rspec']['Request'][0]['NetSpec'][0]['name'] = slice.hrn