From: Francis Dupont Date: Wed, 12 Sep 2018 13:23:44 +0000 (+0200) Subject: [65-libyang-generic] Removed sysrepo_connection and watcher files X-Git-Tag: 65-libyang-control-socket_base~1^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=42a1a8d5965f82faf9d31355cb3b434ccccb1a2e;p=thirdparty%2Fkea.git [65-libyang-generic] Removed sysrepo_connection and watcher files --- diff --git a/src/lib/yang/Makefile.am b/src/lib/yang/Makefile.am index 0e5df09505..01b3a633af 100644 --- a/src/lib/yang/Makefile.am +++ b/src/lib/yang/Makefile.am @@ -6,9 +6,7 @@ AM_CXXFLAGS = $(KEA_CXXFLAGS) lib_LTLIBRARIES = libkea-yang.la libkea_yang_la_SOURCES = sysrepo_error.h -libkea_yang_la_SOURCES += sysrepo_connection.cc sysrepo_connection.h libkea_yang_la_SOURCES += translator.cc translator.h -libkea_yang_la_SOURCES += watcher.cc watcher.h libkea_yang_la_LIBADD = $(top_builddir)/src/lib/asiolink/libkea-asiolink.la libkea_yang_la_LIBADD += $(top_builddir)/src/lib/cc/libkea-cc.la @@ -23,10 +21,8 @@ libkea_yang_la_LDFLAGS = -no-undefined -version-info 0:0:0 # Specify the headers for copying into the installation directory tree. libkea_yang_includedir = $(pkgincludedir)/yang libkea_yang_include_HEADERS = \ - sysrepo_connection.h \ sysrepo_error.h \ - translator.h \ - watcher.h + translator.h EXTRA_DIST = yang.dox diff --git a/src/lib/yang/sysrepo_connection.cc b/src/lib/yang/sysrepo_connection.cc deleted file mode 100644 index bfb3eb8e4e..0000000000 --- a/src/lib/yang/sysrepo_connection.cc +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC") -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#include - -namespace isc { -namespace yang { - -SysrepoConnection::SysrepoConnection() { -} - -SysrepoConnection::~SysrepoConnection() { - if (session_) { - session_->discard_changes(); - session_->unlock_datastore(); - session_->session_stop(); - - /// @todo: how to call disconnect? - } -} - -void -SysrepoConnection::connect() { - - // Get a connection. - S_Connection conn(new Connection("kea-netconf")); - // Get a session. - session_.reset(new Session(conn, SR_DS_CANDIDATE)); - // Get a from yang object. -} - -void -SysrepoConnection::commit() { - if (!session_) { - isc_throw(SysrepoConnectionError, "session not established"); - } - session_->commit(); -} - -} -} diff --git a/src/lib/yang/sysrepo_connection.h b/src/lib/yang/sysrepo_connection.h deleted file mode 100644 index 2ed211125c..0000000000 --- a/src/lib/yang/sysrepo_connection.h +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC") -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef NETCONF_CONNECTION_H -#define NETCONF_CONNECTION_H - -#include -#include - -namespace isc { -namespace yang { - -/// @brief An exception thrown when connection with sysrepo is broken -class SysrepoConnectionError : public Exception { -public: - SysrepoConnectionError(const char* file, size_t line, const char* what) : - isc::Exception(file, line, what) {} -}; - -/// @brief A class that represents a connection to Sysrepo -class SysrepoConnection { -public: - - /// @brief constructor - /// - /// Currently does nothing. You need to explicitly call connect() - SysrepoConnection(); - - /// @brief Destructor - /// - /// Discards any pending data, unlocks datastore and stops session. - virtual ~SysrepoConnection(); - - // @brief Get a connection and a session. - void connect(); - - /// @brief Commits any pending data. - void commit(); - - private: - - /// @brief pointer to a session - /// - /// May be null if the session is not established. - S_Session session_; -}; - -} // sysrepo -} // isc - -#endif /* NETCONF_CONNECTION_H_ */ diff --git a/src/lib/yang/watcher.cc b/src/lib/yang/watcher.cc deleted file mode 100644 index 4c96a3920e..0000000000 --- a/src/lib/yang/watcher.cc +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC") -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#include - -#include - -using namespace std; -using namespace isc::data; - -namespace isc { -namespace yang { - -Watcher::Watcher(SysrepoConnection &connection, const string &xpath) - : xpath_(xpath), netconf_data_(0), connection_(connection) { -}; - -Watcher::~Watcher() { -} - -const string& -Watcher::getXPath() const { - return (xpath_); -} - -ElementPtr -Watcher::getJSON() { - return (json_); -} - -} // namespace netconf -} // namespace isc diff --git a/src/lib/yang/watcher.h b/src/lib/yang/watcher.h deleted file mode 100644 index 7320475092..0000000000 --- a/src/lib/yang/watcher.h +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC") -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef ISC_WATCHER_H -#define ISC_WATCHER_H - -#include - -#include -#include -#include - -namespace isc { -namespace yang { - -/// @brief This represents a base class for all watchers. -/// -/// Isc_Watcher is an object that receives callback notification -/// from sysrepo (in YANG format) and converts it to appropriate -/// JSON that can be sent over control channel and understood by Kea. -class Watcher { -public: - // @brief Constructor (requires xpath to install a callback). - // - // @param connection The sysrepo connection. - // @param xpath The xpath to watch to. - Watcher(SysrepoConnection& connection, const std::string& xpath); - - // @brief Destructor (doing nothing). - virtual ~Watcher(); - - // @brief Get the xpath. - // @return The xpath to watch to. - virtual const std::string& getXPath() const; - - // This method will be called when the callback returns. - // Need to figure out the type used. - // - // @param data The yang data. - void setYangData(void* data); - - // @brief This method translates Netconf data to JSON format - // understood by Kea. - virtual void translate() = 0; - - // @brief Get JSON once setYangData is called, - // @return The JSON representation of the yang data. - isc::data::ElementPtr getJSON(); - -protected: - // @brief The xpath to watch to. - const std::string& xpath_; - - // @brief The yang data. - void* netconf_data_; - - // @brief The JSON representation of the yang data. - isc::data::ElementPtr json_; - - // @brief The sysrepo connection. - SysrepoConnection &connection_; -}; - -/// @brief The type of shared pointers to watcher objects. -typedef boost::shared_ptr WatcherPtr; - -} // namespace isc::yang -} // namespace isc - -#endif /* ISC_WATCHER_H */