-
Notifications
You must be signed in to change notification settings - Fork 2
/
check_cloud_users.py
executable file
·51 lines (41 loc) · 1.2 KB
/
check_cloud_users.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python3
from multiprocessing import Pool
from rucio.client import Client
from rucio.client.accountclient import AccountClient
from rucio.client.accountlimitclient import AccountLimitClient
import getopt
import sys
rclient = Client()
accclient = AccountClient()
acclimitclient = AccountLimitClient()
MY_RSE = 'UNI-BONN_LOCALGROUPDISK'
def check_in_cloud(acc):
is_in_cloud = False
attrs = list(accclient.list_account_attributes(acc['account']))[0]
for kv in attrs:
if (kv['key'] == 'country-de'):
is_in_cloud = True
break
return is_in_cloud
def get_limit(acc):
limit = accclient.get_local_account_limit(acc['account'], MY_RSE)
if limit:
return limit[MY_RSE]
else:
return {}
def main(argv):
pool = Pool(24)
accdict = list(accclient.list_accounts())
res_in_cloud = pool.map(check_in_cloud, accdict)
res_limit = pool.map(get_limit, accdict)
for A in range(0,len(accdict)):
#print(accdict[A])
if res_limit[A]:
if not res_in_cloud[A]:
print("Error: Account ",accdict[A]," not in cloud anymore, but still has quota!")
else:
if res_in_cloud[A]:
print("Warning: Account ",accdict[A]," in cloud, but has no quota!")
print("")
if __name__ == "__main__":
main(sys.argv[1:])