| 1 | <?xml version="1.0" encoding="UTF-8" standalone="no" ?> |
|---|
| 2 | |
|---|
| 3 | <!-- A demo configuration file for configuring a changeset --> |
|---|
| 4 | <config xmlns:xi="http://www.w3.org/2001/XInclude"> |
|---|
| 5 | |
|---|
| 6 | <!-- |
|---|
| 7 | A global change namespace, used to define commonly used items. |
|---|
| 8 | You can use this to define variables that can be substituted in |
|---|
| 9 | common places below. This provides a mechanism for templating changes. |
|---|
| 10 | |
|---|
| 11 | All values are strings. If you need to convert to a python number, |
|---|
| 12 | do this in the python code, via int(), float() etc. |
|---|
| 13 | |
|---|
| 14 | --> |
|---|
| 15 | <namespace> |
|---|
| 16 | <entry name='var1'>This is the variable value</entry> |
|---|
| 17 | <entry name='var2'>Another globally available value</entry> |
|---|
| 18 | </namespace> |
|---|
| 19 | |
|---|
| 20 | <xi:include href="subchange.conf"/> |
|---|
| 21 | |
|---|
| 22 | <provisioner |
|---|
| 23 | name='prov1' |
|---|
| 24 | type='MultiConnectingProvisioner'> |
|---|
| 25 | |
|---|
| 26 | <command>ssh -i /home/daedalus/.ssh/localconnect -o BatchMode=yes %(device.name)s "%(command.send)s"</command> |
|---|
| 27 | |
|---|
| 28 | <!-- This is a provisioner specific namespace. It can be accessed by |
|---|
| 29 | all changes that use this provisioner. |
|---|
| 30 | --> |
|---|
| 31 | <namespace> |
|---|
| 32 | <entry name='var1'>This is the variable value</entry> |
|---|
| 33 | <entry name='var2'>Another globally available value</entry> |
|---|
| 34 | </namespace> |
|---|
| 35 | |
|---|
| 36 | </provisioner> |
|---|
| 37 | |
|---|
| 38 | <device name='localhost'> |
|---|
| 39 | <fqdn/> |
|---|
| 40 | <ipaddress>127.0.0.1</ipaddress> |
|---|
| 41 | |
|---|
| 42 | <!-- This is a device specific namespace. It can be accessed by |
|---|
| 43 | all changes that use this device as a target. |
|---|
| 44 | --> |
|---|
| 45 | <namespace/> |
|---|
| 46 | |
|---|
| 47 | </device> |
|---|
| 48 | |
|---|
| 49 | <change name='change1' |
|---|
| 50 | type='CommandChange'> |
|---|
| 51 | |
|---|
| 52 | <!-- This is a change specific namespace. --> |
|---|
| 53 | <namespace/> |
|---|
| 54 | |
|---|
| 55 | <useprov>prov1</useprov> |
|---|
| 56 | |
|---|
| 57 | <target>localhost</target> |
|---|
| 58 | |
|---|
| 59 | <preimpl> |
|---|
| 60 | <command> |
|---|
| 61 | <send>echo hello</send> |
|---|
| 62 | </command> |
|---|
| 63 | </preimpl> |
|---|
| 64 | |
|---|
| 65 | <impl> |
|---|
| 66 | <command> |
|---|
| 67 | <send>echo 'I am implementing a change'</send> |
|---|
| 68 | </command> |
|---|
| 69 | <command> |
|---|
| 70 | <send>sleep 1</send> |
|---|
| 71 | </command> |
|---|
| 72 | <command> |
|---|
| 73 | <send>echo 'It is done.'</send> |
|---|
| 74 | </command> |
|---|
| 75 | </impl> |
|---|
| 76 | |
|---|
| 77 | <postimpl> |
|---|
| 78 | <!-- |
|---|
| 79 | A condition is used to check the output of a set of commands and |
|---|
| 80 | determine if the commands were successfully implemented. |
|---|
| 81 | If multiple conditions exist, all of them must evaluate to True |
|---|
| 82 | for the commands to be deemed successful. |
|---|
| 83 | It is a python expression that will be evaluated against a namespace |
|---|
| 84 | containing the final exitcode for the command, as well as the results |
|---|
| 85 | of the commands as a string: |
|---|
| 86 | exitcode == The exitcode of the final command |
|---|
| 87 | cmdoutput == The complete output from STDOUT and STDERR from all commands. |
|---|
| 88 | |
|---|
| 89 | Also available in the namespace are some useful modules, such as 're' and 'time'. |
|---|
| 90 | --> |
|---|
| 91 | <condition>exitcode == 14</condition> |
|---|
| 92 | <command> |
|---|
| 93 | <send>echo 'testing postimplementation'</send> |
|---|
| 94 | </command> |
|---|
| 95 | <command> |
|---|
| 96 | <send>echo 'in two commands'</send> |
|---|
| 97 | </command> |
|---|
| 98 | </postimpl> |
|---|
| 99 | |
|---|
| 100 | <backout> |
|---|
| 101 | <command> |
|---|
| 102 | <send>echo "I am backing out"</send> |
|---|
| 103 | </command> |
|---|
| 104 | <command> |
|---|
| 105 | <send>echo "the change in two commands"</send> |
|---|
| 106 | </command> |
|---|
| 107 | |
|---|
| 108 | </backout> |
|---|
| 109 | |
|---|
| 110 | </change> |
|---|
| 111 | |
|---|
| 112 | <change name='change2' |
|---|
| 113 | type='CommandChange'> |
|---|
| 114 | <useprov>prov1</useprov> |
|---|
| 115 | |
|---|
| 116 | <target>localhost</target> |
|---|
| 117 | |
|---|
| 118 | <!-- |
|---|
| 119 | optional 0 to n changes that must complete successfully before |
|---|
| 120 | attempting this change. |
|---|
| 121 | <prereq>change1</prereq> |
|---|
| 122 | --> |
|---|
| 123 | |
|---|
| 124 | <impl> |
|---|
| 125 | <command> |
|---|
| 126 | <send>echo "I am implementing change 2"</send> |
|---|
| 127 | </command> |
|---|
| 128 | </impl> |
|---|
| 129 | |
|---|
| 130 | </change> |
|---|
| 131 | |
|---|
| 132 | <prereq for="change2">change1</prereq> |
|---|
| 133 | |
|---|
| 134 | <iterator name="iterator_1"> |
|---|
| 135 | <dict> |
|---|
| 136 | <entry name="ns_1">val_1</entry> |
|---|
| 137 | <entry name="ns_2">val_2</entry> |
|---|
| 138 | </dict> |
|---|
| 139 | |
|---|
| 140 | <dict> |
|---|
| 141 | <entry name="ns_1">val_3</entry> |
|---|
| 142 | <entry name="ns_2">val_4</entry> |
|---|
| 143 | </dict> |
|---|
| 144 | |
|---|
| 145 | </iterator> |
|---|
| 146 | |
|---|
| 147 | </config> |
|---|