diff --git a/src/datastore/Datastore.cc b/src/datastore/Datastore.cc index 67b8c7691c..601d216ddc 100644 --- a/src/datastore/Datastore.cc +++ b/src/datastore/Datastore.cc @@ -148,12 +148,12 @@ int Datastore::set_tm_mad(string &tm_mad, string &error_str) int rc; string st; + ostringstream oss; + rc = Nebula::instance().get_tm_conf_attribute(tm_mad, vatt); if (rc != 0) { - ostringstream oss; - oss << "TM_MAD named \"" << tm_mad << "\" is not defined in oned.conf"; error_str = oss.str(); @@ -167,13 +167,11 @@ int Datastore::set_tm_mad(string &tm_mad, string &error_str) if (st.empty()) { - st = "YES"; - } - else - { - one_util::toupper(st); + goto error; } + one_util::toupper(st); + replace_template_attribute("SHARED", st); } else @@ -182,30 +180,34 @@ int Datastore::set_tm_mad(string &tm_mad, string &error_str) if (st.empty()) { - st = "NONE"; - } - else - { - one_util::toupper(st); + goto error; } + one_util::toupper(st); + replace_template_attribute("LN_TARGET", st); st = vatt->vector_value("CLONE_TARGET"); if (st.empty()) { - st = "SYSTEM"; - } - else - { - one_util::toupper(st); + goto error; } + one_util::toupper(st); + replace_template_attribute("CLONE_TARGET", st); } return 0; + +error: + oss << "Attribute TM_MAD_CONF for " << tm_mad + << " is missing shared, ln_target or clone_target in oned.conf"; + + error_str = oss.str(); + + return -1; } int Datastore::insert(SqlDB *db, string& error_str)