当前位置: 首页>>代码示例>>C++>>正文


C++ Ptr::ResolveGroupMembership方法代码示例

本文整理汇总了C++中servicegroup::Ptr::ResolveGroupMembership方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::ResolveGroupMembership方法的具体用法?C++ Ptr::ResolveGroupMembership怎么用?C++ Ptr::ResolveGroupMembership使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在servicegroup::Ptr的用法示例。


在下文中一共展示了Ptr::ResolveGroupMembership方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: EvaluateObjectRule

bool ServiceGroup::EvaluateObjectRule(const Service::Ptr service, const ObjectRule& rule)
{
	DebugInfo di = rule.GetDebugInfo();

	std::ostringstream msgbuf;
	msgbuf << "Evaluating 'object' rule (" << di << ")";
	CONTEXT(msgbuf.str());

	Host::Ptr host = service->GetHost();

	Dictionary::Ptr locals = make_shared<Dictionary>();
	locals->Set("host", host);
	locals->Set("service", service);

	if (!rule.EvaluateFilter(locals))
		return false;

	std::ostringstream msgbuf2;
	msgbuf2 << "Assigning membership for group '" << rule.GetName() << "' to service '" << service->GetName() << "' for rule " << di;
	Log(LogDebug, "icinga", msgbuf2.str());

	String group_name = rule.GetName();
	ServiceGroup::Ptr group = ServiceGroup::GetByName(group_name);

	if (!group) {
		Log(LogCritical, "icinga", "Invalid membership assignment. Group '" + group_name + "' does not exist.");
		return false;
	}

	/* assign service group membership */
	group->ResolveGroupMembership(service, true);

	return true;
}
开发者ID:nv1r,项目名称:icinga2,代码行数:34,代码来源:servicegroup.cpp

示例2: ResolveGroupMembership

bool ServiceGroup::ResolveGroupMembership(const Service::Ptr& service, bool add, int rstack) {

	if (add && rstack > 20) {
		Log(LogWarning, "ServiceGroup")
		    << "Too many nested groups for group '" << GetName() << "': Service '"
		    << service->GetName() << "' membership assignment failed.";

		return false;
	}

	Array::Ptr groups = GetGroups();

	if (groups && groups->GetLength() > 0) {
		ObjectLock olock(groups);

		for (const String& name : groups) {
			ServiceGroup::Ptr group = ServiceGroup::GetByName(name);

			if (group && !group->ResolveGroupMembership(service, add, rstack + 1))
				return false;
		}
	}

	if (add)
		AddMember(service);
	else
		RemoveMember(service);

	return true;
}
开发者ID:LMNetworks,项目名称:icinga2,代码行数:30,代码来源:servicegroup.cpp


注:本文中的servicegroup::Ptr::ResolveGroupMembership方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。