IMM fails to load model file which has system attribute(s) in object tags but not in its class element. In case of importing, it always fails to importing file having system attributes in object tags.
This patch checks if the processing attribute is system or not, ignore checking its existence from its class. --- src/imm/immloadd/imm_loader.cc | 18 ++++++++++++++++++ src/imm/tools/imm_import.cc | 20 +++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/imm/immloadd/imm_loader.cc b/src/imm/immloadd/imm_loader.cc index de5a575e9..c5b35240a 100644 --- a/src/imm/immloadd/imm_loader.cc +++ b/src/imm/immloadd/imm_loader.cc @@ -1747,6 +1747,19 @@ static char *getAttributeValue(const char *attr, return NULL; } +static bool is_system_attribute(const std::string& name) { + const char* system_attributes[] = { + "SaImmAttrClassName", + "SaImmAttrAdminOwnerName", + "SaImmAttrImplementerName" + }; + + for (const auto& s : system_attributes) { + if (std::string {s} == name) return true; + } + return false; +} + /** * Adds an object attr definition to the attrValuesList */ @@ -1880,6 +1893,11 @@ static SaImmValueTypeT getClassAttrValueType( exit(1); } + // This is system attribute, ignore checking. + if (is_system_attribute(attrNameString) == true) { + return SA_IMM_ATTR_SASTRINGT; + } + if ((*classAttrTypeMap)[classNameString].find(attrNameString) == (*classAttrTypeMap)[classNameString].end()) { LOG_ER("NO CORRESPONDING ATTRIBUTE %s in class %s", attrName, className); diff --git a/src/imm/tools/imm_import.cc b/src/imm/tools/imm_import.cc index e2bdcba5c..711d017a8 100644 --- a/src/imm/tools/imm_import.cc +++ b/src/imm/tools/imm_import.cc @@ -2134,6 +2134,19 @@ static char *getAttributeValue(const char *attr, return NULL; } +static bool is_system_attribute(const std::string& name) { + const std::string system_attributes[] = { + "SaImmAttrClassName", + "SaImmAttrAdminOwnerName", + "SaImmAttrImplementerName" + }; + + for (const auto& s : system_attributes) { + if (std::string {s} == name) return true; + } + return false; +} + /** * Adds an object attr definition to the state->attrValues list */ @@ -2143,6 +2156,11 @@ static void addObjectAttributeDefinition(ParserState *state) { int i; size_t len; + // Ignore processing system attributes if any. + if (is_system_attribute(state->attrName)) { + return; + } + /* The attrName must be set */ if (!state->attrName) { LOG_ER("The attrName must be set"); @@ -2354,9 +2372,9 @@ static SaImmValueTypeT getClassAttrValueType(ParserState *state, if (state->classAttrTypeMap[classNameString].find(attrNameString) == state->classAttrTypeMap[classNameString].end()) { + LOG_ER("NO CORRESPONDING ATTRIBUTE %s in class %s", attrName, className); stopParser(state); state->parsingStatus = 1; - LOG_ER("NO CORRESPONDING ATTRIBUTE %s in class %s", attrName, className); return (SaImmValueTypeT)-1; } -- 2.18.0 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel