Revision 9f6760ee
b/snf-cyclades-app/synnefo/api/ports.py | ||
---|---|---|
36 | 36 |
from django.http import HttpResponse |
37 | 37 |
from django.utils import simplejson as json |
38 | 38 |
from django.db import transaction |
39 |
from django.db.models import Q |
|
40 | 39 |
from django.template.loader import render_to_string |
41 | 40 |
|
42 | 41 |
from snf_django.lib import api |
... | ... | |
85 | 84 |
network__userid=request.user_uniq) |
86 | 85 |
|
87 | 86 |
port_dicts = [port_to_dict(port, detail) |
88 |
for port in user_ports.order_by('id')] |
|
87 |
for port in user_ports.order_by('id')]
|
|
89 | 88 |
|
90 | 89 |
if request.serialization == 'xml': |
91 | 90 |
data = render_to_string('list_ports.xml', { |
... | ... | |
98 | 97 |
|
99 | 98 |
@api.api_method(http_method='POST', user_required=True, logger=log) |
100 | 99 |
def create_port(request): |
101 |
''' |
|
102 |
''' |
|
103 | 100 |
user_id = request.user_uniq |
104 | 101 |
req = api.utils.get_request_dict(request) |
105 | 102 |
log.info('create_port %s', req) |
... | ... | |
108 | 105 |
net_id = api.utils.get_attribute(port_dict, "network_id") |
109 | 106 |
dev_id = api.utils.get_attribute(port_dict, "device_id") |
110 | 107 |
|
111 |
network = util.get_network(net_id, request.user_uniq, non_deleted=True)
|
|
108 |
network = util.get_network(net_id, user_id, non_deleted=True)
|
|
112 | 109 |
|
113 | 110 |
if network.public: |
114 | 111 |
raise api.faults.Forbidden('forbidden') |
115 | 112 |
|
116 |
|
|
117 |
vm = util.get_vm(dev_id, request.user_uniq) |
|
113 |
vm = util.get_vm(dev_id, user_id) |
|
118 | 114 |
|
119 | 115 |
name = api.utils.get_attribute(port_dict, "name", required=False) |
120 | 116 |
|
... | ... | |
210 | 206 |
d['fixed_ips'] = [] |
211 | 207 |
for ip in port.ips.all(): |
212 | 208 |
d['fixed_ips'].append({"ip_address": ip.address, |
213 |
"subnet": str(ip.subnet.id)})
|
|
209 |
"subnet": str(ip.subnet.id)}) |
|
214 | 210 |
sg_list = list(port.security_groups.values_list('id', flat=True)) |
215 | 211 |
d['security_groups'] = map(str, sg_list) |
216 | 212 |
|
Also available in: Unified diff