# Copyright (C) 2009 Andrew Beekhof
# Copyright (C) 2015 Kristoffer Gronlund
#
# License: GNU General Public License (GPL)
version: 2.2
shortdesc: GFS2 File System (Cloned)
longdesc: >- 
  This template generates a cloned instance of the GFS2 file system.
  The file system should be on the device, unless cLVM is used.

category: File System
parameters:
  - name: id
    shortdesc: File System Resource ID
    longdesc: "NB: The clone is going to be named c-<id> (e.g. c-bigfs)"
    example: bigfs
    required: true
    type: resource
  - name: directory
    shortdesc: Mount Point
    example: /mnt/bigfs
    required: true
    type: string
  - name: device
    shortdesc: Device
    required: true
    type: string
  - name: options
    shortdesc: Mount Options
    type: string
    required: false
  - name: dlm
    shortdesc: Create DLM Resource and Cloned Group
    longdesc: If set, create the DLM resource and cloned resource group.
    type: boolean
    default: true
  - name: group
    shortdesc: Cloned Group Resource ID
    longdesc: ID of cloned group
    required: false
    type: resource
    default: g-dlm
actions:
  - when: dlm
    cib: |
      primitive dlm ocf:pacemaker:controld
        op start timeout=90
        op stop timeout=60
      group {{group}} dlm
      clone c-dlm {{group}} meta interleave=true
  - cib: |
      primitive {{id}} ocf:heartbeat:Filesystem
          directory="{{directory}}"
          fstype="gfs2"
          device="{{device}}"
          {{#options}}options="{{options}}"{{/options}}
          op start timeout=60s
          op stop timeout=60s
          op monitor interval=20s timeout=40s

  - crm: configure modgroup {{group}} add {{id}}
    shortdesc: Add the GFS2 File System to the Cloned Group
