About the CMT data(structure)

The datastructure of CMT consists of various models, defined in the source-file. Just like in other Django projects, these models are used as a blueprint for objects in CMT, and for database tables to store these objects in. There's an interactive shell, included in Django, which you can use for testing queries or looking up the models. This shell has to be executed with the which is a wrapper around Django's command-line utility and can be found in the CMT-package directory. If you are familiar with Django, you might use this shell. Otherwise we advise you to use one one of the interfaces of CMT.

user@host$ python shell

This will give you an interactive shell with a welcome message. First thing to do is import the models of sara_cmt:

In [1]: from sara_cmt.cluster.models import *

Example of a model

To give an impression of how a model looks like, here's an example:

class Room(ModelExtension):
  address = models.ForeignKey(Address, related_name='rooms')

  floor   = models.IntegerField(max_length=2)
  label   = models.CharField(max_length=30, blank=False)

  class Meta:
    unique_together = ('address', 'floor', 'label')
  def __unicode__(self):
    return unicode(floor)

This model the class for a Room-model. In this case a room has got 3 fields of different types:

  • An address, which is stored in the database as a foreign key to the Address-table.
  • A floor, which is stored as an integer of 2 digits max.
  • A label, to give the room a human readable name. This label stored as a string of at least 1 character, to 30 characters max.

Available models

The models available in CMT are:

Model Description Related to
Cluster A labeled group of hardware pieces
HardwareUnit A specific piece of hardware Cluster (n:1)
Role (n:n)
Network (n:n)
HardwareModel (n:1)
WarrantyContract (n:1)
Rack (n:1)
Connection (n:1)
Interface An interface of a piece of hardware Network (n:1)
HardwareUnit (n:1)
InterfaceType (n:1)
Network Information about a network. Interface (1:n)
Rack A standardized system for mounting various pieces of hardware in a stack of slots.
Country Countries paired with there country-code
Address Holds information about the physical location of a piece of hardware. Country (n:1)
Room Located at an address, this is where a rack of hardware can be found.
Company This can be linked to hardware, to be able to define contactpersons for a specific piece of hardware Address (n:n)
Connection These are contacts that can be linked as connections for warranties etc. Address (n:1)
Company (n:1)
Telephonenumber Used for telephonenumbers of contacts. Country (n:1)
Connection (n:1)
HardwareModel This model is being used to specify some extra information (specifications) about a specific type (model) of hardware Company (n:1)
Role Describes the role of a piece of hardware in the cluster.
InterfaceType Contains information about different types of interfaces Company (n:1)
WarrantyType A type of warranty offered by a company Connection (n:1)
WarrantyContract A class which contains warranty information of (a collection of) hardware. WarrantyType (n:1)


A labeled group of hardware units.

namestringhuman readable label of the cluster
machinenamesstringmachine names syntaxr{rack}n{first_slot}

required: name; unique: name


A specific kind of hardware.

clustermany-to-one relationshipcluster which this hardware is part of
rolemany-to-many relationshipthe role this hardware fulfills within the cluster
specificationsmany-to-one relationshiphardware specifications
warrantymany-to-one relationshipwarranty contract for this hardware
sellermany-to-one relationshipthe company which it's bought from
ownermany-to-one relationshipthe client/project which it's bought for
rackmany-to-one relationshiopthe rack this hardware is mounted in
first_slotintegerthe first slot this hardware occupies in its rack
statestring{new,clean,configured,unknown,off}, default: off (more)
warranty_tagstringservice tag or serialnumber
serial_numberstringserial number
labelstringlabel for the piece of hardware

required: cluster, role, rack; unique: rack+first_slot, cluster+label


An interface of a piece of hardware.

networkmany-to-one relationshipnetwork this interface is in
hostmany-to-one relationshippiece of hardware this interface is part of
iftypemany-to-one relationshiptype of interface
labelstringlabel for the interface
aliasesstringcomma-seperated list of CNAMEs
hwaddressstringMAC-address written with [0-9a-f:]

required: network, host, iftype, label; unique: network+ip, network+hwaddress


Holds information about a network.

namestringhuman readable label.
gatewayIP-addressgateway address. Automagically generated if kept empty.
hostnamesstringstringformat of hostnames in the networkib-{machine}

required: name, cidr, domain, hostnames; unique: -


A cabinet used for mounting hardware.

roommany-to-one relationshipthe room where this rack is located
labelstringlabel for the rackam91
capacityintegernumber of slots

required: room, label, capacity; unique: room+label


namestringname of the countryNetherlands
country_codeintegercountry code, according to E.164 standard31

required: name, country_code; unique: name, country_code


Information about the physical locations, which can be referred to from objects.

countrymany-to-one relationshipcountry of the address
postalcodestringpostal code

required: address, city; unique: address+city


A room is located at an address. This is where racks of hardware can be found.

addressmany-to-one relationshipaddress where the room is
floorintegerfloor of the room
labelstringlabel of the room

required: address, floor, label; unique: address+floor+label


Holds information about a company. This can be used to link (to) hardware and contacts.

addressesmany-to-many relationshipaddresses where a company is located
namestringname of the company
websiteURLURL of their website

required: addresses, name, website; unique: name


A contact can be a person, or (for example) a hotline for support.

addressmany-to-one relationshipaddress of the contact
companymany-to-one relationshipcompany of the contact
activebooleanwhether it's currently a contact or not
namestringfull name
emailemail addressemail address

required: company, name; unique: company+name


Telephonenumber to link to a contact. Split in country-, area- and subscriber-part for easy filtering.

countrymany-to-one relationshipcountry part of the telephone number
connectionmany-to-one relationshipowner of the telephone number
areacodecharfieldarea code part of the telephone number
subscriber_numberintegerfieldsubscriber part of the telephone number
number_typecharfield['T','C','F'], for telephone, cellphone, or fax

required: country, connection, areacode, subscriber_number, number_type; unique: -


This model is being used to specify some extra information (read: specifications) about a specific type of hardware.

vendormany-to-one relationshipmodel
vendorcodestringvendor's product codeCISCO7606-S
namestringhuman readable labelPowerEdge M610
rackspaceintegersize (number of slots) of the box
expansionsintegernumber of expansion slots

required: vendor, name, rackspace; unique: -


These are possible roles for hardware in a cluster.

labelstringhuman readable labelcompute node

required: label; unique: label


Contains information about different types of interfaces.

vendormanufacturer of the interface
labelstringhuman readable labelDRAC 5

required: label; unique: -


A type of warranty offered by a company.

contactmany-to-one relationshipsupplier of the warranty
labelstringhuman readable labelDell Next Business Day On-Site

required: contact, label; unique: label


Contains warranty information of a specific contract, for (a collection of) hardware.

warranty_typemany-to-one relationshipthe type of warranty
contract_numberstringcontract numberNSEN420201
annual_costdecimalcost per year433.61
labelstringhuman readable labelLISA I vervanging
date_fromdatestart-date of the contract
date_todateexpiration-date of the contract

required: label, date_from, date_to; unique: label

Database Model

Last modified 5 years ago Last modified on 12/08/14 11:16:03

Attachments (2)

Download all attachments as: .zip