utils: push values to sysrepo

Add a helper for setting Sysrepo values into a specified datastore. The
values are passed as a std::map (mapping XPath to a value) which
might simplify our life in future data manipulation.

There are two instances of the helper. The first one just pushes the data
into the current datastore of the session. The second one wraps around
the first one and it changes the session's datastore to the specified
one and restores the previous datastore after the changes are applied.

Change-Id: Ic0c374737047ef5944dbc4d8af34a6e364946c05
diff --git a/src/utils/sysrepo.cpp b/src/utils/sysrepo.cpp
index 23e3006..4d6ebe0 100644
--- a/src/utils/sysrepo.cpp
+++ b/src/utils/sysrepo.cpp
@@ -74,4 +74,26 @@
     }
 }
 
+/** @brief Set values into Sysrepo's specified datastore. It changes the datastore and after the data are applied, the original datastore is restored. */
+void valuesPush(const std::map<std::string, std::string>& values, std::shared_ptr<::sysrepo::Session> session, sr_datastore_t datastore)
+{
+    sr_datastore_t oldDatastore = session->session_get_ds();
+    session->session_switch_ds(datastore);
+
+    valuesPush(values, session);
+
+    session->apply_changes();
+    session->session_switch_ds(oldDatastore);
+}
+
+/** @brief Set values into Sysrepo's current datastore. */
+void valuesPush(const std::map<std::string, std::string>& values, std::shared_ptr<::sysrepo::Session> session)
+{
+    libyang::S_Data_Node edit;
+    valuesToYang(values, session, edit);
+
+    session->edit_batch(edit, "merge");
+    session->apply_changes();
+}
+
 }