NetconfAccess: enable passing libnetconf2 (C++) session directly
Instead of implementing all possible constructors twice, rely on the
underlying library (or rather its C++ bindings) to do the right thing,
and use that as a connection handle.
Change-Id: I954edc9bfbd1c909479db6b92b929aab93762810
diff --git a/src/netconf_access.cpp b/src/netconf_access.cpp
index 78d80b1..4f4a923 100644
--- a/src/netconf_access.cpp
+++ b/src/netconf_access.cpp
@@ -98,6 +98,13 @@
datastoreInit();
}
+NetconfAccess::NetconfAccess(std::unique_ptr<libnetconf::client::Session>&& session)
+ : m_session(std::move(session))
+ , m_schema(new YangSchema())
+{
+ datastoreInit();
+}
+
NetconfAccess::NetconfAccess(const std::string& socketPath)
: m_schema(new YangSchema())
{
diff --git a/src/netconf_access.hpp b/src/netconf_access.hpp
index ccfffcc..29101ed 100644
--- a/src/netconf_access.hpp
+++ b/src/netconf_access.hpp
@@ -31,6 +31,7 @@
public:
NetconfAccess(const std::string& hostname, uint16_t port, const std::string& user, const std::string& pubKey, const std::string& privKey);
NetconfAccess(const std::string& socketPath);
+ NetconfAccess(std::unique_ptr<libnetconf::client::Session>&& session);
~NetconfAccess() override;
std::map<std::string, leaf_data_> getItems(const std::string& path) override;
void setLeaf(const std::string& path, leaf_data_ value) override;