From owner-svn-src-head@FreeBSD.ORG Sun Aug 29 21:42:45 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7CABD10656BA; Sun, 29 Aug 2010 21:42:45 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 51ECE8FC12; Sun, 29 Aug 2010 21:42:45 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o7TLgj2w075327; Sun, 29 Aug 2010 21:42:45 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o7TLgjgo075324; Sun, 29 Aug 2010 21:42:45 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201008292142.o7TLgjgo075324@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Sun, 29 Aug 2010 21:42:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r211978 - head/sbin/hastd X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2010 21:42:45 -0000 Author: pjd Date: Sun Aug 29 21:42:45 2010 New Revision: 211978 URL: http://svn.freebsd.org/changeset/base/211978 Log: - Call hook on role change. - Document new event. MFC after: 2 weeks Obtained from: Wheel Systems Sp. z o.o. http://www.wheelsystems.com Modified: head/sbin/hastd/control.c head/sbin/hastd/hast.conf.5 Modified: head/sbin/hastd/control.c ============================================================================== --- head/sbin/hastd/control.c Sun Aug 29 21:41:53 2010 (r211977) +++ head/sbin/hastd/control.c Sun Aug 29 21:42:45 2010 (r211978) @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$"); #include "hast.h" #include "hastd.h" #include "hast_proto.h" +#include "hooks.h" #include "nv.h" #include "pjdlog.h" #include "proto.h" @@ -54,6 +55,7 @@ static void control_set_role_common(struct hastd_config *cfg, struct nv *nvout, uint8_t role, struct hast_resource *res, const char *name, unsigned int no) { + int oldrole; /* Name is always needed. */ if (name != NULL) @@ -85,6 +87,7 @@ control_set_role_common(struct hastd_con pjdlog_info("Role changed to %s.", role2str(role)); /* Change role to the new one. */ + oldrole = res->hr_role; res->hr_role = role; pjdlog_prefix_set("[%s] (%s) ", res->hr_name, role2str(res->hr_role)); @@ -113,6 +116,8 @@ control_set_role_common(struct hastd_con if (role == HAST_ROLE_PRIMARY) hastd_primary(res); pjdlog_prefix_set("%s", ""); + hook_exec(res->hr_exec, "role", res->hr_name, role2str(oldrole), + role2str(res->hr_role), NULL); } void Modified: head/sbin/hastd/hast.conf.5 ============================================================================== --- head/sbin/hastd/hast.conf.5 Sun Aug 29 21:41:53 2010 (r211977) +++ head/sbin/hastd/hast.conf.5 Sun Aug 29 21:42:45 2010 (r211978) @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 27, 2010 +.Dd August 29, 2010 .Dt HAST.CONF 5 .Os .Sh NAME @@ -228,6 +228,10 @@ Executed on primary node when synchroniz interrupted, most likely due to secondary node outage or connection failure between the nodes. .Pp +.It Ic " role " +.Pp +Executed on both primary and secondary nodes when resource role is changed. +.Pp .El The .Aq path @@ -241,6 +245,22 @@ The .Aq resource argument is resource name from the configuration file. .Pp +The +.Aq oldrole +argument is previous resource role (before the change). +It can be one of: +.Ar init , +.Ar secondary , +.Ar primary . +.Pp +The +.Aq newrole +argument is current resource role (after the change). +It can be one of: +.Ar init , +.Ar secondary , +.Ar primary . +.Pp .It Ic name Aq name .Pp GEOM provider name that will appear as