From 86e0740ff36b97ba98f1ed02f34bfb23d1b96262 Mon Sep 17 00:00:00 2001 From: wsliwka Date: Wed, 20 Nov 2019 13:20:08 +0100 Subject: Latest changes to pnf simulator - replace cpp bindings by python - remove docker spotify plugin (no longer supported) - create own image for netopeer (with all packages installed upfront) Issue-ID: INT-1372 Signed-off-by: wsliwka Change-Id: I983c0eddf12fa589fbf3ad1ffbab2b36929c9ef0 --- .../SysrepoCallback.cpp | 108 --------------------- 1 file changed, 108 deletions(-) delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/netopeer-change-saver-native/SysrepoCallback.cpp (limited to 'test/mocks/pnfsimulator/netconfsimulator/netopeer-change-saver-native/SysrepoCallback.cpp') diff --git a/test/mocks/pnfsimulator/netconfsimulator/netopeer-change-saver-native/SysrepoCallback.cpp b/test/mocks/pnfsimulator/netconfsimulator/netopeer-change-saver-native/SysrepoCallback.cpp deleted file mode 100644 index 225fe03a4..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/netopeer-change-saver-native/SysrepoCallback.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Simulator - * ================================================================================ - * Copyright (C) 2019 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -#include "SysrepoCallback.h" -#define CREATED "CREATED" -#define DELETED "DELETED" -#define MODIFIED "MODIFIED" -#define MOVED "MOVED" -#define XPATH_MAX_LEN 100 - - -int SysrepoCallback::module_change(sysrepo::S_Session sess, const char *module_name, sr_notif_event_t event, void *private_ctx) { - { - if (event == SR_EV_APPLY) { - char change_path[XPATH_MAX_LEN]; - - try { -#ifdef DEBUG - std::cout << "\n ========== CHANGES: =============================================\n" << std::endl; -#endif - snprintf(change_path, XPATH_MAX_LEN, "/%s:*", module_name); - auto it = sess->get_changes_iter(&change_path[0]); - while (auto change = sess->get_change_next(it)) { - std::string message = create_message(change); - std::cout<kafka_send_message(message); - } -#ifdef DEBUG - std::cout << "\n ========== END OF CHANGES =======================================\n" << std::endl; -#endif - } catch( const std::exception& e ) { - std::cerr << e.what() << std::endl; - } - } - return SR_ERR_OK; - } -} - -SysrepoCallback::SysrepoCallback(std::shared_ptr wrapper) { - this->kafkaWrapper = wrapper; -} - -std::string SysrepoCallback::create_message(sysrepo::S_Change change) { - std::string change_details; - sysrepo::S_Val new_val = change->new_val(); - sysrepo::S_Val old_val = change->old_val(); - - switch (change->oper()) { - case SR_OP_CREATED: - if (nullptr != new_val) { - change_details.append(CREATED).append(": ").append(new_val->to_string()); - } - break; - case SR_OP_DELETED: - if (nullptr != old_val) { - change_details.append(DELETED).append(": ").append(old_val->to_string()); - } - break; - case SR_OP_MODIFIED: - if (nullptr != old_val && nullptr != new_val) { - change_details.append(MODIFIED).append(": ").append(": old value: ").append(old_val->to_string()) - .append(", new value: ").append(new_val->to_string()); - } - break; - case SR_OP_MOVED: - if (nullptr != old_val && nullptr != new_val) { - change_details.append(MOVED).append(": ").append(new_val->to_string()) - .append(" after ").append(old_val->to_string()); - } else if (nullptr != new_val) { - change_details.append(MOVED).append(": ").append(new_val->xpath()).append(" last"); - } - break; - } - return change_details; -} - -void SysrepoCallback::print_current_config(sysrepo::S_Session session, const char *module_name) { - char select_xpath[XPATH_MAX_LEN]; - try { - snprintf(select_xpath, XPATH_MAX_LEN, "/%s:*//*", module_name); - - auto values = session->get_items(&select_xpath[0]); - if (values == nullptr) - return; - - for(unsigned int i = 0; i < values->val_cnt(); i++) - std::cout << values->val(i)->to_string(); - } catch( const std::exception& e ) { - std::cout << e.what() << std::endl; - } -} -- cgit 1.2.3-korg