Changes between Version 4 and Version 5 of TopDl
- Timestamp:
- Oct 4, 2012 5:50:20 PM (12 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
TopDl
v4 v5 73 73 74 74 }}} 75 76 That file is [attachment:two.xml attached] to this page. 75 77 76 78 === Substrates === … … 237 239 The topdl library is a set of python classes and function s that are [TopdlLibrary fully documented elsewhere]. This section gives a few examples that gives the feel for the library. Each entity is represented by a class with attributes named and broken down as described above. There are routines to import and export topologies in topdl as well as to translate between several formats, including ns2 and GENI Rspecs. 238 240 239 The following python generates the example topdl above:241 The following python prints the example topdl above: 240 242 241 243 {{{ … … 278 280 }}} 279 281 280 282 There are also routines for changing existing topologies. The following example numbers the computers in a topology by adding a "computer_number" attribute to them and prints the topology in topdl. 283 284 {{{ 285 #!/usr/bin/env python 286 287 import sys 288 from deter import topdl 289 290 if len(sys.argv) < 2: 291 sys.exit('Usage: %s topdl_file' % sys.argv[0]) 292 293 top = topdl.topology_from_xml(filename=sys.argv[1], top='experiment') 294 295 for i, e in enumerate(top.elements): 296 if not isinstance(e, topdl.Computer): continue 297 e.set_attribute('computer_number', '%s' % i) 298 299 300 print topdl.topology_to_xml(top, top='experiment') 301 302 }}} 303