blob: 1c9fb04e11eeadb645d35ab958b39ec4ccb1abcb [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>
11#include "ast_commands.hpp"
12#include "datastore_access.hpp"
13
14/*! \class NetconfAccess
15 * \brief Implementation of DatastoreAccess for accessing a NETCONF server
16 */
17
18namespace libnetconf {
19namespace client {
20class Session;
21}
22}
23
24namespace libyang {
25class Data_Node;
26}
27
28class Schema;
29class YangSchema;
30
31class NetconfAccess : public DatastoreAccess {
32public:
33 NetconfAccess(const std::string& hostname, uint16_t port, const std::string& user, const std::string& pubKey, const std::string& privKey);
34 NetconfAccess(const std::string& socketPath);
35 ~NetconfAccess() override;
36 std::map<std::string, leaf_data_> getItems(const std::string& path) override;
37 void setLeaf(const std::string& path, leaf_data_ value) override;
38 void createPresenceContainer(const std::string& path) override;
39 void deletePresenceContainer(const std::string& path) override;
40 void createListInstance(const std::string& path) override;
41 void deleteListInstance(const std::string& path) override;
42 void commitChanges() override;
43 void discardChanges() override;
44
45 std::shared_ptr<Schema> schema() override;
46
47private:
48 std::string fetchSchema(const std::string_view module, const std::optional<std::string_view> revision, const std::optional<std::string_view>);
49 std::vector<std::string> listImplementedSchemas();
50 void datastoreInit();
51 void doEditFromDataNode(std::shared_ptr<libyang::Data_Node> dataNode);
52
53 std::unique_ptr<libnetconf::client::Session> m_session;
54 std::shared_ptr<YangSchema> m_schema;
55};