Changeset d46b1d5 for fedd/federation


Ignore:
Timestamp:
Mar 12, 2010 2:34:01 AM (15 years ago)
Author:
Ted Faber <faber@…>
Branches:
axis_example, compt_changes, info-ops, master, version-3.01, version-3.02
Children:
1cf8e2c
Parents:
35a4c01
Message:

Bracked all tcl names so that names with a dash (and other atrocities) will
work. Also switch to manual routing by default in tcl/ns2 output.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedd/federation/topdl.py

    r35a4c01 rd46b1d5  
    641641                add = True
    642642            if gw and add:
    643                 s = "%s $%s\n" % (cmd, to_tcl_name(e.name[0]))
     643                s = "%s ${%s}\n" % (cmd, to_tcl_name(e.name[0]))
    644644        return s
    645645    return rv
     
    651651            gw = e.get_attribute('portal')
    652652            if gw:
    653                 s = "tb-set-node-os $%s %s\n" % (to_tcl_name(e.name[0]), image)
     653                s = "tb-set-node-os ${%s} %s\n" % (to_tcl_name(e.name[0]), image)
    654654        return s
    655655    return rv
     
    661661            gw = e.get_attribute('portal')
    662662            if gw:
    663                 s = "tb-set-hardware $%s %s\n" % (to_tcl_name(e.name[0]), type)
     663                s = "tb-set-hardware ${%s} %s\n" % (to_tcl_name(e.name[0]), type)
    664664        return s
    665665    return rv
    666666
    667667
    668 def topology_to_ns2(t, filters=[], routing="Session"):
     668def topology_to_ns2(t, filters=[], routing="Manual"):
    669669    out = """
    670670set ns [new Simulator]
     
    682682                osid = e.os[0].get_attribute('osid')
    683683                if osid:
    684                     out += "tb-set-node-os $%s %s\n" % (name, osid)
     684                    out += "tb-set-node-os ${%s} %s\n" % (name, osid)
    685685            hw = e.get_attribute('type')
    686686            if hw:
    687                 out += "tb-set-hardware $%s %s\n" % (name, hw)
     687                out += "tb-set-hardware ${%s} %s\n" % (name, hw)
    688688            for s in e.software:
    689689                if s.install:
     
    692692                    rpms += "%s " % s.location
    693693            if rpms:
    694                 out += "tb-set-node-rpms $%s %s\n" % (name, rpms)
     694                out += "tb-set-node-rpms ${%s} %s\n" % (name, rpms)
    695695            if tarfiles:
    696                 out += "tb-set-node-tarfiles $%s %s\n" % (name, tarfiles)
     696                out += "tb-set-node-tarfiles ${%s} %s\n" % (name, tarfiles)
    697697            startcmd = e.get_attribute('startup')
    698698            if startcmd:
    699                 out+= 'tb-set-node-startcmd $%s "%s"\n' % (name, startcmd)
     699                out+= 'tb-set-node-startcmd ${%s} "%s"\n' % (name, startcmd)
    700700            for f in filters:
    701701                out += f(e)
     
    712712        if len(s.interfaces) > 2:
    713713            # Lan
    714             members = [ to_tcl_name("$%s") % i.element.name[0] \
     714            members = [ to_tcl_name("${%s}") % i.element.name[0] \
    715715                    for i in s.interfaces]
    716716            out += 'set %s [$ns make-lan "%s" %fkb %fms ]\n' % \
    717717                    (name, " ".join(members), s.capacity.rate, delay)
    718718            if loss:
    719                 "tb-set-lan-loss $%s %f\n" % (name, float(loss))
     719                "tb-set-lan-loss ${%s} %f\n" % (name, float(loss))
    720720
    721721            for i in s.interfaces:
     
    723723                ip = i.get_attribute("ip4_address")
    724724                if ip:
    725                     out += "tb-set-ip-lan $%s $%s %s\n" % \
     725                    out += "tb-set-ip-lan ${%s} ${%s} %s\n" % \
    726726                            (to_tcl_name(e.name[0]), name, ip)
    727727                if i.capacity and i.capacity.rate != s.capacity.rate:
    728                     out += "tb-set-node-lan-bandwidth $%s $%s %fkb\n" % \
     728                    out += "tb-set-node-lan-bandwidth ${%s} ${%s} %fkb\n" % \
    729729                            (to_tcl_name(e.name[0]), name, i.capacity.rate)
    730730                if i.latency and i.latency.time != delay:
    731                     out += "tb-set-node-lan-delay $%s $%s %fms\n" % \
     731                    out += "tb-set-node-lan-delay ${%s} ${%s} %fms\n" % \
    732732                            (to_tcl_name(e.name[0]), name, i.latency.time)
    733733                iloss = i.get_attribute('loss')
    734734                if loss and iloss != loss :
    735                     out += "tb-set-node-lan-loss $%s $%s %f\n" % \
     735                    out += "tb-set-node-lan-loss ${%s} ${%s} %f\n" % \
    736736                            (to_tcl_name(e.name[0]), name, float(loss))
    737737            out+= "\n"
     
    740740            t = s.interfaces[1]
    741741
    742             out += "set %s [$ns duplex-link $%s $%s %fkb %fms DropTail]\n" %\
     742            out += "set %s [$ns duplex-link ${%s} ${%s} %fkb %fms DropTail]\n" %\
    743743                    (name, to_tcl_name(f.element.name[0]),
    744744                            to_tcl_name(t.element.name[0]),
    745745                            s.capacity.rate, delay)
    746746            if loss:
    747                 out += "tb-set-link-loss $%s %f\n" % (name, float(loss))
     747                out += "tb-set-link-loss ${%s} %f\n" % (name, float(loss))
    748748
    749749            for i in s.interfaces:
     
    763763                    else: loss = loss or 0.0
    764764
    765                     out += "tb-set-link-simplex-params $%s $%s %fms %fkb %f\n"\
     765                    out += "tb-set-link-simplex-params ${%s} ${%s} %fms %fkb %f\n"\
    766766                            % (name, to_tcl_name(i.element.name[0]),
    767767                                    delay, cap, loss)
    768768                ip = i.get_attribute('ip4_address')
    769769                if ip:
    770                     out += "tb-set-ip-link $%s $%s %s\n" % \
     770                    out += "tb-set-ip-link ${%s} ${%s} %s\n" % \
    771771                            (to_tcl_name(i.element.name[0]), name, ip)
    772772            out+= "\n"
Note: See TracChangeset for help on using the changeset viewer.