Changes between Version 3 and Version 4 of Usage/UserDocumentation


Ignore:
Timestamp:
05/31/12 14:46:39 (12 years ago)
Author:
sil
Comment:

documented options of cmt client

Legend:

Unmodified
Added
Removed
Modified
  • Usage/UserDocumentation

    v3 v4  
    4040To use the Command Line Interface has to be installed on your system. If you issue the command `cmt` you'll get the usage info:
    4141{{{
     42user@host$ cmt
    4243Usage: cmt [options]
    4344
     
    4950  --script             
    5051  -a ENTITY, --add=ENTITY
    51                         Add an object of given ENTITY.              arguments:
    52                         set <ASSIGNMENTS>              The object will get
    53                         values according to the given assignments.
    54                         Assignments could be formed like
    55                         [<FK>__]<attr>=<value>
     52                        Add an object of the given ENTITY. Extra arguments
     53                        should be given like `set ASSIGNMENTS`, where
     54                        ASSIGNMENTS are formatted like `ATTR=VAL`
    5655  -c ENTITY, --change=ENTITY
    57                         Change value(s) of object(s) of given ENTITY.
    58                         arguments:   get <QUERY> set <ASSIGNMENTS>
    59                         The query, which consists out of one or more terms, is
    60                         used to make             a selection of objects to
    61                         change. These objects will be changed
    62                         according to the given assignments.
     56                        Change value(s) of object(s) of the given ENTITY.
     57                        Arguments should be given like `get QUERY set
     58                        ASSIGNMENTS`, where both QUERY and ASSIGNMENTS consist
     59                        out of one or more terms formatted like `ATTR=VAL`.
     60                        Only objects matching QUERY will be changed according
     61                        to the given ASSIGNMENTS
    6362  -g TEMPLATE, --generate=TEMPLATE
    64                         Render the given template
    65   -l ENTITY [ATTRIBUTE=VALUE], --list=ENTITY [ATTRIBUTE=VALUE]
    66                         List object(s) of the given ENTITY.
    67                         arguments:   get <QUERY>              The query, which
    68                         consists out of one or more terms, is used to make
    69                         a selection of objects to list.
    70   -r ENTITY [ATTRIBUTE=VALUE], --remove=ENTITY [ATTRIBUTE=VALUE]
    71                         Remove objects which reflect the given query
     63                        Render the given TEMPLATE, and store the result if
     64                        specified
     65  -l ENTITY, --list=ENTITY
     66                        List object(s) of the given ENTITY. Arguments should
     67                        be given like `get QUERY`, where QUERY consists out of
     68                        one or more terms formatted like `ATTR=VAL`
     69  -r ENTITY, --remove=ENTITY
     70                        Remove object(s) of the given ENTITY. Arguments should
     71                        be given like `get QUERY`, where QUERY consists out of
     72                        one or more terms formatted like `ATTR=VAL`. Only
     73                        objects matching QUERY will be listed
    7274  -v, --verbose         
    7375}}}
    7476
    75 
    76 == Add object(s): `-a, --add` ==
    77 === Syntax ===
    78 === Use case ===
     77More 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.
     78
     79
     80== Add object: `-a, --add` ==
     81
     82Use 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:
     83
     84{{{
     85cmt --add <entity> <assignments>
     86}}}
     87
     88=== Use case ===
     89
     90'''You want to add a new server, and its interfaces'''
     91
     92As 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:
     93
     94|| ''Interface'' || ''network'' || ''MAC-address'' ||
     95|| Gigabit || lisa admin || 00:00:00:00:00:01 ||
     96|| !InfiniBand || lisa infiniband || 00:00:00:00:00:02 ||
     97|| iDRAC6 || lisa consoles || 00:00:00:00:00:03 ||
     98
     99{{{
     100user@host$ cmt --add hardwareunit cluster=Lisa role=computenode role=testnode specifications='PowerEdge M610' rack=1 first_slot=1
     101
     102user@host$ cmt --add interface host=r1n1 network='lisa admin' iftype='Gigabit' hwaddress='00:00:00:00:00:01'
     103
     104user@host$ cmt --add interface host=r1n1 network='lisa infiniband' iftype='InfiniBand' hwaddress='00:00:00:00:00:02'
     105
     106user@host$ cmt --add interface host=r1n1 network='lisa consoles' iftype='iDRAC6' hwaddress='00:00:00:00:00:03'
     107}}}
     108
     109
    79110== Change object(s): `-c, --change` ==
    80 === Syntax ===
    81 === Use case ===
    82 == Generate a configfile: `-g, --generate` ==
    83 === Syntax ===
    84 === Use case ===
     111
     112Use 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:
     113
     114{{{
     115sara_cmt --change <entity> [get] <query> set <assignments>
     116}}}
     117
     118=== Use case ===
     119'''You have to change an existing address:'''
     120
     121{{{
     122user@host$ cmt --change address get address='Kruislaan 415' set address='Science Park 121' postalcode='1098 XG'
     123}}}
     124
     125'''Or maybe a motherboard has been replaced, so the MAC-addresses of the onboard interfaces have been changed:'''
     126
     127|| ''Interface'' || ''Old MAC'' || ''New MAC'' ||
     128|| Gigabit || 00:23:AE:FD:C9:00 || 00:26:B9:F9:95:34 ||
     129|| iDRAC6 || 00:23:AE:FB:C7:DD || A4:BA:DB:00:31:F6 ||
     130
     131{{{
     132user@host$ cmt --change interface get hwaddress=00:23:AE:FD:C9:00 set hwaddress=00:26:B9:F9:95:34
     133
     134user@host$ cmt --change interface get hwaddress=00:23:AE:FB:C7:DD set hwaddress=A4:BA:DB:00:31:F6
     135}}}
     136
     137In both commands you'll query for the interface with the old MAC-address, and overwrite the value of the hwaddress-field with the new MAC-address.
     138
     139Since you know in which machine the motherboard has been replaced -- in this case `r34n26` -- it might be easier to issue a command like:
     140
     141{{{
     142user@host$ cmt --change interface get host=r34n26 iftype=Gigabit set hwaddress=00:26:B9:F9:95:34
     143
     144user@host$ cmt --change interface get host=r34n26 iftype=iDRAC6 set hwaddress=A4:BA:DB:00:31:F6
     145}}}
     146
     147This will only work when the machine contains a single Gigabit-interface, as well as a single iDRAC6-interface. In this case you don't need to know the old MAC-addresses.
     148
     149'''You want to add the service-tags to new Dell-hardware:'''
     150
     151For example new chassis in rack 2, 13, and 36:
     152
     153{{{
     154user@host$ for rack in 2 13 36
     155> do
     156>   for cmc in a b
     157>   do
     158>     svctag=`sararac -c getsvctag dr-r${rack}cmc-${cmc} | sed -rn 's/^Chassis.*([A-Z0-9]{7})$/\1/p'`
     159>     echo saving warranty tag ${svctag} to r${rack}cmc-${cmc}
     160>     cmt --script --change hardwareunit get label=r${rack}cmc-${cmc} set warranty_tag=${svctag}
     161>   done
     162> done
     163}}}
     164
     165And all hardware in these chassis:
     166
     167{{{
     168user@host$ for rack in 2 13 36
     169> do
     170>   for node in `seq 1 32`
     171>   do
     172>     svctag=`sararac -c getsvctag dr-r${rack}n${node} | sed -rn 's/^.*([A-Z0-9]{7})$/\1/p'`
     173>     echo saving warranty tag ${svctag} to r${rack}n${node}
     174>     cmt --script --change hardwareunit get rack=${rack} first_slot=${node} set warranty_tag=${svctag}
     175>   done
     176> done
     177}}}
     178
     179
     180== Generate a config-file: `-g, --generate` ==
     181
     182Render a template to generate a config-file or a report. Use the following syntax:
     183
     184{{{
     185sara_cmt --generate <templatename>
     186}}}
     187
     188=== Use case ===
     189
     190'''When you want to generate the cfrun_hosts file of the Clearspeed cluster:'''
     191
     192{{{
     193user@host$ cmt --generate cfrun_hosts.clearspeed
     194}}}
     195Which generates the cfrun_hosts file and stores the following content at `/usr/sara/etc/cfengine/rc.hosts.clearspeed`:
     196
     197{{{
     198#
     199# This file is automagicly generated by CMT
     200#
     201#             SARA - Computing and Networking Services
     202# Date      : Tue, 15 Jun 2010
     203# Version   : CMT CLI 1.0
     204# Generated : Thu, 15 Jul 2010 09:20:27 +0200
     205#
     206# SVN:
     207#       $Id:$
     208#       $URL:$
     209#
     210
     211
     212outputdir=/data/cfengine/output/clearspeed
     213maxchild=8
     214login1
     215gb-r50n1.irc.sara.nl
     216gb-r50n2.irc.sara.nl
     217gb-r50n3.irc.sara.nl
     218gb-r50n4.irc.sara.nl
     219gb-r50n5.irc.sara.nl
     220gb-r50n6.irc.sara.nl
     221gb-r50n7.irc.sara.nl
     222gb-r50n8.irc.sara.nl
     223gb-r51n1.irc.sara.nl
     224gb-r51n2.irc.sara.nl
     225gb-r51n3.irc.sara.nl
     226gb-r51n4.irc.sara.nl
     227gb-r51n5.irc.sara.nl
     228gb-r51n6.irc.sara.nl
     229gb-r51n7.irc.sara.nl
     230gb-r51n8.irc.sara.nl
     231}}}
     232
     233
    85234== List object(s): `-l, --list` ==
    86 === Syntax ===
    87 === Use case ===
     235
     236Use 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:
     237
     238{{{
     239cmt_sara --list <entity> [get] <query>
     240}}}
     241
     242=== Use case ===
     243
     244'''If you need to figure out where a machine -- in this case `test3` -- is physically hosted:'''
     245
     246When 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:
     247
     248{{{
     249user@host$ cmt --list hardwareunit label=test3
     250}}}
     251
     252The output of this command looks like:
     253
     254{{{
     255 .---[  test3  ]---
     256 : cluster        : LDAP/CUA
     257 : address        : Amsterdam - Science Park 121
     258 : room           : S142A
     259 : rack           : rack AD38
     260 : first_slot     : 23
     261 : specifications : PowerEdge 1950 (Dell bv)
     262 : roles          : administration
     263 : in_support     : True
     264 '---
     265}}}