[[PageOutline]] = About the CMT data(structure) = The datastructure of CMT consists of various models, defined in the [source:trunk/sara_cmt/sara_cmt/cluster/models.py models.py source-file]. Just like in other [https://www.djangoproject.com/ 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 [https://docs.djangoproject.com/en/dev/ref/django-admin/ 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) [[BR]] Role (n:n) [[BR]] Network (n:n) [[BR]] !HardwareModel (n:1) [[BR]] !WarrantyContract (n:1) [[BR]] Rack (n:1) [[BR]] Connection (n:1) || || Interface || An interface of a piece of hardware || Network (n:1) [[BR]] !HardwareUnit (n:1) [[BR]] !InterfaceType (n:1) [[BR]] || || 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) [[BR]] Company (n:1) || || Telephonenumber || Used for telephonenumbers of contacts. || Country (n:1) [[BR]] 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. ||'''attribute'''||'''datatype'''||'''description'''||'''example'''|| ||name||string||human readable label of the cluster|||| ||machinenames||string||machine names syntax||r{rack}n{first_slot}|| '''required:''' name; '''unique:''' name === !HardwareUnit === A specific kind of hardware. ||'''attribute'''||'''datatype'''||'''description'''||'''example'''|| ||cluster||many-to-one relationship||cluster which this hardware is part of|||| ||role||many-to-many relationship||the role this hardware fulfills within the cluster|||| ||specifications||many-to-one relationship||hardware specifications|||| ||warranty||many-to-one relationship||warranty contract for this hardware|||| ||seller||many-to-one relationship||the company which it's bought from|||| ||owner||many-to-one relationship||the client/project which it's bought for|||| ||rack||many-to-one relationshiop||the rack this hardware is mounted in|||| ||first_slot||integer||the first slot this hardware occupies in its rack|||| ||state||string||{new,clean,configured,unknown,off}, default: off ([http://www.usenix.net/publications/library/proceedings/lisa97/full_papers/20.evard/20.pdf more])|||| ||warranty_tag||string||service tag or serialnumber|||| ||serial_number||string||serial number|||| ||label||string||label for the piece of hardware|||| '''required:''' cluster, role, rack; '''unique:''' rack+first_slot, cluster+label === Interface === An interface of a piece of hardware. ||'''attribute'''||'''datatype'''||'''description'''||'''example'''|| ||network||many-to-one relationship||network this interface is in|||| ||host||many-to-one relationship||piece of hardware this interface is part of|||| ||iftype||many-to-one relationship||type of interface|||| ||label||string||label for the interface|||| ||aliases||string||comma-seperated list of CNAMEs|||| ||hwaddress||string||MAC-address written with [0-9a-f:]|||| ||ip||IP-address||IP-address|||| '''required:''' network, host, iftype, label; '''unique:''' network+ip, network+hwaddress === Network === Holds information about a network. ||'''attribute'''||'''datatype'''||'''description'''||'''example'''|| ||name||string||human readable label.|| ||cidr||cidr||subnet||192.168.1.0/24|| ||gateway||IP-address||gateway address. Automagically generated if kept empty.|| ||domain||string||domain name||irc.sara.nl|| ||vlan||integer||VLAN||139|| ||hostnames||string||stringformat of hostnames in the network||ib-{machine}|| '''required:''' name, cidr, domain, hostnames; '''unique:''' - === Rack === A cabinet used for mounting hardware. ||'''attribute'''||'''datatype'''||'''description'''||'''example'''|| ||room||many-to-one relationship||the room where this rack is located|||| ||label||string||label for the rack||am91|| ||capacity||integer||number of slots|||| '''required:''' room, label, capacity; '''unique:''' room+label === Country === ||'''attribute'''||'''datatype'''||'''description'''||'''example'''|| ||name||string||name of the country||Netherlands|| ||country_code||integer||country code, according to E.164 standard||31|| '''required:''' name, country_code; '''unique:''' name, country_code === Address === Information about the physical locations, which can be referred to from objects. ||'''attribute'''||'''datatype'''||'''description'''||'''example'''|| ||country||many-to-one relationship||country of the address|||| ||address||string||address-line|||| ||postalcode||string||postal code|||| ||city||string||city|||| '''required:''' address, city; '''unique:''' address+city === Room === A room is located at an address. This is where racks of hardware can be found. ||'''attribute'''||'''datatype'''||'''description'''||'''example'''|| ||address||many-to-one relationship||address where the room is|||| ||floor||integer||floor of the room|||| ||label||string||label 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. ||'''attribute'''||'''datatype'''||'''description'''||'''example'''|| ||addresses||many-to-many relationship||addresses where a company is located|||| ||name||string||name of the company|||| ||website||URL||URL of their website|||| '''required:''' addresses, name, website; '''unique:''' name === Connection === A contact can be a person, or (for example) a hotline for support. ||'''attribute'''||'''datatype'''||'''description'''||'''example'''|| ||address||many-to-one relationship||address of the contact|||| ||company||many-to-one relationship||company of the contact|||| ||active||boolean||whether it's currently a contact or not|||| ||name||string||full name|||| ||email||email address||email address|||| '''required:''' company, name; '''unique:''' company+name === Telephonenumber === Telephonenumber to link to a contact. Split in country-, area- and subscriber-part for easy filtering. ||'''attribute'''||'''datatype'''||'''description'''||'''example'''|| ||country||many-to-one relationship||country part of the telephone number|||| ||connection||many-to-one relationship||owner of the telephone number|||| ||areacode||charfield||area code part of the telephone number|||| ||subscriber_number||integerfield||subscriber part of the telephone number|||| ||number_type||charfield||['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. ||'''attribute'''||'''datatype'''||'''description'''||'''example'''|| ||vendor||many-to-one relationship||model|||| ||vendorcode||string||vendor's product code||CISCO7606-S|| ||name||string||human readable label||!PowerEdge M610|| ||rackspace||integer||size (number of slots) of the box|||| ||expansions||integer||number of expansion slots|||| '''required:''' vendor, name, rackspace; '''unique:''' - === Role === These are possible roles for hardware in a cluster. ||'''attribute'''||'''datatype'''||'''description'''||'''example'''|| ||label||string||human readable label||compute node|| '''required:''' label; '''unique:''' label === !InterfaceType === Contains information about different types of interfaces. ||'''attribute'''||'''datatype'''||'''description'''||'''example'''|| ||vendor||||manufacturer of the interface|||| ||label||string||human readable label||DRAC 5|| '''required:''' label; '''unique:''' - === !WarrantyType === A type of warranty offered by a company. ||'''attribute'''||'''datatype'''||'''description'''||'''example'''|| ||contact||many-to-one relationship||supplier of the warranty|||| ||label||string||human readable label||Dell Next Business Day On-Site|| '''required:''' contact, label; '''unique:''' label === !WarrantyContract === Contains warranty information of a specific contract, for (a collection of) hardware. ||'''attribute'''||'''datatype'''||'''description'''||'''example'''|| ||warranty_type||many-to-one relationship||the type of warranty|||| ||contract_number||string||contract number||NSEN420201|| ||annual_cost||decimal||cost per year||433.61|| ||label||string||human readable label||LISA I vervanging|| ||date_from||date||start-date of the contract|||| ||date_to||date||expiration-date of the contract|||| '''required:''' label, date_from, date_to; '''unique:''' label == Databasemodel == [[Image(CMT.png,100%)]]