MT#15803 Add ngcpcfg log/show scripts to improve usability

Change-Id: I56f3c6d6cb5187ac471e0ae05ff313f24803fc1c
changes/14/3014/6
Alexander Lutay 11 years ago
parent ef891f3560
commit e8f7ce894e

@ -18,6 +18,8 @@ scripts/commit usr/share/ngcp-ngcpcfg/scripts/
scripts/diff usr/share/ngcp-ngcpcfg/scripts/
scripts/etckeeper usr/share/ngcp-ngcpcfg/scripts/
scripts/initialise usr/share/ngcp-ngcpcfg/scripts/
scripts/log usr/share/ngcp-ngcpcfg/scripts/
scripts/services usr/share/ngcp-ngcpcfg/scripts/
scripts/show usr/share/ngcp-ngcpcfg/scripts/
scripts/status usr/share/ngcp-ngcpcfg/scripts/
scripts/values usr/share/ngcp-ngcpcfg/scripts/

@ -284,6 +284,10 @@ sip:carrier environment. Further details about the details of the setup
are available in the <<init-mgmt>> section.
Note: This feature is only available if the ngcp-ngcpcfg-carrier package is installed.
**log** [-p]::
Prints the log of local changes. Expand all changes if '-p' option is specified.
**pull**::
Retrieve modifications from shared repository.
@ -311,6 +315,11 @@ _--dry-run_ option is present the services won't be executed but you'll be
noticed which service files would be executed if being invoked without the
_--dry-run__ option.
**show** [<change_id>]::
Display the change details for specified <change_id>. Show the latest change if
no <change_id> is specified.
**status** [--local-only]::
Display the current state of the configuration system, like modified
@ -319,7 +328,6 @@ Note: The _--local-only_ option is available in the High Availability setup
only and disables checking any remote systems (useful when the remote
system isn't available).
**values** <key>::
Prints the value of <key> using ngcp config files as source.

@ -88,6 +88,15 @@ values() {
"${SCRIPTS}"/values $*
}
log() {
log_debug "${SCRIPTS}/log $*"
"${SCRIPTS}"/log $*
}
show() {
log_debug "${SCRIPTS}/show $*"
"${SCRIPTS}"/show $*
}
usage() {
# make sure to output errors on stderr
@ -104,6 +113,8 @@ usage() {
$PN initialise - initialise setup (to be executed only once on setup)
$PN check - validate YAML configuration files
$PN values - print key value from YAML configuration files
$PN log [opt] - show log of config changes
$PN show [id] - show latest config change (if id is specified show specified id instead)
"
# display only if ngcp-ngcpcfg-ha is available
@ -151,6 +162,8 @@ case ${1:-} in
diff) shift ; diff "$*" ;;
init-mgmt) shift ; init-mgmt "$*" ;;
values) shift ; values "$*" ;;
log) shift ; log "$*" ;;
show) shift ; show "$*" ;;
--debug) export DEBUG=1 ; shift ; $0 $* ;;
--no-db-sync) export NO_DB_SYNC=1 ; shift ; $0 $* ;;
--no-validate) export NO_VALIDATE=1; shift ; $0 $* ;;

@ -0,0 +1,38 @@
#!/bin/bash
# Purpose: show ngcpcfg log (git log) in human readable format
################################################################################
set -e
set -u
# support testsuite
FUNCTIONS="${FUNCTIONS:-/usr/share/ngcp-ngcpcfg/functions/}"
HELPER="${HELPER:-/usr/share/ngcp-ngcpcfg/helper/}"
if ! [ -r "${FUNCTIONS}"/main ] ; then
printf "Error: %s/main could not be read. Exiting.\n" "${FUNCTIONS}" >&2
exit 1
fi
. "${FUNCTIONS}"/main
cd "$NGCPCTL_MAIN"
if [ -f "${FUNCTIONS}/ha_features" ] ; then
if ! git remote update origin >/dev/null 2>&1 ; then
log_error "Failed to fetch changes from shared repository"
exit 1
fi
git log $* --oneline --date-order --graph --date=rfc --format=format:"%h (%ar) %s %d" master origin/master
else
git log $* --oneline --date-order --graph --date=rfc --format=format:"%h (%ar) %s %d" master
fi
exit 0
## END OF FILE #################################################################

@ -0,0 +1,31 @@
#!/bin/bash
# Purpose: show ngcpcfg changes (git show) as part of ngcpcfg framework
################################################################################
set -e
set -u
# support testsuite
FUNCTIONS="${FUNCTIONS:-/usr/share/ngcp-ngcpcfg/functions/}"
HELPER="${HELPER:-/usr/share/ngcp-ngcpcfg/helper/}"
if ! [ -r "${FUNCTIONS}"/main ] ; then
printf "Error: %s/main could not be read. Exiting.\n" "${FUNCTIONS}" >&2
exit 1
fi
. "${FUNCTIONS}"/main
if [ "$*" = "" ] ; then
git_commit="HEAD"
else
git_commit="$*"
fi
cd "$NGCPCTL_MAIN"
git show ${git_commit}
exit 0
## END OF FILE #################################################################
Loading…
Cancel
Save