| 1 | = ShopDL = |
| 2 | |
| 3 | [[[TOC]]] |
| 4 | |
| 5 | ShopDL is a command-line tool for manipulating TopDL files. |
| 6 | |
| 7 | It can be invoked by running the following command on users: |
| 8 | {{{ |
| 9 | $ /share/benito/util/shopdl.py <topo.xml> |
| 10 | }}} |
| 11 | |
| 12 | Once it begins you will be in an interactive shell. At any time you may run the {{{help}}} command to see the online documentation. You can also ask for help for specific commands. |
| 13 | {{{ |
| 14 | shopdl> help |
| 15 | Commands: annotate attributes list save strip |
| 16 | |
| 17 | shopdl> help annotate |
| 18 | Annotates topdl.Computer elements |
| 19 | Usage: annotate <name=value> <regex-for-node-name> |
| 20 | }}} |
| 21 | |
| 22 | Throughout this documentation I'll be running through some examples with a sample TopDL file. Download the attached {{{two_nodes.xml}}} in order to follow along. |
| 23 | |
| 24 | == Regular Expressions == |
| 25 | |
| 26 | Commands which take an argument for a node name always accept regular expressions. This is important to remember when nodes have similar names. For instance the following regular expression will match both {{{bot-10}}} '''and''' {{{bot-100}}}: |
| 27 | |
| 28 | {{{ |
| 29 | bot-10 |
| 30 | }}} |
| 31 | |
| 32 | If you wish to limit your results to only matching bot-10, you should use a regular expression such as the following: |
| 33 | |
| 34 | {{{ |
| 35 | bot-10$ |
| 36 | }}} |
| 37 | |
| 38 | == Commands == |
| 39 | |
| 40 | === Listing Information === |
| 41 | |
| 42 | The two commands used to list information are {{{list}}} and {{{attributes}}}, which list nodes and their attributes respectively. |
| 43 | |
| 44 | {{{ |
| 45 | shopdl> list |
| 46 | node-1 |
| 47 | node-2 |
| 48 | |
| 49 | shopdl> attributes .* |
| 50 | node-1: |
| 51 | type: pc2133 |
| 52 | failureaction: fatal |
| 53 | node-2: |
| 54 | type: pc2133 |
| 55 | failureaction: fatal |
| 56 | }}} |
| 57 | |
| 58 | The attributes listed above are not meaningful to Benito. They are present because this TopDL file was automatically converted from NS. |
| 59 | |
| 60 | === Adding, Modifying, and Deleting === |
| 61 | |
| 62 | The modification commands are {{{annotate}}} and {{{strip}}}, which add/modify attributes and remove them respectively. {{{strip}}} will also remove attributes from substrates, heyoo. |
| 63 | |
| 64 | Note that a node or substrate can only have one attribute for a given name. Assigning a new value to an existing attribute will overwrite the previous value. |
| 65 | |
| 66 | {{{ |
| 67 | shopdl> annotate benito:node_type=qemu node-1$ |
| 68 | Annotated 1 node |
| 69 | shopdl> annotate benito:node_type=embedded_pnode node-2$ |
| 70 | Annotated 1 node |
| 71 | |
| 72 | shopdl> attributes node-.* |
| 73 | node-1: |
| 74 | type: pc2133 |
| 75 | failureaction: fatal |
| 76 | benito:node_type: qemu |
| 77 | node-2: |
| 78 | type: pc2133 |
| 79 | failureaction: fatal |
| 80 | benito:node_type: embedded_pnode |
| 81 | }}} |
| 82 | |
| 83 | Note also that you can quote the attribute name and value according to shell quoting rules. This allows you to embed spaces. |
| 84 | |
| 85 | {{{ |
| 86 | shopdl> strip benito:node_type node-.* |
| 87 | Removed 2 attributes (searched 2 nodes) |
| 88 | Removed 0 attributes (searched 1 substrate) |
| 89 | }}} |
| 90 | |
| 91 | Again remember that {{{strip}}} will remove attributes from substrates as well as nodes. |
| 92 | |
| 93 | === Save and/or Quit === |
| 94 | |
| 95 | Save your results using {{{save}}}, quit using {{{quit}}}. {{{save}}} takes an optional parameter to specify output file. |