mirror of https://github.com/Icinga/icinga2.git
API: Check if objects exists and return proper error message
This commit is contained in:
parent
3a8017fd99
commit
bd7598cb1b
|
@ -110,6 +110,13 @@ bool ConfigObjectUtility::CreateObject(const Type::Ptr& type, const String& full
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ConfigItem::Ptr item = ConfigItem::GetByTypeAndName(type, fullName);
|
||||||
|
|
||||||
|
if (item) {
|
||||||
|
errors->Add("Object '" + fullName + "' already exists.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
String path = GetObjectConfigPath(type, fullName);
|
String path = GetObjectConfigPath(type, fullName);
|
||||||
Utility::MkDirP(Utility::DirName(path), 0700);
|
Utility::MkDirP(Utility::DirName(path), 0700);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue