本文整理汇总了C++中host::Ptr::AddGroup方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::AddGroup方法的具体用法?C++ Ptr::AddGroup怎么用?C++ Ptr::AddGroup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类host::Ptr
的用法示例。
在下文中一共展示了Ptr::AddGroup方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddMember
void HostGroup::AddMember(const Host::Ptr& host)
{
host->AddGroup(GetName());
boost::mutex::scoped_lock lock(m_HostGroupMutex);
m_Members.insert(host);
}
示例2: EvaluateObjectRuleOne
bool HostGroup::EvaluateObjectRuleOne(const Host::Ptr& host, const ObjectRule& rule)
{
DebugInfo di = rule.GetDebugInfo();
std::ostringstream msgbuf;
msgbuf << "Evaluating 'object' rule (" << di << ")";
CONTEXT(msgbuf.str());
Dictionary::Ptr locals = make_shared<Dictionary>();
locals->Set("host", host);
if (!rule.EvaluateFilter(locals))
return false;
std::ostringstream msgbuf2;
msgbuf2 << "Assigning membership for group '" << rule.GetName() << "' to host '" << host->GetName() << "' for rule " << di;
Log(LogDebug, "HostGroup", msgbuf2.str());
String group_name = rule.GetName();
HostGroup::Ptr group = HostGroup::GetByName(group_name);
if (!group) {
Log(LogCritical, "HostGroup", "Invalid membership assignment. Group '" + group_name + "' does not exist.");
return false;
}
/* assign host group membership */
group->ResolveGroupMembership(host, true);
/* update groups attribute for apply */
host->AddGroup(group_name);
return true;
}