+++ /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() {
-}
-
-string
-Watcher::getXPath() {
- 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:
- // Constructor (requires xpath to install a callback)
- Watcher(SysrepoConnection &connection, const std::string &xpath);
-
- virtual ~Watcher();
-
- virtual std::string getXPath();
-
- // This method will be called when the callback returns.
- // Need to figure out the type used.
- void setYangData(void *data);
-
- // This method translates Netconf data to JSON format
- // understood by Kea.
- virtual void translate() = 0;
-
- // Once setYangData is called,
- isc::data::ElementPtr getJSON();
-
-protected:
- std::string xpath_;
-
- void *netconf_data_;
-
- isc::data::ElementPtr json_;
-
- SysrepoConnection &connection_;
-};
-
-typedef boost::shared_ptr<Watcher> WatcherPtr;
-
-} // namespace isc::yang
-} // namespace isc
-
-#endif /* ISC_WATCHER_H */