wiki:Data/Datastructure

Version 3 (modified by ramonb, 11 years ago) (diff)

--

About the CMT data(structure)

The datastructure of CMT consists of various models, defined in the models.py 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 manage.py-file which is a wrapper around Django's command-line utility django-admin.py 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 manage.py 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)

Cluster

A labeled group of hardware units.

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

required: name; unique: name

HardwareUnit

A specific kind of hardware.

attributedatatypedescriptionexample
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

Interface

An interface of a piece of hardware.

attributedatatypedescriptionexample
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:]
ipIP-addressIP-address

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

Network

Holds information about a network.

attributedatatypedescriptionexample
namestringhuman readable label.
cidrcidrsubnet192.168.1.0/24
gatewayIP-addressgateway address. Automagically generated if kept empty.
domainstringdomain nameirc.sara.nl
vlanintegerVLAN139
hostnamesstringstringformat of hostnames in the networkib-{machine}

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

Rack

A cabinet used for mounting hardware.

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

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

Country

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

required: name, country_code; unique: name, country_code

Address

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

attributedatatypedescriptionexample
countrymany-to-one relationshipcountry of the address
addressstringaddress-line
postalcodestringpostal code
citystringcity

required: address, city; unique: address+city

Room

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

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

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

Company

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

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

required: addresses, name, website; unique: name

Connection

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

attributedatatypedescriptionexample
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

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

attributedatatypedescriptionexample
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: -

HardwareModel

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

attributedatatypedescriptionexample
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: -

Role

These are possible roles for hardware in a cluster.

attributedatatypedescriptionexample
labelstringhuman readable labelcompute node

required: label; unique: label

InterfaceType

Contains information about different types of interfaces.

attributedatatypedescriptionexample
vendormanufacturer of the interface
labelstringhuman readable labelDRAC 5

required: label; unique: -

WarrantyType

A type of warranty offered by a company.

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

required: contact, label; unique: label

WarrantyContract

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

attributedatatypedescriptionexample
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

Attachments (2)

Download all attachments as: .zip