Skip to content
Permalink
Browse files

Provide 1.x fallback using GetName() for address macros.

Refs #5855
  • Loading branch information...
dnsmichi committed Apr 5, 2014
1 parent e309a5d commit 4966dfd2416c8ab0ef3bf4c535d76a144e0acaa2
Showing with 33 additions and 0 deletions.
  1. +33 −0 lib/icinga/host.cpp
@@ -261,6 +261,39 @@ bool Host::ResolveMacro(const String& macro, const CheckResult::Ptr&, String *re
String key;
Dictionary::Ptr vars;

/* special treatment for address macros providing name fallback */
if (macro == "address" || macro == "address6") {
vars = GetVars();

String value;
if (vars && vars->Contains(macro))
value = vars->Get(key);

if (value.IsEmpty()) {
*result = GetName();
return true;
} else {
*result = value;
return true;
}
}
else if (macro == "host.vars.address" || macro == "host.vars.address6") {
key = macro.SubStr(10);
vars = GetVars();

String value;
if (vars && vars->Contains(macro))
value = vars->Get(key);

if (value.IsEmpty()) {
*result = GetName();
return true;
} else {
*result = value;
return true;
}
}

/* require prefix for object macros */
if (macro.SubStr(0, 5) == "host.") {
key = macro.SubStr(5);

0 comments on commit 4966dfd

Please sign in to comment.
You can’t perform that action at this time.