Browse Source

Single srp_show sym for different datastores

Serj Kalichev 6 months ago
parent
commit
271fe68902
4 changed files with 8 additions and 17 deletions
  1. 0 2
      src/plugin.c
  2. 0 1
      src/private.h
  3. 7 13
      src/syms.c
  4. 1 1
      xml/sysrepo.xml

+ 0 - 2
src/plugin.c

@@ -107,8 +107,6 @@ int kplugin_sysrepo_init(kcontext_t *context)
 		KSYM_USERDEFINED_PERMANENT, KSYM_SYNC));
 	kplugin_add_syms(plugin, ksym_new_ext("srp_show", srp_show,
 		KSYM_USERDEFINED_PERMANENT, KSYM_SYNC));
-	kplugin_add_syms(plugin, ksym_new_ext("srp_show_running", srp_show_running,
-		KSYM_USERDEFINED_PERMANENT, KSYM_SYNC));
 	kplugin_add_syms(plugin, ksym_new_ext("srp_diff", srp_diff,
 		KSYM_USERDEFINED_PERMANENT, KSYM_SYNC));
 	kplugin_add_syms(plugin, ksym_new_ext("srp_deactivate", srp_deactivate,

+ 0 - 1
src/private.h

@@ -63,7 +63,6 @@ int srp_verify(kcontext_t *context);
 int srp_commit(kcontext_t *context);
 int srp_reset(kcontext_t *context);
 int srp_show(kcontext_t *context);
-int srp_show_running(kcontext_t *context);
 int srp_diff(kcontext_t *context);
 int srp_deactivate(kcontext_t *context);
 

+ 7 - 13
src/syms.c

@@ -917,22 +917,16 @@ err:
 
 int srp_show(kcontext_t *context)
 {
-	return show(context, SRP_REPO_EDIT);
-}
-
-
-int srp_show_running(kcontext_t *context)
-{
-	sr_session_ctx_t *sess = NULL;
+	sr_datastore_t ds = SRP_REPO_EDIT;
+	const char *script = NULL;
 
 	assert(context);
+	script = kcontext_script(context);
+	if (!faux_str_is_empty(script))
+		if (!kly_str2ds(script, strlen(script), &ds))
+			ds = SRP_REPO_EDIT;
 
-	sess = srp_udata_sr_sess(context);
-	sr_session_switch_ds(sess, SR_DS_RUNNING);
-	show_xpath(sess, NULL, srp_udata_opts(context));
-	sr_session_switch_ds(sess, SRP_REPO_EDIT);
-
-	return 0;
+	return show(context, ds);
 }
 
 

+ 1 - 1
xml/sysrepo.xml

@@ -78,7 +78,7 @@
 
 	<COMMAND name="show" help="Show" mode="switch">
 		<COMMAND name="running" help="Show running-config">
-			<ACTION sym="srp_show_running@sysrepo"/>
+			<ACTION sym="srp_show@sysrepo">running</ACTION>
 		</COMMAND>
 	</COMMAND>