Show
Ignore:
Timestamp:
26/11/07 20:14:17 (2 years ago)
Author:
daedalus
Message:

* Refactored code to permit more flexible templating of changes. You can now

define a <changetemplate/> in 95% the same way as a <change/>, and then
refer to a <changetemplate/> when defining a <change/> to allow you to
combine change templates as a change flow, using namespaces and iterators
for each one.

* Some work on manual bailout in authoritarian mode, but it isn't completely

bailing out immediately yet, due to some complexities in the deferred chains
that I haven't quite unravelled.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/etc/netapp-provision-demo.xml

    r27 r28  
    1212   
    1313--> 
     14<!-- include change templates I want to use --> 
     15<xi:include href="netapp-create-volume.change-template.xml"/> 
    1416 
     17<!-- define my provisioner --> 
    1518<provisioner 
    1619  name='netapp_provisioner' 
    1720  type='MultiConnectingProvisioner' 
    18   command_timeout='5'> 
     21  command_timeout='30'> 
    1922 
    2023  <command>ssh -i /home/daedalus/.ssh/configulator -o BatchMode=yes -o ServerAliveInterval=0 root@%(device.ipaddress)s "%(command.send)s"</command> 
     
    2629</provisioner> 
    2730 
     31<!-- define some devices I want to provision to --> 
    2832<device name='wibble'> 
    2933  <ipaddress>10.232.8.71</ipaddress> 
     
    3438</device> 
    3539 
    36 <!-- define some namespace entities that I need for the changes --> 
    37 <namespace> 
    38   <entry name='primary_filer'>wibble</entry> 
    39   <entry name='secondary_filer'>wibble</entry> 
    40  
    41   <entry name='vfiler_name'>vf_demo</entry> 
    42  
    43   <entry name='root_aggr'>aggr01</entry> 
    44   <entry name='root_vol_size'>20m</entry> 
    45  
    46 </namespace> 
    47  
    48 <iterator name="project_volumes"> 
     40<!-- Define iterators used by changes --> 
     41<iterator name="primary_volumes"> 
    4942  <dict> 
    50     <entry name="volnum">00</entry> 
     43    <entry name="volname">prim_root</entry> 
    5144    <entry name="volaggr">aggr01</entry> 
    5245    <entry name="volsize">25m</entry> 
     
    5447 
    5548  <dict> 
    56     <entry name="volnum">01</entry> 
     49    <entry name="volname">prim_vol01</entry> 
    5750    <entry name="volaggr">aggr01</entry> 
    5851    <entry name="volsize">25m</entry> 
     
    6154</iterator> 
    6255 
    63 <change name="create_root_volume_primary" type="CommandChange" onfail='continue'> 
     56<iterator name="secondary_volumes"> 
     57  <dict> 
     58    <entry name="volname">sec_root</entry> 
     59    <entry name="volaggr">aggr01</entry> 
     60    <entry name="volsize">25m</entry> 
     61  </dict> 
    6462 
    65   <target>%(primary_filer)s</target> 
     63  <dict> 
     64    <entry name="volname">sec_vol01</entry> 
     65    <entry name="volaggr">aggr01</entry> 
     66    <entry name="volsize">25m</entry> 
     67  </dict> 
    6668 
    67   <preimpl> 
    68     <command> 
    69       <send>vol status %(vfiler_name)s_root</send> 
    70     </command> 
     69</iterator> 
    7170 
    72     <condition>cmdoutput.find("No volume named '%(vfiler_name)s_root' exists.") >= 0</condition> 
    73  
    74   </preimpl> 
    75  
    76   <impl> 
    77     <command> 
    78       <send>vol create %(vfiler_name)s_root %(root_aggr)s %(root_vol_size)s</send> 
    79     </command> 
    80  
    81     <condition>cmdoutput.find("Creation of volume") >= 0</condition> 
    82     <condition>cmdoutput.find("has completed") >= 0</condition> 
    83  
    84   </impl> 
    85  
    86   <backout> 
    87     <command> 
    88       <send>vol offline %(vfiler_name)s_root</send> 
    89     </command> 
    90  
    91     <command> 
    92       <expect>Volume '%(vfiler_name)s_root' has been set temporarily offline</expect> 
    93       <send>vol destroy %(vfiler_name)s_root -f</send> 
    94     </command> 
    95  
    96     <condition>cmdoutput.find("Volume '%(vfiler_name)s_root' destroyed") >= 0</condition> 
    97  
    98   </backout> 
    99  
     71<!-- Set up the change list I want to apply --> 
     72<change name="create_primary_volumes" template='create_netapp_volume' iterator='primary_volumes'> 
     73  <target>wibble</target> 
    10074</change> 
    10175 
    102 <change name="create_project_volume_primary" type="CommandChange" iterator="project_volumes" 
    103   onfail='retry' max_retries='2'> 
    104  
    105   <prereq>create_root_volume_primary</prereq> 
    106  
    107   <target>%(primary_filer)s</target> 
    108  
    109   <preimpl> 
    110     <command> 
    111       <send>vol status %(vfiler_name)s_vol%(volnum)s</send> 
    112     </command> 
    113  
    114     <condition>cmdoutput.find("No volume named '%(vfiler_name)s_vol%(volnum)s' exists.") >= 0</condition> 
    115  
    116   </preimpl> 
    117  
    118   <impl> 
    119     <command> 
    120       <send>vol create %(vfiler_name)s_vol%(volnum)s %(volaggr)s %(volsize)s</send> 
    121     </command> 
    122  
    123     <condition>cmdoutput.find("Creation of volume") >= 0</condition> 
    124     <condition>cmdoutput.find("has completed") >= 0</condition> 
    125  
    126   </impl> 
    127  
    128   <backout> 
    129     <command> 
    130       <send>vol offline %(vfiler_name)s_vol%(volnum)s</send> 
    131     </command> 
    132  
    133     <command> 
    134       <expect>Volume '%(vfiler_name)s_vol%(volnum)s' has been set temporarily offline</expect> 
    135       <send>vol destroy %(vfiler_name)s_vol%(volnum)s -f</send> 
    136     </command> 
    137  
    138     <condition>cmdoutput.find("Volume '%(vfiler_name)s_vol%(volnum)s' destroyed") >= 0</condition> 
    139  
    140   </backout> 
    141  
     76<change name="create_secondary_volumes" template='create_netapp_volume' iterator='secondary_volumes'> 
     77  <target>wibble</target> 
     78  <depends on='create_primary_volumes'/> 
    14279</change> 
    14380 
    144  
    145 <!-- 
    146 <change name="test_iterator" type="CommandChange" iterator="iter1"> 
    147  
    148   <prereq>None</prereq> 
    149  
    150   <target>wibble</target> 
    151  
    152   <preimpl> 
    153     <command> 
    154       <send>vol status %(volname)s</send> 
    155     </command> 
    156  
    157     <condition>cmdoutput.find("No volume named '%(volname)s' exists.") >= 0</condition> 
    158  
    159   </preimpl> 
    160  
    161 </change> 
    162 --> 
    163  
    16481</config>