<!-- 
     This change template can be used to create volumes on a NetApp filer.
     It expects an iterator called 'netapp_volume_iter' to be defined,
     which can be used to create multiple volumes.
-->

<changetemplate name="create_netapp_volume" type="CommandChange">

  <preimpl>
    <command>
      <send>vol status %(volname)s</send>
    </command>

    <condition>cmdoutput.find("No volume named '%(volname)s' exists.") >= 0</condition>

  </preimpl>

  <impl>
    <command>
      <send>vol create %(volname)s %(volaggr)s %(volsize)s</send>
    </command>

    <condition>cmdoutput.find("Creation of volume") >= 0</condition>
    <condition>cmdoutput.find("has completed") >= 0</condition>

  </impl>

  <backout>
    <command>
      <send>vol offline %(volname)s</send>
    </command>

    <command>
      <expect>Volume '%(volname)s' has been set temporarily offline</expect>
      <send>vol destroy %(volname)s -f</send>
    </command>

    <condition>cmdoutput.find("Volume '%(volname)s' destroyed") >= 0</condition>

  </backout>

</changetemplate>

