--- LVM	2011-04-19 15:43:17.000000000 +0200
+++ LVM.new	2011-04-19 15:44:26.000000000 +0200
@@ -89,6 +89,23 @@
 <content type="string" default="false" />
 </parameter>
 
+<parameter name="set_hosttag" unique="0" required="0">
+<longdesc lang="en">
+This enables a more secure LVM failover (HA LVM).
+The volume group will be tagged with the hostname reported by "uname -n".
+A volume group is only activated if it matches an item in the list.
+But all active volume groups will stay active until they are deactivated once,
+so make sure to deactivate any active volume group.
+To use this feature some manual changes need to be done.
+It is necessary to enable the hosttags first /etc/lvm/lvm.conf:
+tags { hosttags = 1 }
+Create a file lvm_"hostname".conf on each node
+"activation { volume_list = [ "rootvg", "@nodeA" ] }".
+</longdesc>
+<shortdesc lang="en">Set a hosttag on the volume group</shortdesc>
+<content type="boolean" default="false"/>
+</parameter>
+
 </parameters>
 
 <actions>
@@ -214,6 +231,29 @@
 	partial_active="--partial"
   fi
 
+  if ocf_is_true "$OCF_RESKEY_set_hosttag" ; then
+	if [ $(vgs --noheadings -o vg_tags $1 | wc -w) -ge 1 ]; then
+		IFS=','
+		ocf_log info "Removing tags from volume group $1"
+		# Remove all tags
+		for vgtag in $(vgs --noheadings -o vg_tags $1 | tr -d ' '); do
+			ocf_run vgchange --deltag ${vgtag} $1
+		done
+		unset IFS
+	fi
+	# Check if all tags are removed
+	if [ $(vgs --noheadings -o vg_tags $1 | wc -w) -ge 1 ]; then
+		ocf_log err "LVM: $1 has still active tags"
+		return $OCF_ERR_GENERIC
+	fi
+	ocf_log info "Set tag $(uname -n) on volume group $1"
+	ocf_run vgchange --addtag $(uname -n) $1
+	if [ $(vgs --noheadings -o vg_tags newvg | tr -d ' ') != $(uname -n) ]; then
+		ocf_log err "LVM: $1 tag does not match to $(uname -n)"
+		return $OCF_ERR_GENERIC
+	fi
+  fi	
+
   ocf_run vgchange -a $active_mode $partial_active $1 || return $OCF_ERR_GENERIC
 
   if LVM_status $1; then
