From 9ae492ab9b1c77369264efc71d2960c1b834ba2f Mon Sep 17 00:00:00 2001
From: John Estabrook <jestabro@vyos.io>
Date: Wed, 18 Jan 2023 21:58:14 -0600
Subject: config-mgmt: T4942: use vyos-1x config-mgmt scripts

---
 etc/bash_completion.d/vyatta-cfg     |  9 +--------
 functions/interpreter/vyatta-cfg-run | 13 +++++++------
 2 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/etc/bash_completion.d/vyatta-cfg b/etc/bash_completion.d/vyatta-cfg
index eb07616..c679374 100644
--- a/etc/bash_completion.d/vyatta-cfg
+++ b/etc/bash_completion.d/vyatta-cfg
@@ -245,14 +245,7 @@ vyatta_loadkey_complete()
 
 print_commit_log ()
 {
-  local -a array
-  eval "array=($(${vyatta_sbindir}/vyatta-config-mgmt.pl --action=show-commit-log-brief))"
-  local count=0
-  for i in "${array[@]}"; do
-     i=${i//_/ }
-     echo -e "    $count\t$i"
-     (( count++ ))
-  done
+  ${vyos_op_scripts_dir}/config_mgmt.py show_commit_log_brief
 }
 
 vyatta_rollback_complete ()
diff --git a/functions/interpreter/vyatta-cfg-run b/functions/interpreter/vyatta-cfg-run
index 5e0ce42..4280159 100644
--- a/functions/interpreter/vyatta-cfg-run
+++ b/functions/interpreter/vyatta-cfg-run
@@ -152,17 +152,18 @@ vyatta_config_commit-confirm ()
       args[${#args[@]}]="$arg"    
     fi
   done
-  cmd="${vyatta_sbindir}/vyatta-config-mgmt.pl --action=commit-confirm \
-                                               --minutes=$minutes"
+  cmd="${vyos_bin_dir}/config-mgmt commit_confirm -t=$minutes"
   eval "sudo sg vyattacfg \"$cmd\" "
   if [ $? = 0 ]; then
+    export IN_COMMIT_CONFIRM=t
     vyatta_config_commit "$@"
+    unset IN_COMMIT_CONFIRM
   fi
 }
 
 vyatta_config_confirm ()
 {
-  ${vyatta_sbindir}/vyatta-config-mgmt.pl --action=confirm
+  ${vyos_bin_dir}/config-mgmt confirm
 }
 
 vyatta_config_compare ()
@@ -171,9 +172,9 @@ vyatta_config_compare ()
   local -a filtered=()
   get_prefix_filtered_list $1 comp filtered
   if [[ "${filtered[0]}" == "saved" ]]; then
-     cli-shell-api showConfig --show-cfg1 /config/config.boot --show-cfg2 @WORKING --show-context-diff
+     ${vyos_bin_dir}/config-mgmt compare --saved
   else  
-     ${vyatta_sbindir}/vyatta-config-mgmt.pl --action=diff "$@" | eval "${VYATTA_PAGER:-cat}"
+     ${vyos_bin_dir}/config-mgmt wrap_compare --options "$@" | eval "${VYATTA_PAGER:-cat}"
   fi 
 }
 
@@ -210,7 +211,7 @@ vyatta_config_rollback ()
     echo "Error: must include a revision # to rollback to"
     return 1;
   fi
-  sudo ${vyatta_sbindir}/vyatta-config-mgmt.pl --action=rollback --revnum "$@"
+  sudo ${vyos_bin_dir}/config-mgmt rollback --rev "$@"
 }
 
 shutdown ()
-- 
cgit v1.2.3