= Topdl Library = This page describes the python library for manipulating topologies that follow the [TopDl topdl] model and are generally output in the topdl language. It is broken up into a reference section describing the various python classes and procedures and an examples section. = Reference = == Installing and Accessing == The topdl library is available as oart of the DETER module of the DETER federation system. Any system that has fedd installed will have topdl installed as well. In particular, {{{users.isi.deterlab.net}}} has the library installed. To install the library separately, follow the [FeddDownload#GitAccess instructions for getting fedd from git], make the distribution, and install the {{{deter-data-}}}''version''{{{.tar.gz}}} tar file using the [FeddDownload#DownloadingandInstallingthetarfile same procedure for installing the fedd tar file]. Installing all of fedd will work as well, of course. Once the library is installed, python programs can access it by: {{{ #!/usr/bin/env python from deter import topdl }}} == The Classes == The 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. A Substrate object has members that are Capacity and Latency objects. This listing shows that nesting: * Substrate * Capacity (0 or 1) * Latency (0 or 1) * Attribute (0 or more) The other common element, a Computer object, has the following nested objects: * [TopdlLibrary#ComputerClass Computer] * CPU (0 or more) * Attribute (0 or more) * !OperatingSystem (0 or more) * Attribute * Software (0 or more) * Attribute (0 or more) * Storage * Attribute * Interface (0 or more) * Capacity (0 or 1) * Latency (0 or 1) * Attribute (0 or more) * Service (0 or more) * !ServiceParam (0 or more) Most 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. == Adaptive Constructors == The 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. The following calls to create a CPU object are equivalent: {{{ cpu = topdl.CPU(type='Intel', attribute=[topdl.Attribute(attribute='clock_rate', value='1Ghz')]) }}} and {{{ cpu = topdl.CPU(type='Intel', attribute=[{'attribute': 'clock_rate', 'value': '1Ghz'}]) }}} and {{{ cpu = topdl.CPU(**{'type': 'Intel', 'attribute' : [ {'attribute': 'clock_rate', 'value': '1Ghz'}]}) }}} That is, inner class parameters can be specified using dicts directly, and a top level dict can user the standard ** operator. == Computer Class == A Computer object is a programmable computer in a topology. A webserver is well represented by a computer, as is a desktop. = Examples =