Skip to content

Commit 74a398e

Browse files
authored
Quota: limit scope (#120)
1 parent 0f1b2dc commit 74a398e

File tree

1 file changed

+7
-45
lines changed

1 file changed

+7
-45
lines changed

ada/ada

Lines changed: 7 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,9 @@ usage() {
228228
The pinned (sticky) capacity can be calculated with:
229229
"ada ... | jq '.total - .free - .precious - .removable'"
230230
231-
--quota <all|own>
232-
Shows storage quotas, for tape (custodial) and for disk (replica).
233-
With 'all' (default), shows all quotas.
234-
With 'own', shows only quotas for your own user ID and/or
235-
your primary group ID.
231+
--quota
232+
Shows your storage quotas, for tape (custodial) and for disk (replica),
233+
user based as well as group based.
236234
237235
238236
Configuration files:
@@ -678,22 +676,6 @@ get_args() {
678676
;;
679677
--quota )
680678
command='quota'
681-
case $2 in
682-
own | all )
683-
# Quota scope has been specified by user.
684-
quota_scope="$2"
685-
shift
686-
;;
687-
--* | '' )
688-
# Next argument is another option or absent; not a scope.
689-
# Use default scope 'all'
690-
quota_scope=all
691-
;;
692-
* )
693-
echo 1>&2 "ERROR: '$2' is not a valid scope for --quota. Use 'own' or 'all' (default)"
694-
exit 1
695-
;;
696-
esac
697679
shift
698680
;;
699681
--igtf )
@@ -1920,19 +1902,6 @@ get_dcache_versions () {
19201902

19211903

19221904
get_quota () {
1923-
local quota_scope="$1"
1924-
case $quota_scope in
1925-
own | '' )
1926-
query_parameter='user=true'
1927-
;;
1928-
all )
1929-
query_parameter='user=false'
1930-
;;
1931-
* )
1932-
echo 1>&2 "ERROR: quota scope is $quota_scope, but should be either 'own' or 'all'."
1933-
exit 1
1934-
;;
1935-
esac
19361905
# Show quotas, for disk and tape, and for user(s) and group(s).
19371906
# We use bash arrays for this. For that, we need a fresh bash.
19381907
if [ "${BASH_VERSINFO[0]}" -lt 4 ] ; then
@@ -1951,7 +1920,7 @@ get_quota () {
19511920
"${curl_options_common[@]}" \
19521921
--silent --show-error \
19531922
--write-out "\nHTTP_CODE_%{http_code}" \
1954-
-X GET "$api/quota/${quota_type}?${query_parameter}" 2>&1
1923+
-X GET "$api/quota/${quota_type}?user=true" 2>&1
19551924
)
19561925
status=$(echo "$response" | grep '^HTTP_CODE') # HTTP return code
19571926
case $status in
@@ -2013,14 +1982,7 @@ get_quota () {
20131982
# No quota found. If user ran `ada --quota`, show message.
20141983
# If the user ran `ada --whoami`, we don't need to show a message; it would only be confusing.
20151984
if [ "$command" == "quota" ] ; then
2016-
case $quota_scope in
2017-
own )
2018-
echo 1>&2 "You do not have any quota set on your user ID or primary group ID."
2019-
;;
2020-
all )
2021-
echo 1>&2 "No quota found on this dCache system."
2022-
;;
2023-
esac
1985+
echo 1>&2 "You do not have any quota set on your user ID or primary group ID."
20241986
fi
20251987
fi
20261988
}
@@ -2405,7 +2367,7 @@ api_call () {
24052367
-X GET "$api/user" \
24062368
| jq .
24072369
)
2408-
get_quota own
2370+
get_quota
24092371
;;
24102372
list )
24112373
type=$(pathtype "$path")
@@ -2956,7 +2918,7 @@ api_call () {
29562918
fi
29572919
;;
29582920
quota )
2959-
get_quota "$quota_scope"
2921+
get_quota
29602922
;;
29612923
* )
29622924
echo "Command '$command' is not implemented (yet)."

0 commit comments

Comments
 (0)