109 | | |
110 | | == Change object(s): `-c, --change` == |
| 113 | === List object(s): `-l, --list` === |
| 114 | |
| 115 | Use 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: |
| 116 | |
| 117 | {{{ |
| 118 | cmt_sara --list <entity> [get] <query> |
| 119 | }}} |
| 120 | |
| 121 | ==== Use case ==== |
| 122 | |
| 123 | '''If you need to figure out where a machine -- in this case `test3` -- is physically hosted:''' |
| 124 | |
| 125 | When 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: |
| 126 | |
| 127 | {{{ |
| 128 | user@host$ cmt --list hardwareunit label=test3 |
| 129 | }}} |
| 130 | |
| 131 | The output of this command looks like: |
| 132 | |
| 133 | {{{ |
| 134 | .---[ test3 ]--- |
| 135 | : cluster : LDAP/CUA |
| 136 | : address : Amsterdam - Science Park 121 |
| 137 | : room : S142A |
| 138 | : rack : rack AD38 |
| 139 | : first_slot : 23 |
| 140 | : specifications : PowerEdge 1950 (Dell bv) |
| 141 | : roles : administration |
| 142 | : in_support : True |
| 143 | '--- |
| 144 | }}} |
| 145 | |
| 146 | === Change object(s): `-c, --change` === |
179 | | |
180 | | == Generate a config-file: `-g, --generate` == |
| 215 | === Remove object(s): `-r, --remove` === |
| 216 | |
| 217 | Use 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: |
| 218 | |
| 219 | {{{ |
| 220 | sara_cmt --remove <entity> [get] <query> |
| 221 | }}} |
| 222 | |
| 223 | ==== Use case ==== |
| 224 | |
| 225 | '''You have removed a server from a rack:''' |
| 226 | |
| 227 | For example the first node in rack 2: |
| 228 | |
| 229 | {{{ |
| 230 | user@host$ cmt --remove hardwareunit rack=2 first_slot=1 |
| 231 | INFO remove 233 :: Found 1 objects matching query: r2n1 |
| 232 | Are you sure? [Yn] |
| 233 | }}} |
| 234 | |
| 235 | As you can see there will be asked for confirmation by default. |
| 236 | |
| 237 | |
| 238 | == Other options == |
| 239 | |
| 240 | === Dry-run: `-n, --dry-run === |
| 241 | |
| 242 | Use this option to suppress (CRUD-)actions that make changes to the database. Please note, this option has to be given ''before'' CRUD-options. So, use it like: |
| 243 | |
| 244 | {{{ |
| 245 | user@host$ cmt --dry-run --{add,list,change,remove} ENTITY ... |
| 246 | }}} |
| 247 | |
| 248 | This option can become handy when you first want to test a command that'll have a big impact. |
| 249 | |
| 250 | ==== Use case ==== |
| 251 | |
| 252 | You're replacing all compute-nodes in a couple of racks (2-5), and want to test your command to remove the old hardware from CMT: |
| 253 | |
| 254 | {{{ |
| 255 | user@host$ cmt --dry-run --remove hardwareunit rack={2,3,4,5} role=computenode |
| 256 | }}} |
| 257 | |
| 258 | {{{#!comment |
| 259 | === Non-interactive run: `--script === |
| 260 | |
| 261 | Sometimes you don't want to interact with CMT, after issuing a command. For example, when CMT is executed unattended from scripts. Syntax is like: |
| 262 | |
| 263 | {{{ |
| 264 | user@host$ cmt --script --{add,list,change,remove} ENTITY ... |
| 265 | }}} |
| 266 | |
| 267 | ==== Use case ==== |
| 268 | |
| 269 | {{{ |
| 270 | |
| 271 | }}} |
| 272 | }}} |
| 273 | |
| 274 | === Generate a config-file: `-g, --generate` === |
232 | | |
233 | | |
234 | | == List object(s): `-l, --list` == |
235 | | |
236 | | Use 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 | | {{{ |
239 | | cmt_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 | | |
246 | | When 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 | | {{{ |
249 | | user@host$ cmt --list hardwareunit label=test3 |
250 | | }}} |
251 | | |
252 | | The 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 | | }}} |