Revision bdedfd9d snf-cyclades-app/synnefo/api/subnets.py
b/snf-cyclades-app/synnefo/api/subnets.py | ||
---|---|---|
80 | 80 |
def list_subnets(request, detail=True): |
81 | 81 |
"""List all subnets of a user""" |
82 | 82 |
userid = request.user_uniq |
83 |
subnets_list = Subnet.objects.filter(Q(network__public=True) |
|
|
84 |
(Q(network__userid=userid) &
|
|
85 |
Q(network__public=False)))\
|
|
83 |
subnets_list = Subnet.objects.filter(Q(public=True) | |
|
84 |
(Q(userid=userid) & |
|
85 |
Q(public=False)))\ |
|
86 | 86 |
.order_by("id") |
87 |
subnets_list = subnets_list.prefetch_related("ip_pools")\ |
|
88 |
.select_related("network") |
|
87 |
subnets_list = subnets_list.prefetch_related("ip_pools") |
|
89 | 88 |
subnets_list = api.utils.filter_modified_since(request, |
90 | 89 |
objects=subnets_list) |
91 | 90 |
|
... | ... | |
215 | 214 |
allocation_pools = [render_ip_pool(pool) |
216 | 215 |
for pool in subnet.ip_pools.all()] |
217 | 216 |
|
218 |
network = subnet.network |
|
219 | 217 |
d = {'id': str(subnet.id), |
220 | 218 |
'network_id': str(subnet.network_id), |
221 | 219 |
'name': subnet.name if subnet.name is not None else "", |
222 |
'tenant_id': network.userid, |
|
223 |
'user_id': network.userid, |
|
220 |
'tenant_id': subnet.userid, |
|
221 |
'user_id': subnet.userid, |
|
222 |
'public': subnet.public, |
|
224 | 223 |
'gateway_ip': subnet.gateway, |
225 | 224 |
'ip_version': subnet.ipversion, |
226 | 225 |
'cidr': subnet.cidr, |
Also available in: Unified diff