Revision d776b3c3
b/snf-pithos-app/pithos/api/management/commands/pithos-set-quota.py | ||
---|---|---|
78 | 78 |
s = s.where(table['nodes'].c.node == table['versions'].c.node) |
79 | 79 |
s = s.where(table['nodes'].c.node.in_(select_descendants)) |
80 | 80 |
d2 = dict(conn.execute(s).fetchall()) |
81 |
|
|
82 |
for cluster in clusters:
|
|
81 |
|
|
82 |
for cluster in clusters: |
|
83 | 83 |
try: |
84 | 84 |
size = d2[cluster] |
85 | 85 |
except KeyError: |
86 |
size = 0
|
|
86 |
size = 0 |
|
87 | 87 |
append(Statistics( |
88 | 88 |
node=node, |
89 | 89 |
path=path, |
... | ... | |
117 | 117 |
import_limit=0, |
118 | 118 |
export_limit=0)) |
119 | 119 |
return add_quota |
120 |
|
|
121 |
|
|
120 |
|
|
121 |
|
|
122 | 122 |
class Command(NoArgsCommand): |
123 | 123 |
help = "Set quotaholder account quotas" |
124 | 124 |
|
... | ... | |
126 | 126 |
try: |
127 | 127 |
if not backend.quotaholder_url: |
128 | 128 |
raise CommandError('Quotaholder component url is not set') |
129 |
|
|
129 |
|
|
130 | 130 |
if not backend.quotaholder_token: |
131 | 131 |
raise CommandError('Quotaholder component token is not set') |
132 | 132 |
|
... | ... | |
135 | 135 |
s = s.where(and_(table['nodes'].c.node != 0, |
136 | 136 |
table['nodes'].c.parent == 0)) |
137 | 137 |
account_nodes = conn.execute(s).fetchall() |
138 |
|
|
138 |
|
|
139 | 139 |
# compute account statistics |
140 | 140 |
statistics = _compute_statistics(account_nodes) |
141 | 141 |
|
142 | 142 |
# verify and send quota |
143 | 143 |
add_quota = _get_verified_quota(statistics) |
144 | 144 |
|
145 |
result = backend.quotaholder.add_quota( |
|
146 |
context={}, |
|
147 |
clientkey='pithos', |
|
148 |
serial=42, |
|
149 |
sub_quota=[], |
|
150 |
add_quota=add_quota) |
|
151 |
if result: |
|
152 |
raise CommandError(result) |
|
153 |
finally: |
|
145 |
while True: |
|
146 |
result = backend.quotaholder.add_quota( |
|
147 |
context={}, |
|
148 |
clientkey='pithos', |
|
149 |
serial=42, |
|
150 |
sub_quota=[], |
|
151 |
add_quota=add_quota) |
|
152 |
|
|
153 |
if not result: |
|
154 |
break |
|
155 |
|
|
156 |
missing = [x[0] for x in result] |
|
157 |
self.stdout.write( |
|
158 |
'Unknown quotaholder accounts: %s\n' % ','.join(missing)) |
|
159 |
self.stdout.write('Try sending quota usage for the rest...\n') |
|
160 |
add_quota[:] = [x for x in add_quota if not x.holder in missing] |
|
161 |
finally: |
|
154 | 162 |
backend.close() |
Also available in: Unified diff