aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorHongjun Ni <hongjun.ni@intel.com>2018-12-19 02:23:47 +0000
committerGerrit Code Review <gerrit@fd.io>2018-12-19 02:23:47 +0000
commitb4ac4503a9ed4b3aad9dc3f236b1052248214ebc (patch)
tree6e8ce96e24e462b47766df1082fd53a57a6aa0c6 /src/plugins
parent9c702c398034d38a9e3e81600b676e371dc66268 (diff)
parent6b408c5b3c885faa7bb5e4403d9515f18ab9426e (diff)
Merge "Init Openconfig pluging to sysrepo."
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/openconfig/openconfig_plugin.c16
-rw-r--r--src/plugins/openconfig/openconfig_plugin.h8
-rw-r--r--src/plugins/sc_plugins.c8
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.");