Merge "Fix remove_disabled_extensions to remove an extension at the last position"
This commit is contained in:
commit
7b71d376f9
@ -1629,7 +1629,6 @@ function disable_all_services {
|
|||||||
function disable_negated_services {
|
function disable_negated_services {
|
||||||
local to_remove=""
|
local to_remove=""
|
||||||
local remaining=""
|
local remaining=""
|
||||||
local enabled=""
|
|
||||||
local service
|
local service
|
||||||
|
|
||||||
# build up list of services that should be removed; i.e. they
|
# build up list of services that should be removed; i.e. they
|
||||||
@ -1644,21 +1643,7 @@ function disable_negated_services {
|
|||||||
|
|
||||||
# go through the service list. if this service appears in the "to
|
# go through the service list. if this service appears in the "to
|
||||||
# be removed" list, drop it
|
# be removed" list, drop it
|
||||||
for service in ${remaining//,/ }; do
|
ENABLED_SERVICES=$(remove_disabled_services "$remaining" "$to_remove")
|
||||||
local remove
|
|
||||||
local add=1
|
|
||||||
for remove in ${to_remove//,/ }; do
|
|
||||||
if [[ ${remove} == ${service} ]]; then
|
|
||||||
add=0
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if [[ $add == 1 ]]; then
|
|
||||||
enabled="${enabled},$service"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
ENABLED_SERVICES=$(_cleanup_service_list "$enabled")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# disable_service() removes the services passed as argument to the
|
# disable_service() removes the services passed as argument to the
|
||||||
@ -1762,6 +1747,30 @@ function is_service_enabled {
|
|||||||
return $enabled
|
return $enabled
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# remove specified list from the input string
|
||||||
|
# remove_disabled_services service-list remove-list
|
||||||
|
function remove_disabled_services {
|
||||||
|
local service_list=$1
|
||||||
|
local remove_list=$2
|
||||||
|
local service
|
||||||
|
local enabled=""
|
||||||
|
|
||||||
|
for service in ${service_list//,/ }; do
|
||||||
|
local remove
|
||||||
|
local add=1
|
||||||
|
for remove in ${remove_list//,/ }; do
|
||||||
|
if [[ ${remove} == ${service} ]]; then
|
||||||
|
add=0
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [[ $add == 1 ]]; then
|
||||||
|
enabled="${enabled},$service"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
_cleanup_service_list "$enabled"
|
||||||
|
}
|
||||||
|
|
||||||
# Toggle enable/disable_service for services that must run exclusive of each other
|
# Toggle enable/disable_service for services that must run exclusive of each other
|
||||||
# $1 The name of a variable containing a space-separated list of services
|
# $1 The name of a variable containing a space-separated list of services
|
||||||
# $2 The name of a variable in which to store the enabled service's name
|
# $2 The name of a variable in which to store the enabled service's name
|
||||||
|
@ -91,10 +91,7 @@ function remove_disabled_extensions {
|
|||||||
local extensions_list=$1
|
local extensions_list=$1
|
||||||
shift
|
shift
|
||||||
local disabled_exts=$*
|
local disabled_exts=$*
|
||||||
for ext_to_remove in ${disabled_exts//,/ } ; do
|
remove_disabled_services "$extensions_list" "$disabled_exts"
|
||||||
extensions_list=${extensions_list/$ext_to_remove","}
|
|
||||||
done
|
|
||||||
echo $extensions_list
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# configure_tempest() - Set config files, create data dirs, etc
|
# configure_tempest() - Set config files, create data dirs, etc
|
||||||
|
@ -137,6 +137,31 @@ test_disable_negated_services 'a,aa,-a' 'aa'
|
|||||||
test_disable_negated_services 'a,av2,-a,a' 'av2'
|
test_disable_negated_services 'a,av2,-a,a' 'av2'
|
||||||
test_disable_negated_services 'a,-a,av2' 'av2'
|
test_disable_negated_services 'a,-a,av2' 'av2'
|
||||||
|
|
||||||
|
echo "Testing remove_disabled_services()"
|
||||||
|
|
||||||
|
function test_remove_disabled_services {
|
||||||
|
local service_list="$1"
|
||||||
|
local remove_list="$2"
|
||||||
|
local expected="$3"
|
||||||
|
|
||||||
|
results=$(remove_disabled_services "$service_list" "$remove_list")
|
||||||
|
if [ "$results" = "$expected" ]; then
|
||||||
|
passed "OK: '$service_list' - '$remove_list' -> '$results'"
|
||||||
|
else
|
||||||
|
failed "getting '$expected' from '$service_list' - '$remove_list' failed: '$results'"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
test_remove_disabled_services 'a,b,c' 'a,c' 'b'
|
||||||
|
test_remove_disabled_services 'a,b,c' 'b' 'a,c'
|
||||||
|
test_remove_disabled_services 'a,b,c,d' 'a,c d' 'b'
|
||||||
|
test_remove_disabled_services 'a,b c,d' 'a d' 'b,c'
|
||||||
|
test_remove_disabled_services 'a,b,c' 'a,b,c' ''
|
||||||
|
test_remove_disabled_services 'a,b,c' 'd' 'a,b,c'
|
||||||
|
test_remove_disabled_services 'a,b,c' '' 'a,b,c'
|
||||||
|
test_remove_disabled_services '' 'a,b,c' ''
|
||||||
|
test_remove_disabled_services '' '' ''
|
||||||
|
|
||||||
echo "Testing is_package_installed()"
|
echo "Testing is_package_installed()"
|
||||||
|
|
||||||
if [[ -z "$os_PACKAGE" ]]; then
|
if [[ -z "$os_PACKAGE" ]]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user