X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Frspecs%2Faggregates%2Fvini%2Futils.py;h=94e64bf79c6d8d8b65838cc6ebc3910ba93cd84c;hb=cbfcd01963fd69149937551f9d225ec825554384;hp=57a010fddde7b8155676ebb46a1fdc81cf6a0987;hpb=c2c3a2a188ec988abbf64b0f701fea56a5bf213d;p=sfa.git diff --git a/sfa/rspecs/aggregates/vini/utils.py b/sfa/rspecs/aggregates/vini/utils.py index 57a010fd..94e64bf7 100644 --- a/sfa/rspecs/aggregates/vini/utils.py +++ b/sfa/rspecs/aggregates/vini/utils.py @@ -2,6 +2,68 @@ import re import socket from sfa.rspecs.aggregates.vini.topology import * +default_topo_xml = """ + + i2atla1 + i2chic1 + 1Mbit + + + i2atla1 + i2hous1 + 1Mbit + + + i2atla1 + i2wash1 + 1Mbit + + + i2chic1 + i2kans1 + 1Mbit + + + i2chic1 + i2wash1 + 1Mbit + + + i2hous1 + i2kans1 + 1Mbit + + + i2hous1 + i2losa1 + 1Mbit + + + i2kans1 + i2salt1 + 1Mbit + + + i2losa1 + i2salt1 + 1Mbit + + + i2losa1 + i2seat1 + 1Mbit + + + i2newy1 + i2wash1 + 1Mbit + + + i2salt1 + i2seat1 + 1Mbit + """ + # Taken from bwlimit.py # # See tc_util.c and http://physics.nist.gov/cuu/Units/binary.html. Be @@ -153,7 +215,7 @@ class Site: def __init__(self, site): self.id = site['site_id'] self.node_ids = site['node_ids'] - self.name = site['abbreviated_name'] + self.name = site['abbreviated_name'].replace(" ", "_") self.tag = site['login_base'] self.public = site['is_public'] self.links = set() @@ -460,6 +522,73 @@ class Topology: if tag.tagname == 'topo_rspec' and not tag.updated: tag.delete() tag.write(self.api) + + def toxml(self, hrn = None): + xml = """ + + + """ + + for site in self.getSites(): + if not site.public: + continue + + xml += """ + """ % site.name + + for node in site.get_sitenodes(self.nodes): + if not node.tag: + continue + + xml += """ + + %s + %s + """ % (node.tag, node.hostname, format_tc_rate(node.bps)) + xml += """ + """ + + for link in self.sitelinks: + xml += """ + + %s + %s + %s + """ % (link.end1.name, link.end2.name, format_tc_rate(link.bps)) + + + if hrn: + name = hrn + else: + name = 'default_topology' + xml += """ + + + + """ % name + + if hrn: + for link in self.nodelinks: + xml += """ + + %s + %s + %s + """ % (link.end1.tag, link.end2.tag, format_tc_rate(link.bps)) + else: + xml += default_topo_xml + + xml += """ + + +""" + + # Remove all leading whitespace and newlines + lines = xml.split("\n") + noblanks = "" + for line in lines: + noblanks += line.strip() + return noblanks """