blob: 4c0e813d54462a8e61efd645f745138770637723 [file] [log] [blame]
Václav Kubernátc31bd602019-03-07 11:44:48 +01001/*
2 * Copyright (C) 2019 CESNET, https://photonics.cesnet.cz/
3 *
4 * Written by Václav Kubernát <kubernat@cesnet.cz>
5 *
6*/
7
8#pragma once
9
10#include <string>
Václav Kubernátc31bd602019-03-07 11:44:48 +010011#include "datastore_access.hpp"
12
13/*! \class NetconfAccess
14 * \brief Implementation of DatastoreAccess for accessing a NETCONF server
15 */
16
17namespace libnetconf {
18namespace client {
19class Session;
20}
21}
22
23namespace libyang {
24class Data_Node;
25}
26
27class Schema;
28class YangSchema;
29
30class NetconfAccess : public DatastoreAccess {
31public:
32 NetconfAccess(const std::string& hostname, uint16_t port, const std::string& user, const std::string& pubKey, const std::string& privKey);
33 NetconfAccess(const std::string& socketPath);
34 ~NetconfAccess() override;
35 std::map<std::string, leaf_data_> getItems(const std::string& path) override;
36 void setLeaf(const std::string& path, leaf_data_ value) override;
37 void createPresenceContainer(const std::string& path) override;
38 void deletePresenceContainer(const std::string& path) override;
39 void createListInstance(const std::string& path) override;
40 void deleteListInstance(const std::string& path) override;
41 void commitChanges() override;
42 void discardChanges() override;
43
44 std::shared_ptr<Schema> schema() override;
45
46private:
47 std::string fetchSchema(const std::string_view module, const std::optional<std::string_view> revision, const std::optional<std::string_view>);
48 std::vector<std::string> listImplementedSchemas();
49 void datastoreInit();
50 void doEditFromDataNode(std::shared_ptr<libyang::Data_Node> dataNode);
51
52 std::unique_ptr<libnetconf::client::Session> m_session;
53 std::shared_ptr<YangSchema> m_schema;
54};