Skip to content

Commit 8769257

Browse files
voetbergrdimaio
authored andcommitted
Client: Make behavior of 'rucio-admin scope list' and 'rucio list-scopes' the same rucio#7316
1 parent 3137892 commit 8769257

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

lib/rucio/cli/bin_legacy/rucio.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -516,15 +516,17 @@ def list_scopes(args, client, logger, console, spinner):
516516
517517
List scopes.
518518
"""
519-
# For the moment..
520-
521519
if cli_config == 'rich':
522520
spinner.update(status='Fetching scopes')
523521
spinner.start()
524522

525-
scopes = client.list_scopes()
523+
if args.account:
524+
scopes = client.list_scopes_for_account(args.account)
525+
else:
526+
scopes = client.list_scopes()
526527
if cli_config == 'rich':
527-
table = generate_table([[scope] for scope in sorted(scopes)], headers=['SCOPE'], col_alignments=['left'])
528+
scopes = [[scope] for scope in sorted(scopes) if 'mock' not in scope]
529+
table = generate_table(scopes, headers=['SCOPE'], col_alignments=['left'])
528530
spinner.stop()
529531
print_output(table, console=console, no_pager=args.no_pager)
530532
else:
@@ -2439,6 +2441,7 @@ def get_parser():
24392441
''')
24402442

24412443
scope_list_parser.set_defaults(function=list_scopes)
2444+
scope_list_parser.add_argument('--account', help='Filter scopes by account')
24422445

24432446
# The close command
24442447
close_parser = subparsers.add_parser('close', help='Close a dataset or container.')

lib/rucio/cli/bin_legacy/rucio_admin.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -781,8 +781,7 @@ def list_scopes(args, client, logger, console, spinner):
781781
print_output(table, console=console, no_pager=args.no_pager)
782782
else:
783783
for scope in scopes:
784-
if 'mock' not in scope:
785-
print(scope)
784+
print(scope)
786785
return SUCCESS
787786

788787

tests/test_bin_rucio.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,19 +134,30 @@ def test_attributes(random_account):
134134
@pytest.mark.dirty(reason="Creates a new scope on vo=def")
135135
def test_scope(random_account):
136136
"""CLIENT(ADMIN): Add/list/delete/list scope"""
137-
tmp_scp = scope_name_generator().replace("mock", "test")
137+
tmp_scp = scope_name_generator()
138138
cmd = f'rucio-admin scope add --account {random_account} --scope {tmp_scp}'
139139
exitcode, out, _ = execute(cmd)
140140
assert exitcode == 0
141141
assert f'Added new scope to {random_account}: {tmp_scp}' in out
142142

143-
cmd = 'rucio list-scopes'
143+
cmd = f'rucio-admin scope list --account {random_account}'
144144
exitcode, out, _ = execute(cmd)
145145
assert exitcode == 0
146146
assert tmp_scp in out
147147

148-
cmd = f'rucio-admin scope list --account {random_account}'
149-
exitcode, out, _ = execute(cmd)
148+
cmd = 'rucio-admin scope list'
149+
exitcode, out, err = execute(cmd)
150+
assert exitcode == 0
151+
assert tmp_scp in out
152+
153+
# Client should do the same
154+
cmd = 'rucio list-scopes'
155+
exitcode, out, err = execute(cmd)
156+
assert exitcode == 0
157+
assert tmp_scp in out
158+
159+
cmd = f'rucio list-scopes --account {random_account}'
160+
exitcode, out, err = execute(cmd)
150161
assert exitcode == 0
151162
assert tmp_scp in out
152163

0 commit comments

Comments
 (0)