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
# 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
+++ /dev/null
-// 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 <yang/sysrepo_connection.h>
-
-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();
-}
-
-}
-}
+++ /dev/null
-// 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 <exceptions/exceptions.h>
-#include <sysrepo-cpp/Session.h>
-
-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_ */
+++ /dev/null
-// 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 <config.h>
-
-#include <yang/watcher.h>
-
-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
+++ /dev/null
-// 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 <config.h>
-
-#include <boost/shared_ptr.hpp>
-#include <cc/data.h>
-#include <yang/sysrepo_connection.h>
-
-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<Watcher> WatcherPtr;
-
-} // namespace isc::yang
-} // namespace isc
-
-#endif /* ISC_WATCHER_H */