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):
8 def __init__(self, xml = None, xsd = None, NSURL = None):
9 RSpec.__init__(self, xml, xsd, NSURL)
11 self.parseFile(SFA_VINI_DEFAULT_RSPEC)
13 def updateCapacity(self, topo):
17 for site in topo.getSites():
22 for node in site.get_sitenodes(topo.nodes):
26 ndict['hostname'] = [node.hostname]
27 ndict['name'] = node.tag
28 ndict['bw'] = [format_tc_rate(node.bps)]
29 nodespecs.append(ndict)
30 sdict['NodeSpec'] = nodespecs
31 sdict['name'] = site.name
32 sitespecs.append(sdict)
37 sldict['endpoint'] = [sl.end1.name, sl.end2.name]
38 sldict['bw'] = [format_tc_rate(sl.bps)]
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, topo):
48 for link in topo.nodelinks:
50 edict['endpoint'] = [link.end1.tag, link.end2.tag]
51 edict['bw'] = [format_tc_rate(link.bps)]
52 linkspecs.append(edict)
55 d['RSpec']['Request'][0]['NetSpec'][0]['LinkSpec'] = linkspecs
56 d['RSpec']['Request'][0]['NetSpec'][0]['name'] = slice.hrn