18 | | = About the CMT data(structure) = |
19 | | |
20 | | The datastructure of CMT consists of various models, defined in the [source:trunk/sara_cmt/sara_cmt/cluster/models.py models.py source-file]. |
21 | | 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. |
22 | | There's an interactive shell, included in Django, which you can use for testing queries or looking up the models. |
23 | | 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. |
24 | | If you are familiar with Django, you might use this shell. |
25 | | Otherwise we advise you to use one one of the interfaces of CMT. |
26 | | |
27 | | {{{ |
28 | | user@host$ python manage.py shell |
29 | | }}} |
30 | | |
31 | | This will give you an interactive shell with a welcome message. |
32 | | First thing to do is import the models of `sara_cmt`: |
33 | | |
34 | | {{{ |
35 | | In [1]: from sara_cmt.cluster.models import * |
36 | | }}} |
37 | | |
38 | | |
39 | | == Example of a model == |
40 | | |
41 | | To give an impression of how a model looks like, here's an example: |
42 | | {{{ |
43 | | class Room(ModelExtension): |
44 | | address = models.ForeignKey(Address, related_name='rooms') |
45 | | |
46 | | floor = models.IntegerField(max_length=2) |
47 | | label = models.CharField(max_length=30, blank=False) |
48 | | |
49 | | class Meta: |
50 | | unique_together = ('address', 'floor', 'label') |
51 | | |
52 | | def __unicode__(self): |
53 | | return unicode(floor) |
54 | | }}} |
55 | | |
56 | | This model the class for a Room-model. In this case a room has got 3 fields of different types: |
57 | | * An address, which is stored in the database as a foreign key to the Address-table. |
58 | | * A floor, which is stored as an integer of 2 digits max. |
59 | | * 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. |
60 | | |
61 | | |
62 | | == Available models == |
63 | | |
64 | | The models available in CMT are: |
65 | | |
66 | | || '''Model''' || '''Description''' || '''Related to''' || |
67 | | || Cluster || A labeled group of hardware pieces || || |
68 | | || !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) || |
69 | | || Interface || An interface of a piece of hardware || Network (n:1) [[BR]] !HardwareUnit (n:1) [[BR]] !InterfaceType (n:1) [[BR]] || |
70 | | || Network || Information about a network. || Interface (1:n) || |
71 | | || Rack || A standardized system for mounting various pieces of hardware in a stack of slots. || || |
72 | | || Country || Countries paired with there country-code || || |
73 | | || Address || Holds information about the physical location of a piece of hardware. || Country (n:1) || |
74 | | || Room || Located at an address, this is where a rack of hardware can be found. || || |
75 | | || Company || This can be linked to hardware, to be able to define contactpersons for a specific piece of hardware || Address (n:n) || |
76 | | || Connection || These are contacts that can be linked as connections for warranties etc. || Address (n:1) [[BR]] Company (n:1) || |
77 | | || Telephonenumber || Used for telephonenumbers of contacts. || Country (n:1) [[BR]] Connection (n:1) || |
78 | | || !HardwareModel || This model is being used to specify some extra information (specifications) about a specific type (model) of hardware || Company (n:1) || |
79 | | || Role || Describes the role of a piece of hardware in the cluster. || || |
80 | | || !InterfaceType || Contains information about different types of interfaces || Company (n:1) || |
81 | | || !WarrantyType || A type of warranty offered by a company || Connection (n:1) || |
82 | | || !WarrantyContract || A class which contains warranty information of (a collection of) hardware. || !WarrantyType (n:1) || |
83 | | |
84 | | === Cluster === |
85 | | |
86 | | A labeled group of hardware units. |
87 | | ||'''attribute'''||'''datatype'''||'''description'''||'''example'''|| |
88 | | ||name||string||human readable label of the cluster|||| |
89 | | '''required:''' name; |
90 | | '''unique:''' name |
91 | | |
92 | | === !HardwareUnit === |
93 | | |
94 | | A specific kind of hardware. |
95 | | ||'''attribute'''||'''datatype'''||'''description'''||'''example'''|| |
96 | | ||cluster||many-to-one relationship||cluster which this hardware is part of|||| |
97 | | ||role||many-to-many relationship||the role this hardware fulfills within the cluster|||| |
98 | | ||specifications||many-to-one relationship||hardware specifications|||| |
99 | | ||warranty||many-to-one relationship||warranty contract for this hardware|||| |
100 | | ||seller||many-to-one relationship||the company which it's bought from|||| |
101 | | ||owner||many-to-one relationship||the client/project which it's bought for|||| |
102 | | ||rack||many-to-one relationshiop||the rack this hardware is mounted in|||| |
103 | | ||first_slot||integer||the first slot this hardware occupies in its rack|||| |
104 | | ||state||string||{new,clean,configured,unknown,off}, default: off ([http://www.usenix.net/publications/library/proceedings/lisa97/full_papers/20.evard/20.pdf more])|||| |
105 | | ||warranty_tag||string||service tag or serialnumber|||| |
106 | | ||serial_number||string||serial number|||| |
107 | | ||label||string||label for the piece of hardware|||| |
108 | | '''required:''' cluster, role, rack; |
109 | | '''unique:''' rack+first_slot |
110 | | |
111 | | === Interface === |
112 | | |
113 | | An interface of a piece of hardware. |
114 | | ||'''attribute'''||'''datatype'''||'''description'''||'''example'''|| |
115 | | ||network||many-to-one relationship||network this interface is in|||| |
116 | | ||host||many-to-one relationship||piece of hardware this interface is part of|||| |
117 | | ||iftype||many-to-one relationship||type of interface|||| |
118 | | ||label||string||label for the interface|||| |
119 | | ||aliases||string||comma-seperated list of CNAMEs|||| |
120 | | ||hwaddress||string||MAC-address written with [0-9a-f:]|||| |
121 | | ||ip||IP-address||IP-address|||| |
122 | | '''required:''' network, host, iftype, label; |
123 | | '''unique:''' network+ip, network+hwaddress |
124 | | |
125 | | === Network === |
126 | | |
127 | | Holds information about a network. |
128 | | ||'''attribute'''||'''datatype'''||'''description'''||'''example'''|| |
129 | | ||name||string||human readable label.|| |
130 | | ||netaddress||IP-address||network address||192.168.1.0|| |
131 | | ||netmask||IP-address||netmask||255.255.255.0|| |
132 | | ||gateway||IP-address||gateway address. Automagically generated if kept empty.|| |
133 | | ||domain||string||domain name||irc.sara.nl|| |
134 | | ||vlan||integer||VLAN||139|| |
135 | | ||hostnames||string||stringformat of hostnames in the network||ib-{machine}|| |
136 | | '''required:''' name, netaddress, netmask, domain, hostnames; |
137 | | '''unique:''' - |
138 | | |
139 | | === Rack === |
140 | | |
141 | | A cabinet used for mounting hardware. |
142 | | ||'''attribute'''||'''datatype'''||'''description'''||'''example'''|| |
143 | | ||room||many-to-one relationship||the room where this rack is located|||| |
144 | | ||label||string||label for the rack||am91|| |
145 | | ||capacity||integer||number of slots|||| |
146 | | '''required:''' room, label, capacity; |
147 | | '''unique:''' room+label |
148 | | |
149 | | === Country === |
150 | | |
151 | | ||'''attribute'''||'''datatype'''||'''description'''||'''example'''|| |
152 | | ||name||string||name of the country||Netherlands|| |
153 | | ||country_code||integer||country code, according to E.164 standard||31|| |
154 | | '''required:''' name, country_code; |
155 | | '''unique:''' name, country_code |
156 | | |
157 | | === Address === |
158 | | |
159 | | Information about the physical locations, which can be referred to from objects. |
160 | | ||'''attribute'''||'''datatype'''||'''description'''||'''example'''|| |
161 | | ||country||many-to-one relationship||country of the address|||| |
162 | | ||address||string||address-line|||| |
163 | | ||postalcode||string||postal code|||| |
164 | | ||city||string||city|||| |
165 | | '''required:''' address, city; |
166 | | '''unique:''' address+city |
167 | | |
168 | | === Room === |
169 | | |
170 | | A room is located at an address. This is where racks of hardware can be found. |
171 | | ||'''attribute'''||'''datatype'''||'''description'''||'''example'''|| |
172 | | ||address||many-to-one relationship||address where the room is|||| |
173 | | ||floor||integer||floor of the room|||| |
174 | | ||label||string||label of the room|||| |
175 | | '''required:''' address, floor, label; |
176 | | '''unique:''' address+floor+label |
177 | | |
178 | | === Company === |
179 | | |
180 | | Holds information about a company. This can be used to link (to) hardware and contacts. |
181 | | ||'''attribute'''||'''datatype'''||'''description'''||'''example'''|| |
182 | | ||addresses||many-to-many relationship||addresses where a company is located|||| |
183 | | ||name||string||name of the company|||| |
184 | | ||website||URL||URL of their website|||| |
185 | | '''required:''' addresses, name, website; |
186 | | '''unique:''' name |
187 | | |
188 | | === Connection === |
189 | | A contact can be a person, or (for example) a hotline for support. |
190 | | ||'''attribute'''||'''datatype'''||'''description'''||'''example'''|| |
191 | | ||address||many-to-one relationship||address of the contact|||| |
192 | | ||company||many-to-one relationship||company of the contact|||| |
193 | | ||active||boolean||whether it's currently a contact or not|||| |
194 | | ||name||string||full name|||| |
195 | | ||email||email address||email address|||| |
196 | | '''required:''' company, name; |
197 | | '''unique:''' company+name |
198 | | |
199 | | === Telephonenumber === |
200 | | |
201 | | Telephonenumber to link to a contact. Split in country-, area- and subscriber-part for easy filtering. |
202 | | ||'''attribute'''||'''datatype'''||'''description'''||'''example'''|| |
203 | | ||country||many-to-one relationship||country part of the telephone number|||| |
204 | | ||connection||many-to-one relationship||owner of the telephone number|||| |
205 | | ||areacode||charfield||area code part of the telephone number|||| |
206 | | ||subscriber_number||integerfield||subscriber part of the telephone number|||| |
207 | | ||number_type||charfield||['T','C','F'], for telephone, cellphone, or fax|||| |
208 | | '''required:''' country, connection, areacode, subscriber_number, number_type; |
209 | | '''unique:''' - |
210 | | |
211 | | === !HardwareModel === |
212 | | |
213 | | This model is being used to specify some extra information (read: specifications) about a specific type of hardware. |
214 | | ||'''attribute'''||'''datatype'''||'''description'''||'''example'''|| |
215 | | ||vendor||many-to-one relationship||model|||| |
216 | | ||vendorcode||string||vendor's product code||CISCO7606-S|| |
217 | | ||name||string||human readable label||!PowerEdge M610|| |
218 | | ||rackspace||integer||size (number of slots) of the box|||| |
219 | | ||expansions||integer||number of expansion slots|||| |
220 | | '''required:''' vendor, name, rackspace; |
221 | | '''unique:''' - |
222 | | |
223 | | === Role === |
224 | | |
225 | | These are possible roles for hardware in a cluster. |
226 | | ||'''attribute'''||'''datatype'''||'''description'''||'''example'''|| |
227 | | ||label||string||human readable label||compute node|| |
228 | | '''required:''' label; |
229 | | '''unique:''' label |
230 | | |
231 | | === !InterfaceType === |
232 | | |
233 | | Contains information about different types of interfaces. |
234 | | ||'''attribute'''||'''datatype'''||'''description'''||'''example'''|| |
235 | | ||vendor||||manufacturer of the interface|||| |
236 | | ||label||string||human readable label||DRAC 5|| |
237 | | '''required:''' label; |
238 | | '''unique:''' - |
239 | | |
240 | | === !WarrantyType === |
241 | | |
242 | | A type of warranty offered by a company. |
243 | | ||'''attribute'''||'''datatype'''||'''description'''||'''example'''|| |
244 | | ||contact||many-to-one relationship||supplier of the warranty|||| |
245 | | ||label||string||human readable label||Dell Next Business Day On-Site|| |
246 | | '''required:''' contact, label; |
247 | | '''unique:''' label |
248 | | |
249 | | === !WarrantyContract === |
250 | | |
251 | | Contains warranty information of a specific contract, for (a collection of) hardware. |
252 | | ||'''attribute'''||'''datatype'''||'''description'''||'''example'''|| |
253 | | ||warranty_type||many-to-one relationship||the type of warranty|||| |
254 | | ||contract_number||string||contract number||NSEN420201|| |
255 | | ||annual_cost||decimal||cost per year||433.61|| |
256 | | ||label||string||human readable label||LISA I vervanging|| |
257 | | ||date_from||date||start-date of the contract|||| |
258 | | ||date_to||date||expiration-date of the contract|||| |
259 | | '''required:''' label, date_from, date_to; |
260 | | '''unique:''' label |
261 | | |
262 | | |