//
// ResourceGroupCategory.c++
//
// Category for resource groups.
//
//
// Copyright (c) 1998, 2000 Silicon Graphics, Inc. All Rights Reserved.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of version 2.1 of the GNU Lesser General Public
// License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it would be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// Further, this software is distributed without any warranty that it is
// free of the rightful claim of any third person regarding infringement
// or the like. Any license provided herein, whether implied or
// otherwise, applies only to this software file. Patent licenses, if
// any, provided herein do not apply to combinations of this program
// with other software, or any other product whatsoever.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307,
// USA.
//
// Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
// Mountain View, CA 94043, or http://www.sgi.com/
//
// For further information regarding this notice, see:
// http://oss.sgi.com/projects/GenInfo/NoticeExplan/
//
#ident "$Revision: 1.12 $"
#include <stdio.h>
#include <ci_clikeys.h>
#include <ci_camvalues.h>
#include <ci_err.h>
#include <ci_nlist.h>
#include <fs_param.h>
#include <fs_client.h>
#include <sysadm/Log.h>
#include <fsmgr/ResourceGroupCategory.h>
namespace fsmgr {
SaCATEGORY_REF_DEF(ResourceGroupCategory);
ResourceGroupCategory::ResourceGroupCategory()
: CamCategory("ResourceGroupCategory", cam_category_resource_group)
{
addCategory(cam_category_resource_group_status);
}
//
// void ResourceGroupCategory::modifyItemOnCamEvent(Item* item)
//
// Description:
// Synthesize status attributes.
//
// Parameters:
// item Item for which to derive any additional attributes
//
void ResourceGroupCategory::modifyItemOnCamEvent(Item* item)
{
CamCategory::modifyItemOnCamEvent(item);
Attribute statusAttr(item->getAttr(CICLI_RG_STATUS_STATE));
const char* status = NULL;
long long state = STATE_NULL;
if (statusAttr == Attribute::NUL) {
Log::warning(getSelector(),
"%s: Missing attribute for "
"\"CICLI_RG_STATUS_STATE\"",
(const char *)(item->getSelector()));
status = STATUS_UNKNOWN;
state = STATE_UNKNOWN;
} else {
switch ((fs_resgroup_state_t)(statusAttr.longValue())) {
case FS_RG_STATE_ONLINE:
status = STATUS_ONLINE;
state = STATE_ONLINE;
break;
case FS_RG_STATE_MAINTENANCE:
status = STATUS_MAINTENANCE;
state = STATE_MAINTENANCE;
break;
case FS_RG_STATE_OFFLINE:
case FS_RG_STATE_OFFLINE_PERM:
status = STATUS_OFFLINE;
state = STATE_OFFLINE;
break;
case FS_RG_STATE_ONLINE_READY:
status = STATUS_ONLINE_READY;
state = STATE_ONLINE_READY;
break;
case FS_RG_STATE_PENDING:
case FS_RG_STATE_ONLINE_PENDING:
case FS_RG_STATE_ACTION_PENDING:
case FS_RG_STATE_EXCLUSIVITY:
case FS_RG_STATE_INITIALIZING:
status = STATUS_ONLINE_PENDING;
state = STATE_ONLINE_PENDING;
break;
case FS_RG_STATE_OFFLINE_PENDING:
status = STATUS_OFFLINE_PENDING;
state = STATE_OFFLINE_PENDING;
break;
case FS_RG_STATE_BAD:
case FS_RG_STATE_INTERNAL_ERROR:
status = STATUS_ERROR;
state = STATE_UNKNOWN;
break;
default:
Log::warning(getSelector(),
"%s: Unrecognized value for "
"\"CICLI_RG_STATUS_STATE\": %d",
(const char *)(item->getSelector()),
statusAttr.longValue());
status = STATUS_UNKNOWN;
state = STATE_UNKNOWN;
}
}
Attribute error(item->getAttr(CICLI_RG_ERROR));
if (error != Attribute::NUL && error.longValue() != 0) {
status = STATUS_ERROR;
}
if(status == NULL) Log::fatal(getSelector(), "status == NULL");
if(state == STATE_NULL) Log::fatal(getSelector(), "state == STATE_NULL");
item->setAttr(Attribute(STATUS_KEY, status));
item->setAttr(Attribute(STATE_KEY, state));
}
} // namespace fsmgr
using namespace fsmgr;