Changes between Initial Version and Version 1 of Usage2/UserDocumentation


Ignore:
Timestamp:
05/06/16 08:58:10 (8 years ago)
Author:
jaap
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Usage2/UserDocumentation

    v1 v1  
     1[[PageOutline]]
     2
     3= User Documentation =
     4
     5CMT can be used with different user interfaces:
     6
     7 Web Interface::
     8   An easy-to-use, self explainable, interface based on Django Admin. You only need a webbrowser to use this interface.
     9 Command Line Interface (CLI)::
     10   A less-easy-to-use interface which could be used to make mass-updates. The CLI offers the user some powerful functions which aren't possible on the web-interface. To use this interface you need to [Usage2/Quickstart#InstallCMT install CMT] on the computer you're using.
     11
     12'''Please keep in mind:''' Both interfaces are lacking of an undo-function, so be careful when you're about to make any changes in the data you've stored in CMT.
     13
     14
     15= Web-interface =
     16
     17The web-interface can be opened in any regular web-browser.
     18Ask your administrator for its address.
     19Once you open the web-interface, a login-page should appear where you have to issue your credentials.
     20
     21From there you'll be able to add objects to the database, explore objects in the database, change objects in the database, or delete objects from the database.
     22It's meant as a intuitive easy-to-use interface, with advanced Create-Read-Update-Delete (CRUD) functionalities.
     23It makes you able to quickly explore the [wiki:/Data/Datastructure data stored in CMT], or act on the data.
     24The most important entities you can act on are:
     25 Clusters::
     26   A cluster could be described as a collection of hardware, connected to each other through one or more networks.
     27 Racks::
     28   A rack is a cabinet that houses hardware like servers and switches.
     29   It has multiple slots to mount hardware.
     30   These slots identify the physical location of your hardware.
     31 Equipment::
     32   Hardware units like (virtual) servers, switches, PDU's, etc.
     33   It could be 'any piece of hardware with a powercable attached to it'.
     34 Networks::
     35   Networks defined by their (IP) address space.
     36   The addresses in the address space of a network each are related to an interface.
     37 Interfaces::
     38   Network interfaces for input/output, thus any kind of card or (virtual) adapter which can have a network-cable plugged into it, and has a hardware address (like a MAC-address).
     39   Most obvious example is a regular 100/1000Mbit NIC, but it could be something like an !InfiniBand interface card, or an out-of-band management adapter.
     40   Many network interfaces are related to a single piece of hardware, and a single network.
     41
     42= Command Line Interface =
     43
     44To use the Command Line Interface has to be installed on your system. If you issue the command `cmt` you'll get the usage info:
     45{{{
     46user@host$ cmt
     47usage: cmt [-h] [--dry-run] [--verbose | --quiet] [--version]
     48           [--config-file CONFIG_FILE]
     49           {create,read,update,delete,parse} ...
     50cmt: error: too few arguments
     51
     52}}}
     53
     54More information about the options can be read in the following subsections. For each option we'll give one or more use cases as an example.
     55
     56
     57== CRUD(P) options ==
     58
     59Just like the web-interface, the CLI can be used for CRUD-functionalities (Create, Read, Update, Delete) too. However, the implementation of the CLI is much more powerful, since it can be used to do things with multiple objects at once, and can be done from shell-scripts.
     60
     61=== Create object: `create` ===
     62
     63Use this option to add a new object of a given entity to the database. You have to specify the entity and assign values to its fields by providing assignments as extra arguments. The syntax is as follows:
     64
     65{{{
     66cmt create <entity> --set <assignments>
     67}}}
     68
     69==== Use case ====
     70
     71'''You want to add a new server, and its interfaces'''
     72
     73As an example we'll add a server (!PowerEdge M610) to the 1st position in rack 1 of the Lisa-cluster. The server will be used as a test- and computenode, and has the following interfaces:
     74
     75|| ''Interface'' || ''network'' || ''MAC-address'' ||
     76|| Gigabit || lisa admin || 00:00:00:00:00:01 ||
     77|| iDRAC6 || lisa consoles || 00:00:00:00:00:03 ||
     78
     79{{{
     80user@host$ cmt create equipment --set 'cluster=Lisa' 'label=jaap' rack=35 firs_slot=35 specifications="PowerEdge M620"
     81
     82user@host$ cmt --add interface host=r1n1 network='lisa admin' iftype='Gigabit' hwaddress='00:00:00:00:00:01'
     83
     84user@host$ cmt --add interface host=r1n1 network='lisa consoles' iftype='iDRAC6' hwaddress='00:00:00:00:00:03'
     85}}}
     86
     87=== Read object(s): `read` ===
     88
     89Use this option to list existing objects in the database. You have to specify the entity, and filter objects you want to list by providing a query. The syntax is as follows:
     90
     91{{{
     92cmt_sara read <entity> --get <query>
     93}}}
     94
     95==== Use case ====
     96
     97'''If you need to figure out where a machine -- in this case `test3` -- is physically hosted:'''
     98
     99When an engineer has to fix a node you need to tell him the location of the node. This information shall be listed by issuing the following command:
     100
     101{{{
     102user@host$ cmt read equipment label=test3
     103}}}
     104
     105The output of this command looks like:
     106
     107{{{
     108{
     109    "count": 1,
     110    "next": null,
     111    "previous": null,
     112    "results": [
     113        {
     114            "cluster": "Lisa",
     115            "created_on": "2016-05-06T08:19:54.044",
     116            "first_slot": 35,
     117            "interfaces": [],
     118            "label": "jaap",
     119            "note": "",
     120            "owner": null,
     121            "rack": "35",
     122            "role": [
     123                "testnode"
     124            ],
     125            "seller": null,
     126            "serial_number": null,
     127            "specifications": "PowerEdge M620",
     128            "state": "unknown",
     129            "updated_on": "2016-05-06T08:39:32.776",
     130            "url": "https://cmt.surfsara.nl/api/v1/equipment/5198/",
     131            "warranty": null,
     132            "warranty_tag": null
     133        }
     134    ]
     135}
     136}}}
     137
     138=== Update object(s): `update` ===
     139
     140Use this option to change fields of one or more objects in the database. You have to specify the entity, filter objects you want to change by providing a query, and assign new values to their fields by providing assignments as extra arguments. The syntax is as follows:
     141
     142
     143TODO
     144{{{
     145cmt
     146}}}
     147
     148
     149=== Delete object(s): `delete` ===
     150
     151Use this option to remove objects from the database. You have to specify the entity, and filter objects you want to remove by providing a query. The syntax is as follows:
     152
     153{{{
     154cmt delete <entity> --get <query>
     155}}}
     156
     157==== Use case ====
     158
     159'''You have removed a server from a rack:'''
     160
     161For example node 'jaap' in rack 35:
     162
     163{{{
     164user@host$ cmt delete equipment --get 'cluster=Lisa' 'label=jaap' 'rack=35'
     165{u'count': 1,
     166 u'next': None,
     167 u'previous': None,
     168 u'results': [{u'cluster': u'Lisa',
     169               u'created_on': u'2016-05-06T08:19:54.044',
     170               u'first_slot': 35,
     171               u'interfaces': [],
     172               u'label': u'jaap',
     173               u'note': u'',
     174               u'owner': None,
     175               u'rack': u'35',
     176               u'role': [u'testnode'],
     177               u'seller': None,
     178               u'serial_number': None,
     179               u'specifications': u'PowerEdge M620',
     180               u'state': u'unknown',
     181               u'updated_on': u'2016-05-06T08:39:32.776',
     182               u'url': u'https://cmt.surfsara.nl/api/v1/equipment/5198/',
     183               u'warranty': None,
     184               u'warranty_tag': None}]}
     185[DELETE] You are about to delete: 1 object(s). Are you sure ([N]/Y)?: y
     186[DELETING] 1 of 1
     187[LOGIN] Authorization required
     188[LOGIN] Username: jaap
     189[LOGIN] Password:
     190[SUCCESS] Succefully deleted 1 object(s)
     191}}}
     192
     193As you can see there will be asked for confirmation by default.
     194
     195
     196== Other options ==
     197
     198
     199
     200=== Generate a config-file: `parse` ===
     201
     202Render a template to generate a config-file or a report. Use the following syntax:
     203
     204{{{
     205cmt parse <templatename>
     206}}}
     207
     208By default your templates can be found in your (virtual) environment in de directory `/etc/cmt/templates`.
     209
     210
     211
     212More information about how to write your own templates can be found at a [wiki:Usage/TemplatingDocumentation separate page about the template language].