Changes between Version 1 and Version 2 of TopdlLibrary


Ignore:
Timestamp:
Oct 5, 2012 10:48:22 AM (12 years ago)
Author:
faber
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TopdlLibrary

    v1 v2  
    1818from deter import topdl
    1919}}}
     20
     21== The Classes ==
     22
     23The class hierarchy mirrors the entities of the [TopDl topdl model].  Where the description of the model glosses over the details of the classes that parameterize the top-level abstractions, this reference will discuss them all.  Each of these classes is a python class, and can be created and manipulated independently, but in a proper topology they are grouped together.
     24
     25A Substrate object has members that are Capacity and Latency objects.  This listing shows that nesting:
     26
     27 * Substrate
     28   * Capacity (0 or 1)
     29   * Latency (0 or 1)
     30   * Attribute (0 or more)
     31
     32The other common element, a Computer object, has the following nested objects:
     33
     34 * [TopdlLibrary#ComputerClass Computer]
     35  * CPU (0 or more)
     36    * Attribute (0 or more)
     37  * !OperatingSystem (0 or more)
     38    * Attribute
     39  * Software (0 or more)
     40    * Attribute (0 or more)
     41  * Storage
     42    * Attribute
     43  * Interface (0 or more)
     44    * Capacity (0 or 1)
     45    * Latency (0 or 1)
     46    * Attribute (0 or more)
     47  * Service (0 or more)
     48    * !ServiceParam (0 or more)
     49
     50Most classes can have attributes attached to them that contain extention attributes that different applications make use of.  The presence or absence of an optional nested object does not mean the presence or absence of the thing it describes, but that the description is unbound.  As [TopDl#Representation we have seen] a Computer without a nested CPU object does not describe a computer without a CPU, but a computer with no constraints on the CPU.
     51 
     52== Adaptive Constructors ==
     53
     54The constructors of the various topdl classes will accept contained classes in several formats.  They will always accept an object of the relevant class.  They will also take a dict that maps constructor parameters to values for the given class.  Examples make this clearer than description.
     55
     56The following calls to create a CPU object are equivalent:
     57
     58{{{
     59cpu = topdl.CPU(type='Intel', attribute=[topdl.Attribute(attribute='clock_rate', value='1Ghz')])
     60}}}
     61
     62and
     63
     64{{{
     65cpu = topdl.CPU(type='Intel', attribute=[{'attribute': 'clock_rate', 'value': '1Ghz'}])
     66}}}
     67
     68
     69and
     70
     71{{{
     72cpu = topdl.CPU(**{'type': 'Intel', 'attribute' : [ {'attribute': 'clock_rate', 'value': '1Ghz'}]})
     73}}}
     74
     75That is, inner class parameters can be specified using dicts directly, and a top level dict can user the standard ** operator.
     76
     77
     78== Computer Class ==
     79
     80A Computer object is a programmable computer in a topology.  A webserver is well represented by a computer, as is a desktop. 
     81
     82
     83= Examples =
     84
     85
     86