Revision b7e79bf3
b/snf-cyclades-app/synnefo/api/subnets.py | ||
---|---|---|
164 | 164 |
def get_subnet(request, sub_id): |
165 | 165 |
"""Show info of a specific subnet""" |
166 | 166 |
user_id = request.user_uniq |
167 |
subnet = subnets.get_subnet(sub_id, prefetch_related=True)
|
|
167 |
subnet = subnets.get_subnet(sub_id) |
|
168 | 168 |
|
169 | 169 |
if (subnet.network.userid != user_id) and (subnet.network.public is False): |
170 | 170 |
raise api.faults.Unauthorized("You're not allowed to view this subnet") |
b/snf-cyclades-app/synnefo/api/util.py | ||
---|---|---|
222 | 222 |
|
223 | 223 |
try: |
224 | 224 |
network_id = int(network_id) |
225 |
objects = Network.objects.prefetch_related("subnets")
|
|
225 |
objects = Network.objects |
|
226 | 226 |
if for_update: |
227 | 227 |
objects = objects.select_for_update() |
228 | 228 |
network = objects.get(Q(userid=user_id) | Q(public=True), |
b/snf-cyclades-app/synnefo/logic/subnets.py | ||
---|---|---|
148 | 148 |
return sub |
149 | 149 |
|
150 | 150 |
|
151 |
def get_subnet(sub_id, prefetch_related=False):
|
|
151 |
def get_subnet(sub_id): |
|
152 | 152 |
"""Show info of a specific subnet""" |
153 | 153 |
log.debug('get_subnet %s', sub_id) |
154 | 154 |
try: |
155 | 155 |
subnets = Subnet.objects |
156 |
if prefetch_related: |
|
157 |
subnets = subnets.select_related("network") |
|
158 |
subnets = subnets.prefetch_related("ip_pools") |
|
159 | 156 |
return subnets.get(id=sub_id) |
160 | 157 |
except Subnet.DoesNotExist: |
161 | 158 |
raise api.faults.ItemNotFound("Subnet not found") |
Also available in: Unified diff