# Copyright (C) 2009 Dejan Muhamedagic
# Copyright (C) 2015 Kristoffer Gronlund
#
# License: GNU General Public License (GPL)
version: 2.2
category: File System
shortdesc: OCFS2 File System
longdesc: |
  Configure an OCFS2 File System resource and add
  it to a cloned DLM base group. OCFS2 uses the
  cluster membership services from Pacemaker which
  run in user space. Therefore, DLM needs to be
  configured as a clone resource that is present on
  each node in the cluster.

  The file system resource should be added to a cloned
  group which includes the DLM resource. This wizard
  can optionally create both the required DLM resource
  and the cloned group. The wizard can be reused to create
  additional OCFS2 file system resources by setting the
  group name to the name of an already-created cloned group.

  If you are using cLVM, create the DLM resource and clone
  group using the cLVM wizard. OCFS2 file system resources can
  then be added to the group using this wizard.

parameters:
  - name: id
    shortdesc: OCFS2 File System Resource ID
    example: bigfs
    type: resource
    required: true
  - name: directory
    shortdesc: Mount Point
    example: /mnt/bigfs
    type: string
    required: true
  - name: device
    shortdesc: Device
    type: string
    required: true
  - name: options
    shortdesc: Mount Options
    type: string
  - 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="ocfs2"
          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 OCFS2 File System to the Cloned Group
