Václav Kubernát | c31bd60 | 2019-03-07 11:44:48 +0100 | [diff] [blame] | 1 | /* |
| 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át | c31bd60 | 2019-03-07 11:44:48 +0100 | [diff] [blame] | 11 | #include "datastore_access.hpp" |
| 12 | |
| 13 | /*! \class NetconfAccess |
| 14 | * \brief Implementation of DatastoreAccess for accessing a NETCONF server |
| 15 | */ |
| 16 | |
| 17 | namespace libnetconf { |
| 18 | namespace client { |
| 19 | class Session; |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | namespace libyang { |
| 24 | class Data_Node; |
| 25 | } |
| 26 | |
| 27 | class Schema; |
| 28 | class YangSchema; |
| 29 | |
| 30 | class NetconfAccess : public DatastoreAccess { |
| 31 | public: |
| 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); |
Jan Kundrát | dab815e | 2020-01-22 19:44:11 +0100 | [diff] [blame] | 34 | NetconfAccess(std::unique_ptr<libnetconf::client::Session>&& session); |
Václav Kubernát | c31bd60 | 2019-03-07 11:44:48 +0100 | [diff] [blame] | 35 | ~NetconfAccess() override; |
Jan Kundrát | b331b55 | 2020-01-23 15:25:29 +0100 | [diff] [blame] | 36 | Tree getItems(const std::string& path) override; |
Václav Kubernát | c31bd60 | 2019-03-07 11:44:48 +0100 | [diff] [blame] | 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; |
Jan Kundrát | 6ee8479 | 2020-01-24 01:43:36 +0100 | [diff] [blame] | 44 | Tree executeRpc(const std::string& path, const Tree& input) override; |
Václav Kubernát | 7160a13 | 2020-04-03 02:11:01 +0200 | [diff] [blame^] | 45 | void copyConfig(const Datastore source, const Datastore destination) override; |
Václav Kubernát | c31bd60 | 2019-03-07 11:44:48 +0100 | [diff] [blame] | 46 | |
| 47 | std::shared_ptr<Schema> schema() override; |
| 48 | |
| 49 | private: |
Václav Kubernát | ab612e9 | 2019-11-26 19:51:31 +0100 | [diff] [blame] | 50 | std::vector<std::map<std::string, leaf_data_>> listInstances(const std::string& path) override; |
| 51 | |
Václav Kubernát | b52dc25 | 2019-12-04 13:03:39 +0100 | [diff] [blame] | 52 | std::string fetchSchema(const std::string_view module, const |
| 53 | std::optional<std::string_view> revision, const |
| 54 | std::optional<std::string_view> submodule, const |
| 55 | std::optional<std::string_view> submoduleRevision); |
Václav Kubernát | c31bd60 | 2019-03-07 11:44:48 +0100 | [diff] [blame] | 56 | std::vector<std::string> listImplementedSchemas(); |
| 57 | void datastoreInit(); |
| 58 | void doEditFromDataNode(std::shared_ptr<libyang::Data_Node> dataNode); |
| 59 | |
| 60 | std::unique_ptr<libnetconf::client::Session> m_session; |
| 61 | std::shared_ptr<YangSchema> m_schema; |
| 62 | }; |