Revision 883c1f94 snf-cyclades-app/synnefo/api/ports.py
b/snf-cyclades-app/synnefo/api/ports.py | ||
---|---|---|
85 | 85 |
|
86 | 86 |
user_ports = NetworkInterface.objects.filter(userid=request.user_uniq) |
87 | 87 |
|
88 |
if detail: |
|
89 |
user_ports = user_ports.prefetch_related("ips") |
|
90 |
|
|
88 | 91 |
port_dicts = [port_to_dict(port, detail) |
89 | 92 |
for port in user_ports.order_by('id')] |
90 | 93 |
|
... | ... | |
246 | 249 |
d['mac_address'] = port.mac |
247 | 250 |
d['status'] = port.state |
248 | 251 |
d['device_owner'] = port.device_owner |
249 |
d['network_id'] = str(port.network.id)
|
|
252 |
d['network_id'] = str(port.network_id)
|
|
250 | 253 |
d['updated'] = api.utils.isoformat(port.updated) |
251 | 254 |
d['created'] = api.utils.isoformat(port.created) |
252 | 255 |
d['fixed_ips'] = [] |
253 | 256 |
for ip in port.ips.all(): |
254 | 257 |
d['fixed_ips'].append({"ip_address": ip.address, |
255 |
"subnet": str(ip.subnet.id)}) |
|
256 |
sg_list = list(port.security_groups.values_list('id', flat=True)) |
|
257 |
d['security_groups'] = map(str, sg_list) |
|
258 |
"subnet": str(ip.subnet_id)}) |
|
259 |
# Avoid extra queries until security groups are implemented! |
|
260 |
#sg_list = list(port.security_groups.values_list('id', flat=True)) |
|
261 |
d['security_groups'] = [] |
|
258 | 262 |
|
259 | 263 |
return d |
260 | 264 |
|
Also available in: Unified diff