Václav Kubernát | 80aacc0 | 2018-08-22 17:41:54 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 CESNET, https://photonics.cesnet.cz/ |
| 3 | * Copyright (C) 2018 FIT CVUT, https://fit.cvut.cz/ |
| 4 | * |
| 5 | * Written by Václav Kubernát <kubervac@fit.cvut.cz> |
| 6 | * |
| 7 | */ |
| 8 | |
Václav Kubernát | 19097f3 | 2020-10-05 10:08:29 +0200 | [diff] [blame] | 9 | #include <experimental/iterator> |
Václav Kubernát | ab612e9 | 2019-11-26 19:51:31 +0100 | [diff] [blame] | 10 | #include <libyang/Tree_Data.hpp> |
| 11 | #include <libyang/Tree_Schema.hpp> |
Václav Kubernát | 19097f3 | 2020-10-05 10:08:29 +0200 | [diff] [blame] | 12 | #include <sstream> |
Václav Kubernát | b4e5b18 | 2020-11-16 19:55:09 +0100 | [diff] [blame] | 13 | #include <sysrepo-cpp/Session.hpp> |
Václav Kubernát | ab612e9 | 2019-11-26 19:51:31 +0100 | [diff] [blame] | 14 | #include "libyang_utils.hpp" |
Václav Kubernát | 80aacc0 | 2018-08-22 17:41:54 +0200 | [diff] [blame] | 15 | #include "sysrepo_access.hpp" |
Jan Kundrát | 6ee8479 | 2020-01-24 01:43:36 +0100 | [diff] [blame] | 16 | #include "utils.hpp" |
Václav Kubernát | a6c5fff | 2018-09-07 15:16:25 +0200 | [diff] [blame] | 17 | #include "yang_schema.hpp" |
Václav Kubernát | 80aacc0 | 2018-08-22 17:41:54 +0200 | [diff] [blame] | 18 | |
Václav Kubernát | 654303f | 2020-07-31 13:16:54 +0200 | [diff] [blame] | 19 | const auto OPERATION_TIMEOUT_MS = 1000; |
| 20 | |
Jan Kundrát | 68d4a2c | 2018-10-01 17:17:09 +0200 | [diff] [blame] | 21 | struct valFromValue : boost::static_visitor<sysrepo::S_Val> { |
| 22 | sysrepo::S_Val operator()(const enum_& value) const |
Václav Kubernát | 80aacc0 | 2018-08-22 17:41:54 +0200 | [diff] [blame] | 23 | { |
Jan Kundrát | 68d4a2c | 2018-10-01 17:17:09 +0200 | [diff] [blame] | 24 | return std::make_shared<sysrepo::Val>(value.m_value.c_str(), SR_ENUM_T); |
Václav Kubernát | 80aacc0 | 2018-08-22 17:41:54 +0200 | [diff] [blame] | 25 | } |
| 26 | |
Václav Kubernát | ab53899 | 2019-03-06 15:30:50 +0100 | [diff] [blame] | 27 | sysrepo::S_Val operator()(const binary_& value) const |
| 28 | { |
| 29 | return std::make_shared<sysrepo::Val>(value.m_value.c_str(), SR_BINARY_T); |
| 30 | } |
| 31 | |
Jan Kundrát | 379bb57 | 2020-05-07 03:23:13 +0200 | [diff] [blame] | 32 | sysrepo::S_Val operator()(const empty_) const |
| 33 | { |
| 34 | return std::make_shared<sysrepo::Val>(nullptr, SR_LEAF_EMPTY_T); |
| 35 | } |
| 36 | |
Václav Kubernát | eeb3884 | 2019-03-20 19:46:05 +0100 | [diff] [blame] | 37 | sysrepo::S_Val operator()(const identityRef_& value) const |
| 38 | { |
Jan Kundrát | 0d8abd1 | 2020-05-07 02:00:14 +0200 | [diff] [blame] | 39 | auto res = value.m_prefix ? (value.m_prefix.value().m_name + ":" + value.m_value) : value.m_value; |
Václav Kubernát | eeb3884 | 2019-03-20 19:46:05 +0100 | [diff] [blame] | 40 | return std::make_shared<sysrepo::Val>(res.c_str(), SR_IDENTITYREF_T); |
| 41 | } |
| 42 | |
Václav Kubernát | 144729d | 2020-01-08 15:20:35 +0100 | [diff] [blame] | 43 | sysrepo::S_Val operator()(const special_& value) const |
| 44 | { |
| 45 | throw std::runtime_error("Tried constructing S_Val from a " + specialValueToString(value)); |
| 46 | } |
| 47 | |
Jan Kundrát | 68d4a2c | 2018-10-01 17:17:09 +0200 | [diff] [blame] | 48 | sysrepo::S_Val operator()(const std::string& value) const |
Václav Kubernát | 80aacc0 | 2018-08-22 17:41:54 +0200 | [diff] [blame] | 49 | { |
Jan Kundrát | 68d4a2c | 2018-10-01 17:17:09 +0200 | [diff] [blame] | 50 | return std::make_shared<sysrepo::Val>(value.c_str()); |
Václav Kubernát | 80aacc0 | 2018-08-22 17:41:54 +0200 | [diff] [blame] | 51 | } |
| 52 | |
Václav Kubernát | 19097f3 | 2020-10-05 10:08:29 +0200 | [diff] [blame] | 53 | sysrepo::S_Val operator()(const bits_& value) const |
| 54 | { |
| 55 | std::stringstream ss; |
| 56 | std::copy(value.m_bits.begin(), value.m_bits.end(), std::experimental::make_ostream_joiner(ss, " ")); |
| 57 | return std::make_shared<sysrepo::Val>(ss.str().c_str(), SR_BITS_T); |
| 58 | } |
| 59 | |
Jan Kundrát | bd17836 | 2019-02-05 19:00:04 +0100 | [diff] [blame] | 60 | template <typename T> |
| 61 | sysrepo::S_Val operator()(const T& value) const |
Václav Kubernát | 80aacc0 | 2018-08-22 17:41:54 +0200 | [diff] [blame] | 62 | { |
Jan Kundrát | 68d4a2c | 2018-10-01 17:17:09 +0200 | [diff] [blame] | 63 | return std::make_shared<sysrepo::Val>(value); |
Václav Kubernát | 80aacc0 | 2018-08-22 17:41:54 +0200 | [diff] [blame] | 64 | } |
| 65 | }; |
| 66 | |
Václav Kubernát | 812ee28 | 2018-08-30 17:10:03 +0200 | [diff] [blame] | 67 | SysrepoAccess::~SysrepoAccess() = default; |
Václav Kubernát | 80aacc0 | 2018-08-22 17:41:54 +0200 | [diff] [blame] | 68 | |
Václav Kubernát | 715c85c | 2020-04-14 01:46:08 +0200 | [diff] [blame] | 69 | sr_datastore_t toSrDatastore(Datastore datastore) |
| 70 | { |
| 71 | switch (datastore) { |
| 72 | case Datastore::Running: |
| 73 | return SR_DS_RUNNING; |
| 74 | case Datastore::Startup: |
| 75 | return SR_DS_STARTUP; |
| 76 | } |
| 77 | __builtin_unreachable(); |
| 78 | } |
| 79 | |
Václav Kubernát | 654303f | 2020-07-31 13:16:54 +0200 | [diff] [blame] | 80 | SysrepoAccess::SysrepoAccess(const Datastore datastore) |
| 81 | : m_connection(std::make_shared<sysrepo::Connection>()) |
| 82 | , m_session(std::make_shared<sysrepo::Session>(m_connection)) |
| 83 | , m_schema(std::make_shared<YangSchema>(m_session->get_context())) |
Václav Kubernát | 80aacc0 | 2018-08-22 17:41:54 +0200 | [diff] [blame] | 84 | { |
Václav Kubernát | c58e4aa | 2019-04-03 18:37:32 +0200 | [diff] [blame] | 85 | try { |
Václav Kubernát | 715c85c | 2020-04-14 01:46:08 +0200 | [diff] [blame] | 86 | m_session = std::make_shared<sysrepo::Session>(m_connection, toSrDatastore(datastore)); |
Václav Kubernát | c58e4aa | 2019-04-03 18:37:32 +0200 | [diff] [blame] | 87 | } catch (sysrepo::sysrepo_exception& ex) { |
| 88 | reportErrors(); |
| 89 | } |
Václav Kubernát | 80aacc0 | 2018-08-22 17:41:54 +0200 | [diff] [blame] | 90 | } |
| 91 | |
Václav Kubernát | d628291 | 2020-06-23 14:49:34 +0200 | [diff] [blame] | 92 | DatastoreAccess::Tree SysrepoAccess::getItems(const std::string& path) const |
Václav Kubernát | 80aacc0 | 2018-08-22 17:41:54 +0200 | [diff] [blame] | 93 | { |
Václav Kubernát | b6ff0b6 | 2018-08-30 16:14:53 +0200 | [diff] [blame] | 94 | using namespace std::string_literals; |
Jan Kundrát | b331b55 | 2020-01-23 15:25:29 +0100 | [diff] [blame] | 95 | Tree res; |
Václav Kubernát | 80aacc0 | 2018-08-22 17:41:54 +0200 | [diff] [blame] | 96 | |
Václav Kubernát | c58e4aa | 2019-04-03 18:37:32 +0200 | [diff] [blame] | 97 | try { |
Václav Kubernát | 654303f | 2020-07-31 13:16:54 +0200 | [diff] [blame] | 98 | auto oldDs = m_session->session_get_ds(); |
| 99 | m_session->session_switch_ds(SR_DS_OPERATIONAL); |
Václav Kubernát | f90a0b5 | 2020-11-06 05:53:03 +0100 | [diff] [blame] | 100 | auto config = m_session->get_data(((path == "/") ? "/*" : path).c_str()); |
Václav Kubernát | 654303f | 2020-07-31 13:16:54 +0200 | [diff] [blame] | 101 | m_session->session_switch_ds(oldDs); |
| 102 | if (config) { |
| 103 | lyNodesToTree(res, config->tree_for()); |
Václav Kubernát | b6ff0b6 | 2018-08-30 16:14:53 +0200 | [diff] [blame] | 104 | } |
Václav Kubernát | c58e4aa | 2019-04-03 18:37:32 +0200 | [diff] [blame] | 105 | } catch (sysrepo::sysrepo_exception& ex) { |
| 106 | reportErrors(); |
Václav Kubernát | c89736b | 2018-08-30 16:14:05 +0200 | [diff] [blame] | 107 | } |
Václav Kubernát | 80aacc0 | 2018-08-22 17:41:54 +0200 | [diff] [blame] | 108 | return res; |
| 109 | } |
| 110 | |
| 111 | void SysrepoAccess::setLeaf(const std::string& path, leaf_data_ value) |
| 112 | { |
Václav Kubernát | c58e4aa | 2019-04-03 18:37:32 +0200 | [diff] [blame] | 113 | try { |
| 114 | m_session->set_item(path.c_str(), boost::apply_visitor(valFromValue(), value)); |
| 115 | } catch (sysrepo::sysrepo_exception& ex) { |
| 116 | reportErrors(); |
| 117 | } |
Václav Kubernát | 80aacc0 | 2018-08-22 17:41:54 +0200 | [diff] [blame] | 118 | } |
| 119 | |
Jan Kundrát | cbf288b | 2020-06-18 20:44:39 +0200 | [diff] [blame] | 120 | void SysrepoAccess::createItem(const std::string& path) |
Václav Kubernát | 80aacc0 | 2018-08-22 17:41:54 +0200 | [diff] [blame] | 121 | { |
Václav Kubernát | c58e4aa | 2019-04-03 18:37:32 +0200 | [diff] [blame] | 122 | try { |
| 123 | m_session->set_item(path.c_str()); |
| 124 | } catch (sysrepo::sysrepo_exception& ex) { |
| 125 | reportErrors(); |
| 126 | } |
Václav Kubernát | 80aacc0 | 2018-08-22 17:41:54 +0200 | [diff] [blame] | 127 | } |
| 128 | |
Jan Kundrát | cbf288b | 2020-06-18 20:44:39 +0200 | [diff] [blame] | 129 | void SysrepoAccess::deleteItem(const std::string& path) |
Václav Kubernát | f5f64f0 | 2019-03-19 17:15:47 +0100 | [diff] [blame] | 130 | { |
Václav Kubernát | c58e4aa | 2019-04-03 18:37:32 +0200 | [diff] [blame] | 131 | try { |
Václav Kubernát | 654303f | 2020-07-31 13:16:54 +0200 | [diff] [blame] | 132 | // Have to use SR_EDIT_ISOLATE, because deleting something that's been set without committing is not supported |
| 133 | // https://github.com/sysrepo/sysrepo/issues/1967#issuecomment-625085090 |
| 134 | m_session->delete_item(path.c_str(), SR_EDIT_ISOLATE); |
Václav Kubernát | c58e4aa | 2019-04-03 18:37:32 +0200 | [diff] [blame] | 135 | } catch (sysrepo::sysrepo_exception& ex) { |
| 136 | reportErrors(); |
| 137 | } |
Václav Kubernát | f5f64f0 | 2019-03-19 17:15:47 +0100 | [diff] [blame] | 138 | } |
| 139 | |
Václav Kubernát | bf65dd7 | 2020-05-28 02:32:31 +0200 | [diff] [blame] | 140 | struct impl_toSrMoveOp { |
| 141 | sr_move_position_t operator()(yang::move::Absolute& absolute) |
| 142 | { |
| 143 | return absolute == yang::move::Absolute::Begin ? SR_MOVE_FIRST : SR_MOVE_LAST; |
| 144 | } |
| 145 | sr_move_position_t operator()(yang::move::Relative& relative) |
| 146 | { |
| 147 | return relative.m_position == yang::move::Relative::Position::After ? SR_MOVE_AFTER : SR_MOVE_BEFORE; |
| 148 | } |
| 149 | }; |
| 150 | |
| 151 | sr_move_position_t toSrMoveOp(std::variant<yang::move::Absolute, yang::move::Relative> move) |
| 152 | { |
| 153 | return std::visit(impl_toSrMoveOp{}, move); |
| 154 | } |
| 155 | |
| 156 | void SysrepoAccess::moveItem(const std::string& source, std::variant<yang::move::Absolute, yang::move::Relative> move) |
| 157 | { |
Václav Kubernát | 654303f | 2020-07-31 13:16:54 +0200 | [diff] [blame] | 158 | std::string destination; |
Václav Kubernát | bf65dd7 | 2020-05-28 02:32:31 +0200 | [diff] [blame] | 159 | if (std::holds_alternative<yang::move::Relative>(move)) { |
| 160 | auto relative = std::get<yang::move::Relative>(move); |
| 161 | if (m_schema->nodeType(source) == yang::NodeTypes::LeafList) { |
Václav Kubernát | 654303f | 2020-07-31 13:16:54 +0200 | [diff] [blame] | 162 | destination = leafDataToString(relative.m_path.at(".")); |
Václav Kubernát | bf65dd7 | 2020-05-28 02:32:31 +0200 | [diff] [blame] | 163 | } else { |
Václav Kubernát | 654303f | 2020-07-31 13:16:54 +0200 | [diff] [blame] | 164 | destination = instanceToString(relative.m_path); |
Václav Kubernát | bf65dd7 | 2020-05-28 02:32:31 +0200 | [diff] [blame] | 165 | } |
| 166 | } |
Václav Kubernát | 654303f | 2020-07-31 13:16:54 +0200 | [diff] [blame] | 167 | m_session->move_item(source.c_str(), toSrMoveOp(move), destination.c_str(), destination.c_str()); |
Václav Kubernát | bf65dd7 | 2020-05-28 02:32:31 +0200 | [diff] [blame] | 168 | } |
| 169 | |
Václav Kubernát | 812ee28 | 2018-08-30 17:10:03 +0200 | [diff] [blame] | 170 | void SysrepoAccess::commitChanges() |
| 171 | { |
Václav Kubernát | c58e4aa | 2019-04-03 18:37:32 +0200 | [diff] [blame] | 172 | try { |
Václav Kubernát | 654303f | 2020-07-31 13:16:54 +0200 | [diff] [blame] | 173 | m_session->apply_changes(OPERATION_TIMEOUT_MS, 1); |
Václav Kubernát | c58e4aa | 2019-04-03 18:37:32 +0200 | [diff] [blame] | 174 | } catch (sysrepo::sysrepo_exception& ex) { |
| 175 | reportErrors(); |
| 176 | } |
Václav Kubernát | 812ee28 | 2018-08-30 17:10:03 +0200 | [diff] [blame] | 177 | } |
Václav Kubernát | a6c5fff | 2018-09-07 15:16:25 +0200 | [diff] [blame] | 178 | |
Václav Kubernát | 6d79143 | 2018-10-25 16:00:35 +0200 | [diff] [blame] | 179 | void SysrepoAccess::discardChanges() |
| 180 | { |
Václav Kubernát | c58e4aa | 2019-04-03 18:37:32 +0200 | [diff] [blame] | 181 | try { |
| 182 | m_session->discard_changes(); |
| 183 | } catch (sysrepo::sysrepo_exception& ex) { |
| 184 | reportErrors(); |
| 185 | } |
Václav Kubernát | 6d79143 | 2018-10-25 16:00:35 +0200 | [diff] [blame] | 186 | } |
| 187 | |
Václav Kubernát | b3960f8 | 2020-12-01 03:21:48 +0100 | [diff] [blame] | 188 | DatastoreAccess::Tree SysrepoAccess::execute(const std::string& path, const Tree& input) |
Václav Kubernát | a878960 | 2020-07-20 15:18:19 +0200 | [diff] [blame] | 189 | { |
Václav Kubernát | fbab2d4 | 2021-02-05 16:12:34 +0100 | [diff] [blame] | 190 | auto inputNode = treeToRpcInput(m_session->get_context(), path, input); |
Václav Kubernát | 4077613 | 2021-02-03 08:47:33 +0100 | [diff] [blame] | 191 | auto output = m_session->rpc_send(inputNode); |
Václav Kubernát | fbab2d4 | 2021-02-05 16:12:34 +0100 | [diff] [blame] | 192 | return rpcOutputToTree(path, output); |
Václav Kubernát | a878960 | 2020-07-20 15:18:19 +0200 | [diff] [blame] | 193 | } |
Jan Kundrát | 6ee8479 | 2020-01-24 01:43:36 +0100 | [diff] [blame] | 194 | |
Václav Kubernát | 7160a13 | 2020-04-03 02:11:01 +0200 | [diff] [blame] | 195 | void SysrepoAccess::copyConfig(const Datastore source, const Datastore destination) |
| 196 | { |
Václav Kubernát | 654303f | 2020-07-31 13:16:54 +0200 | [diff] [blame] | 197 | auto oldDs = m_session->session_get_ds(); |
| 198 | m_session->session_switch_ds(toSrDatastore(destination)); |
| 199 | m_session->copy_config(toSrDatastore(source), nullptr, OPERATION_TIMEOUT_MS, 1); |
| 200 | m_session->session_switch_ds(oldDs); |
Václav Kubernát | a6c5fff | 2018-09-07 15:16:25 +0200 | [diff] [blame] | 201 | } |
| 202 | |
| 203 | std::shared_ptr<Schema> SysrepoAccess::schema() |
| 204 | { |
| 205 | return m_schema; |
| 206 | } |
Václav Kubernát | c58e4aa | 2019-04-03 18:37:32 +0200 | [diff] [blame] | 207 | |
Václav Kubernát | d628291 | 2020-06-23 14:49:34 +0200 | [diff] [blame] | 208 | [[noreturn]] void SysrepoAccess::reportErrors() const |
Václav Kubernát | c58e4aa | 2019-04-03 18:37:32 +0200 | [diff] [blame] | 209 | { |
Václav Kubernát | 654303f | 2020-07-31 13:16:54 +0200 | [diff] [blame] | 210 | // I only use get_error to get error info, since the error code from |
Václav Kubernát | c58e4aa | 2019-04-03 18:37:32 +0200 | [diff] [blame] | 211 | // sysrepo_exception doesn't really give any meaningful information. For |
| 212 | // example an "invalid argument" error could mean a node isn't enabled, or |
| 213 | // it could mean something totally different and there is no documentation |
| 214 | // for that, so it's better to just use the message sysrepo gives me. |
Václav Kubernát | 654303f | 2020-07-31 13:16:54 +0200 | [diff] [blame] | 215 | auto srErrors = m_session->get_error(); |
Václav Kubernát | c58e4aa | 2019-04-03 18:37:32 +0200 | [diff] [blame] | 216 | std::vector<DatastoreError> res; |
| 217 | |
| 218 | for (size_t i = 0; i < srErrors->error_cnt(); i++) { |
Václav Kubernát | 654303f | 2020-07-31 13:16:54 +0200 | [diff] [blame] | 219 | res.emplace_back(srErrors->message(i), srErrors->xpath(i) ? std::optional<std::string>{srErrors->xpath(i)} : std::nullopt); |
Václav Kubernát | c58e4aa | 2019-04-03 18:37:32 +0200 | [diff] [blame] | 220 | } |
| 221 | |
| 222 | throw DatastoreException(res); |
| 223 | } |
Václav Kubernát | ab612e9 | 2019-11-26 19:51:31 +0100 | [diff] [blame] | 224 | |
| 225 | std::vector<ListInstance> SysrepoAccess::listInstances(const std::string& path) |
| 226 | { |
| 227 | std::vector<ListInstance> res; |
| 228 | auto lists = getItems(path); |
| 229 | |
| 230 | decltype(lists) instances; |
| 231 | auto wantedTree = *(m_schema->dataNodeFromPath(path)->find_path(path.c_str())->data().begin()); |
Václav Kubernát | b4e5b18 | 2020-11-16 19:55:09 +0100 | [diff] [blame] | 232 | std::copy_if(lists.begin(), lists.end(), std::inserter(instances, instances.end()), [this, pathToCheck = wantedTree->schema()->path()](const auto& item) { |
Václav Kubernát | ab612e9 | 2019-11-26 19:51:31 +0100 | [diff] [blame] | 233 | // This filters out non-instances. |
| 234 | if (item.second.type() != typeid(special_) || boost::get<special_>(item.second).m_value != SpecialValue::List) { |
| 235 | return false; |
| 236 | } |
| 237 | |
| 238 | // Now, getItems is recursive: it gives everything including nested lists. So I try create a tree from the instance... |
| 239 | auto instanceTree = *(m_schema->dataNodeFromPath(item.first)->find_path(item.first.c_str())->data().begin()); |
| 240 | // And then check if its schema path matches the list we actually want. This filters out lists which are not the ones I requested. |
| 241 | return instanceTree->schema()->path() == pathToCheck; |
| 242 | }); |
| 243 | |
| 244 | // If there are no instances, then just return |
| 245 | if (instances.empty()) { |
| 246 | return res; |
| 247 | } |
| 248 | |
| 249 | // I need to find out which keys does the list have. To do that, I create a |
| 250 | // tree from the first instance. This is gives me some top level node, |
| 251 | // which will be our list in case out list is a top-level node. In case it |
| 252 | // isn't, we have call find_path on the top level node. After that, I just |
| 253 | // retrieve the keys. |
| 254 | auto topLevelTree = m_schema->dataNodeFromPath(instances.begin()->first); |
| 255 | auto list = *(topLevelTree->find_path(path.c_str())->data().begin()); |
| 256 | auto keys = libyang::Schema_Node_List{list->schema()}.keys(); |
| 257 | |
| 258 | // Creating a full tree at the same time from the values sysrepo gives me |
| 259 | // would be a pain (and after sysrepo switches to libyang meaningless), so |
| 260 | // I just use this algorithm to create data nodes one by one and get the |
| 261 | // key values from them. |
| 262 | for (const auto& instance : instances) { |
| 263 | auto wantedList = *(m_schema->dataNodeFromPath(instance.first)->find_path(path.c_str())->data().begin()); |
| 264 | ListInstance instanceRes; |
| 265 | for (const auto& key : keys) { |
| 266 | auto vec = wantedList->find_path(key->name())->data(); |
Václav Kubernát | 2e4cafe | 2020-11-05 01:53:21 +0100 | [diff] [blame] | 267 | auto leaf = std::make_shared<libyang::Data_Node_Leaf_List>(*(vec.begin())); |
| 268 | instanceRes.emplace(key->name(), leafValueFromNode(leaf)); |
Václav Kubernát | ab612e9 | 2019-11-26 19:51:31 +0100 | [diff] [blame] | 269 | } |
Václav Kubernát | faacd02 | 2020-07-08 16:44:38 +0200 | [diff] [blame] | 270 | res.emplace_back(instanceRes); |
Václav Kubernát | ab612e9 | 2019-11-26 19:51:31 +0100 | [diff] [blame] | 271 | } |
| 272 | |
| 273 | return res; |
| 274 | } |
Václav Kubernát | 70d7f7a | 2020-06-23 14:40:40 +0200 | [diff] [blame] | 275 | |
| 276 | std::string SysrepoAccess::dump(const DataFormat format) const |
| 277 | { |
Václav Kubernát | 654303f | 2020-07-31 13:16:54 +0200 | [diff] [blame] | 278 | auto root = m_session->get_data("/*"); |
Václav Kubernát | 70d7f7a | 2020-06-23 14:40:40 +0200 | [diff] [blame] | 279 | return root->print_mem(format == DataFormat::Xml ? LYD_XML : LYD_JSON, LYP_WITHSIBLINGS | LYP_FORMAT); |
| 280 | } |