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 |
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 |
75 | | |
76 | | == Add object(s): `-a, --add` == |
77 | | === Syntax === |
78 | | === Use case === |
| 77 | More 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 | |
| 82 | Use 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 | {{{ |
| 85 | cmt --add <entity> <assignments> |
| 86 | }}} |
| 87 | |
| 88 | === Use case === |
| 89 | |
| 90 | '''You want to add a new server, and its interfaces''' |
| 91 | |
| 92 | As 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 | {{{ |
| 100 | user@host$ cmt --add hardwareunit cluster=Lisa role=computenode role=testnode specifications='PowerEdge M610' rack=1 first_slot=1 |
| 101 | |
| 102 | user@host$ cmt --add interface host=r1n1 network='lisa admin' iftype='Gigabit' hwaddress='00:00:00:00:00:01' |
| 103 | |
| 104 | user@host$ cmt --add interface host=r1n1 network='lisa infiniband' iftype='InfiniBand' hwaddress='00:00:00:00:00:02' |
| 105 | |
| 106 | user@host$ cmt --add interface host=r1n1 network='lisa consoles' iftype='iDRAC6' hwaddress='00:00:00:00:00:03' |
| 107 | }}} |
| 108 | |
| 109 | |
80 | | === Syntax === |
81 | | === Use case === |
82 | | == Generate a configfile: `-g, --generate` == |
83 | | === Syntax === |
84 | | === Use case === |
| 111 | |
| 112 | Use 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 | {{{ |
| 115 | sara_cmt --change <entity> [get] <query> set <assignments> |
| 116 | }}} |
| 117 | |
| 118 | === Use case === |
| 119 | '''You have to change an existing address:''' |
| 120 | |
| 121 | {{{ |
| 122 | user@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 | {{{ |
| 132 | user@host$ cmt --change interface get hwaddress=00:23:AE:FD:C9:00 set hwaddress=00:26:B9:F9:95:34 |
| 133 | |
| 134 | user@host$ cmt --change interface get hwaddress=00:23:AE:FB:C7:DD set hwaddress=A4:BA:DB:00:31:F6 |
| 135 | }}} |
| 136 | |
| 137 | In 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 | |
| 139 | Since 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 | {{{ |
| 142 | user@host$ cmt --change interface get host=r34n26 iftype=Gigabit set hwaddress=00:26:B9:F9:95:34 |
| 143 | |
| 144 | user@host$ cmt --change interface get host=r34n26 iftype=iDRAC6 set hwaddress=A4:BA:DB:00:31:F6 |
| 145 | }}} |
| 146 | |
| 147 | This 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 | |
| 151 | For example new chassis in rack 2, 13, and 36: |
| 152 | |
| 153 | {{{ |
| 154 | user@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 | |
| 165 | And all hardware in these chassis: |
| 166 | |
| 167 | {{{ |
| 168 | user@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 | |
| 182 | Render a template to generate a config-file or a report. Use the following syntax: |
| 183 | |
| 184 | {{{ |
| 185 | sara_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 | {{{ |
| 193 | user@host$ cmt --generate cfrun_hosts.clearspeed |
| 194 | }}} |
| 195 | Which 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 | |
| 212 | outputdir=/data/cfengine/output/clearspeed |
| 213 | maxchild=8 |
| 214 | login1 |
| 215 | gb-r50n1.irc.sara.nl |
| 216 | gb-r50n2.irc.sara.nl |
| 217 | gb-r50n3.irc.sara.nl |
| 218 | gb-r50n4.irc.sara.nl |
| 219 | gb-r50n5.irc.sara.nl |
| 220 | gb-r50n6.irc.sara.nl |
| 221 | gb-r50n7.irc.sara.nl |
| 222 | gb-r50n8.irc.sara.nl |
| 223 | gb-r51n1.irc.sara.nl |
| 224 | gb-r51n2.irc.sara.nl |
| 225 | gb-r51n3.irc.sara.nl |
| 226 | gb-r51n4.irc.sara.nl |
| 227 | gb-r51n5.irc.sara.nl |
| 228 | gb-r51n6.irc.sara.nl |
| 229 | gb-r51n7.irc.sara.nl |
| 230 | gb-r51n8.irc.sara.nl |
| 231 | }}} |
| 232 | |
| 233 | |