|
@@ -12,51 +12,35 @@ using namespace isc::data;
|
|
|
std::map<std::string, std::string> cm_map;
|
|
|
std::map<std::string, std::string> option122_map;
|
|
|
|
|
|
-extern "C" {
|
|
|
+std::string host;
|
|
|
+std::string database;
|
|
|
+std::string user;
|
|
|
+std::string password;
|
|
|
|
|
|
-int loadMappging(std::string base_map_config, LibraryHandle& handle, std::map<std::string, std::string>& map){
|
|
|
+extern "C" {
|
|
|
|
|
|
- ConstElementPtr curr_map = handle.getParameter(base_map_config);
|
|
|
- if (Element::map != curr_map->getType()){
|
|
|
- LOG_ERROR(runscript_logger, RUNSCRIPT_MISTYPED_PARAM).arg(base_map_config);
|
|
|
+int load(LibraryHandle& handle)
|
|
|
+{
|
|
|
+ ConstElementPtr hostPtr = handle.getParameter("host");
|
|
|
+ ConstElementPtr databasePtr = handle.getParameter("database");
|
|
|
+ ConstElementPtr userPtr = handle.getParameter("user");
|
|
|
+ ConstElementPtr passwordPtr = handle.getParameter("password");
|
|
|
+
|
|
|
+ if (
|
|
|
+ hostPtr->getType() != Element::string ||
|
|
|
+ databasePtr->getType() != Element::string ||
|
|
|
+ userPtr->getType() != Element::string ||
|
|
|
+ passwordPtr->getType() != Element::string
|
|
|
+ ) {
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
- std::map<std::string, ConstElementPtr> map_config = curr_map->mapValue();;
|
|
|
- std::pair<std::string, ConstElementPtr> me;
|
|
|
-
|
|
|
- BOOST_FOREACH(me, map_config) {
|
|
|
- std::string class_to_map = me.first;
|
|
|
- std::cout << me.first << "\n";
|
|
|
- ConstElementPtr table = me.second;
|
|
|
- if(table->getType() != Element::list){
|
|
|
- LOG_ERROR(runscript_logger, RUNSCRIPT_MISTYPED_PARAM).arg(base_map_config + "." + me.first);
|
|
|
- return 1;
|
|
|
- }
|
|
|
- const std::vector<ElementPtr> mac_list = table->listValue();
|
|
|
- for(int i = 0; i < mac_list.size(); i++) {
|
|
|
- ElementPtr it = mac_list[i];
|
|
|
- if(it->getType() != Element::string){
|
|
|
- LOG_ERROR(runscript_logger, RUNSCRIPT_MISTYPED_PARAM).arg(base_map_config + "." + me.first + "[" + std::to_string(i) + "]");
|
|
|
- return 1;
|
|
|
- }
|
|
|
- std::cout << mac_list[i]->stringValue() << "\n";
|
|
|
- std::string mac = mac_list[i]->stringValue();
|
|
|
- std::transform(mac.begin(), mac.end(),mac.begin(), ::toupper);
|
|
|
-
|
|
|
- map[mac] = class_to_map;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return 0;
|
|
|
-}
|
|
|
+ host = hostPtr->stringValue();
|
|
|
+ database = databasePtr->stringValue();
|
|
|
+ user = userPtr->stringValue();
|
|
|
+ password = passwordPtr->stringValue();
|
|
|
|
|
|
-int load(LibraryHandle& handle)
|
|
|
-{
|
|
|
-
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
} // end extern "C"
|