-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathget_config.cc
43 lines (32 loc) · 997 Bytes
/
get_config.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <iostream>
#include "yang-kea.h"
#include "sysrepo.h"
using namespace std;
int main(int argc, const char *argv[]) {
int rc = SR_ERR_OK;
sr_conn_ctx_t *conn = NULL;
sr_session_ctx_t *sess = NULL;
rc = sr_connect("pull kea config", SR_CONN_DEFAULT, &conn);
if (rc != SR_ERR_OK) {
cerr << "Failed to create session" << endl;
return (EXIT_FAILURE);
}
rc = sr_session_start(conn, SR_DS_STARTUP, SR_SESS_DEFAULT, &sess);
if (rc != SR_ERR_OK) {
cerr << "Failed to start session" << endl;
return (EXIT_FAILURE);
}
SysrepoKea yang(sess);
std::string json = yang.getConfig();
cout << "Received JSON config is " << json.length() << " bytes long."
<< endl;
cout << json;
int status = EXIT_SUCCESS;
rc = sr_session_stop(sess);
if (rc != SR_ERR_OK) {
cerr << "Failed to stop session" << endl;
status = EXIT_FAILURE;
}
sr_disconnect(conn);
return (status);
}