diff options
author | Andrej Kozemcak <andrej.kozemcak@pantheon.tech> | 2018-12-13 09:10:36 +0100 |
---|---|---|
committer | Andrej Kozemcak <andrej.kozemcak@pantheon.tech> | 2018-12-17 11:37:46 +0000 |
commit | 6b408c5b3c885faa7bb5e4403d9515f18ab9426e (patch) | |
tree | f58f4045de4c158f380cfbbcdef2a6d917f9fcb7 /src/plugins | |
parent | 52872f7bc67c472ada9f8e62a7aabcc86b02b987 (diff) |
Init Openconfig pluging to sysrepo.
Change-Id: Icc14fe4af468a8f895e37aa53f68e5253e52a09e
Signed-off-by: Andrej Kozemcak <andrej.kozemcak@pantheon.tech>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/openconfig/openconfig_plugin.c | 16 | ||||
-rw-r--r-- | src/plugins/openconfig/openconfig_plugin.h | 8 | ||||
-rw-r--r-- | src/plugins/sc_plugins.c | 8 |
3 files changed, 32 insertions, 0 deletions
diff --git a/src/plugins/openconfig/openconfig_plugin.c b/src/plugins/openconfig/openconfig_plugin.c index 5d5582a..a47d687 100644 --- a/src/plugins/openconfig/openconfig_plugin.c +++ b/src/plugins/openconfig/openconfig_plugin.c @@ -263,3 +263,19 @@ void openconfig_unsubscribe(plugin_main_t* plugin_main) } while (plugin_subcscription != NULL); } } + +plugin_main_t plugin_main; + +int openconfig_plugin_init(sr_session_ctx_t* session) +{ + memset((void*) &plugin_main, 0, sizeof(plugin_main)); + + plugin_main.ds_running = session; + + openconfig_register_subscribe(&plugin_main); +} + +void openconfig_plugin_cleanup() +{ + openconfig_register_subscribe(&plugin_main); +} diff --git a/src/plugins/openconfig/openconfig_plugin.h b/src/plugins/openconfig/openconfig_plugin.h index 5f0c352..714ae7d 100644 --- a/src/plugins/openconfig/openconfig_plugin.h +++ b/src/plugins/openconfig/openconfig_plugin.h @@ -66,5 +66,13 @@ struct _sys_repo_call { int openconfig_register_subscribe(plugin_main_t *plugin_main); void openconfig_unsubscribe(plugin_main_t *plugin_main); +//FIXME: +// This solution is not good and should be rewrite. +// But first we must discuss the architecture of sweetcomb and how we should +// register the new YANGS modules. +// This function here is only for test. +int openconfig_plugin_init(sr_session_ctx_t *session); +void openconfig_plugin_cleanup(); + #endif /* __SWEETCOMB_OPENCONFIG_PLUGIN__ */ diff --git a/src/plugins/sc_plugins.c b/src/plugins/sc_plugins.c index 29d75bb..1a09654 100644 --- a/src/plugins/sc_plugins.c +++ b/src/plugins/sc_plugins.c @@ -41,6 +41,8 @@ DEFINE_VAPI_MSG_IDS_HC_API_JSON; //#include "sc_l2.h" //#include "sc_vxlan.h" +#include "openconfig/openconfig_plugin.h" + int sr_plugin_init_cb(sr_session_ctx_t *session, void **private_ctx) { SC_INVOKE_BEGIN; @@ -61,6 +63,9 @@ int sr_plugin_init_cb(sr_session_ctx_t *session, void **private_ctx) //INTERFACE sc_interface_subscribe_events(session, &subscription); + //Openconfig modules + openconfig_plugin_init(session); + /* set subscription as our private context */ *private_ctx = subscription; SC_INVOKE_END; @@ -70,6 +75,9 @@ int sr_plugin_init_cb(sr_session_ctx_t *session, void **private_ctx) void sr_plugin_cleanup_cb(sr_session_ctx_t *session, void *private_ctx) { SC_INVOKE_BEGIN; + + openconfig_plugin_clean(); + /* subscription was set as our private context */ sr_unsubscribe(session, private_ctx); SC_LOG_DBG_MSG("unload plugin ok."); |