- Call hook on role change.

- Document new event.

MFC after:	2 weeks
Obtained from:	Wheel Systems Sp. z o.o. http://www.wheelsystems.com
This commit is contained in:
pjd 2010-08-29 21:42:45 +00:00
parent 70a52f0307
commit 1d4a51dd2d
2 changed files with 26 additions and 1 deletions

View File

@ -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_config *cfg, struct nv *nvout,
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_config *cfg, struct nv *nvout,
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

View File

@ -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 synchronization process of secondary node is
interrupted, most likely due to secondary node outage or connection failure
between the nodes.
.Pp
.It Ic "<path> role <resource> <oldrole> <newrole>"
.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