Changeset d46b1d5
- Timestamp:
- Mar 12, 2010 2:34:01 AM (15 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master, version-3.01, version-3.02
- Children:
- 1cf8e2c
- Parents:
- 35a4c01
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/federation/topdl.py
r35a4c01 rd46b1d5 641 641 add = True 642 642 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])) 644 644 return s 645 645 return rv … … 651 651 gw = e.get_attribute('portal') 652 652 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) 654 654 return s 655 655 return rv … … 661 661 gw = e.get_attribute('portal') 662 662 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) 664 664 return s 665 665 return rv 666 666 667 667 668 def topology_to_ns2(t, filters=[], routing=" Session"):668 def topology_to_ns2(t, filters=[], routing="Manual"): 669 669 out = """ 670 670 set ns [new Simulator] … … 682 682 osid = e.os[0].get_attribute('osid') 683 683 if osid: 684 out += "tb-set-node-os $ %s%s\n" % (name, osid)684 out += "tb-set-node-os ${%s} %s\n" % (name, osid) 685 685 hw = e.get_attribute('type') 686 686 if hw: 687 out += "tb-set-hardware $ %s%s\n" % (name, hw)687 out += "tb-set-hardware ${%s} %s\n" % (name, hw) 688 688 for s in e.software: 689 689 if s.install: … … 692 692 rpms += "%s " % s.location 693 693 if rpms: 694 out += "tb-set-node-rpms $ %s%s\n" % (name, rpms)694 out += "tb-set-node-rpms ${%s} %s\n" % (name, rpms) 695 695 if tarfiles: 696 out += "tb-set-node-tarfiles $ %s%s\n" % (name, tarfiles)696 out += "tb-set-node-tarfiles ${%s} %s\n" % (name, tarfiles) 697 697 startcmd = e.get_attribute('startup') 698 698 if startcmd: 699 out+= 'tb-set-node-startcmd $ %s"%s"\n' % (name, startcmd)699 out+= 'tb-set-node-startcmd ${%s} "%s"\n' % (name, startcmd) 700 700 for f in filters: 701 701 out += f(e) … … 712 712 if len(s.interfaces) > 2: 713 713 # Lan 714 members = [ to_tcl_name("$ %s") % i.element.name[0] \714 members = [ to_tcl_name("${%s}") % i.element.name[0] \ 715 715 for i in s.interfaces] 716 716 out += 'set %s [$ns make-lan "%s" %fkb %fms ]\n' % \ 717 717 (name, " ".join(members), s.capacity.rate, delay) 718 718 if loss: 719 "tb-set-lan-loss $ %s%f\n" % (name, float(loss))719 "tb-set-lan-loss ${%s} %f\n" % (name, float(loss)) 720 720 721 721 for i in s.interfaces: … … 723 723 ip = i.get_attribute("ip4_address") 724 724 if ip: 725 out += "tb-set-ip-lan $ %s $%s%s\n" % \725 out += "tb-set-ip-lan ${%s} ${%s} %s\n" % \ 726 726 (to_tcl_name(e.name[0]), name, ip) 727 727 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" % \ 729 729 (to_tcl_name(e.name[0]), name, i.capacity.rate) 730 730 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" % \ 732 732 (to_tcl_name(e.name[0]), name, i.latency.time) 733 733 iloss = i.get_attribute('loss') 734 734 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" % \ 736 736 (to_tcl_name(e.name[0]), name, float(loss)) 737 737 out+= "\n" … … 740 740 t = s.interfaces[1] 741 741 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" %\ 743 743 (name, to_tcl_name(f.element.name[0]), 744 744 to_tcl_name(t.element.name[0]), 745 745 s.capacity.rate, delay) 746 746 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)) 748 748 749 749 for i in s.interfaces: … … 763 763 else: loss = loss or 0.0 764 764 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"\ 766 766 % (name, to_tcl_name(i.element.name[0]), 767 767 delay, cap, loss) 768 768 ip = i.get_attribute('ip4_address') 769 769 if ip: 770 out += "tb-set-ip-link $ %s $%s%s\n" % \770 out += "tb-set-ip-link ${%s} ${%s} %s\n" % \ 771 771 (to_tcl_name(i.element.name[0]), name, ip) 772 772 out+= "\n"
Note: See TracChangeset
for help on using the changeset viewer.