| 1 | <!-- Musings on how to define a change flow, using templated changes --> |
|---|
| 2 | |
|---|
| 3 | <!-- |
|---|
| 4 | If we have templated changes, then we basically just want to join |
|---|
| 5 | them together using chaining to create a change dependency tree. |
|---|
| 6 | |
|---|
| 7 | We then wish to apply each change with a dictionary.. actually, an |
|---|
| 8 | iterator which runs over 1..n dictionaries, but applied only to |
|---|
| 9 | that change. |
|---|
| 10 | |
|---|
| 11 | Ok.. so we have change templates defined. We can name the iterator |
|---|
| 12 | variable for each change based on its name, eg: |
|---|
| 13 | |
|---|
| 14 | <change name="change_does_something" type="CommandChange" iterator="%(iter_change_does_something)s"> |
|---|
| 15 | |
|---|
| 16 | This requires us to do substitution processing on the change attributes, |
|---|
| 17 | such as 'iterator' in order to determine the actual iterator to use. |
|---|
| 18 | We then look up the iterator in the namespace available in the |
|---|
| 19 | context above the change. |
|---|
| 20 | |
|---|
| 21 | Ah, bugger, no we can't. Namespaces are defined within the change |
|---|
| 22 | definition itself, so unless we create multiple different namespaces, |
|---|
| 23 | we're not really doing this right. |
|---|
| 24 | |
|---|
| 25 | What we want to be able to do is use the same change template with |
|---|
| 26 | multiple, different iterators, or namespaces. So, we want to be |
|---|
| 27 | able to define a skeleton change template and fill in some of the |
|---|
| 28 | variables elsewhere, by joining the components together. |
|---|
| 29 | |
|---|
| 30 | For example, we might have 2 lists of volumes to be created, one |
|---|
| 31 | on 'device_a', and one on 'device_b'. The list of volumes would |
|---|
| 32 | be defined in an iterator, called 'vol_iter' say; the devices |
|---|
| 33 | would be defined in 2 namespaces. |
|---|
| 34 | |
|---|
| 35 | So we need to be able to do 3 things: |
|---|
| 36 | 1. Set the namespace for a templated change at runtime. |
|---|
| 37 | 2. Set the iterator for a templated change at runtime. |
|---|
| 38 | 3. Use the one change template definition multiple times, with |
|---|
| 39 | different namespaces and iterators. |
|---|
| 40 | |
|---|
| 41 | Let's have a go at defining this mechanism... |
|---|
| 42 | |
|---|
| 43 | <change usetemplate='template_name' iterator='blah' namespace='blah'/> |
|---|
| 44 | |
|---|
| 45 | While we're at it, we could use a different mechanism from below |
|---|
| 46 | for defining dependencies. |
|---|
| 47 | |
|---|
| 48 | |
|---|
| 49 | <change> |
|---|
| 50 | <depends on='changename'/> |
|---|
| 51 | <depends on='change2'/> |
|---|
| 52 | </change> |
|---|
| 53 | |
|---|
| 54 | Ok. So now we need the difference between a 'change' and a 'changetemplate'. |
|---|
| 55 | Well, there isn't one, except that one is defined via <change/> |
|---|
| 56 | and the other by <changetemplate/>. |
|---|
| 57 | |
|---|
| 58 | Ok, so now we can define a generic change and use namespaces to vary |
|---|
| 59 | which devices it gets applied to thus: |
|---|
| 60 | |
|---|
| 61 | <target>%(change_specific_target)s</target> |
|---|
| 62 | |
|---|
| 63 | but how do we specify the prereqs, in order to create our change tree? |
|---|
| 64 | |
|---|
| 65 | Currently they are defined inside the change template itself, but this |
|---|
| 66 | is not ideal if we want to be able to use a more modular approach and |
|---|
| 67 | define change templates as building blocks and *then* chain them together. |
|---|
| 68 | |
|---|
| 69 | Namespaces again? No, because we may wish to define multiple prereqs, |
|---|
| 70 | not just the name(s) of a specific number of changes. So, we need a |
|---|
| 71 | mechanism that will be processed after all other stuff is loaded in order |
|---|
| 72 | to build the dependency tree... |
|---|
| 73 | |
|---|
| 74 | Aha! A dependency tree! That's just XML.. so... |
|---|
| 75 | |
|---|
| 76 | <dependencies> |
|---|
| 77 | <before changename='change4'> |
|---|
| 78 | <require changename='change3'/> |
|---|
| 79 | <require changename='change2'/> |
|---|
| 80 | </before> |
|---|
| 81 | |
|---|
| 82 | <before changename='change9'> |
|---|
| 83 | <require changename='change2'/> |
|---|
| 84 | </before> |
|---|
| 85 | |
|---|
| 86 | </dependencies> |
|---|
| 87 | |
|---|
| 88 | So, that should take care of post-processing dependency trees. |
|---|
| 89 | If any prereqs are defined within a change template, it will be |
|---|
| 90 | overridden by any post-processed dependencies. |
|---|
| 91 | |
|---|
| 92 | --> |
|---|
| 93 | |
|---|
| 94 | <config xmlns:xi="http://www.w3.org/2001/XInclude"> |
|---|
| 95 | |
|---|
| 96 | |
|---|
| 97 | </config> |
|---|