Revision d2c3c533 snf-cyclades-app/synnefo/logic/servers.py
b/snf-cyclades-app/synnefo/logic/servers.py | ||
---|---|---|
274 | 274 |
port = util.get_port(port_id, userid, for_update=True) |
275 | 275 |
ports.append(port) |
276 | 276 |
elif net_id is not None: |
277 |
address = net.get("fixed_ip") |
|
277 | 278 |
network = util.get_network(net_id, userid, non_deleted=True) |
278 | 279 |
if network.public: |
279 |
raise faults.Forbidden("Can not connect to public network") |
|
280 |
address = net.get("fixed_ip") |
|
281 |
port = _create_port(userid, network, address=address) |
|
280 |
if address is None: |
|
281 |
msg = ("Can not connect to public network %s. Specify" |
|
282 |
" 'fixed_ip'" " attribute to connect to a public" |
|
283 |
" network") |
|
284 |
raise faults.BadRequest(msg % network.id) |
|
285 |
floating_ip = util.get_floating_ip_by_address(userid, |
|
286 |
address, |
|
287 |
for_update=True) |
|
288 |
port = _create_port(userid, network, use_ipaddress=floating_ip) |
|
289 |
else: |
|
290 |
port = _create_port(userid, network, address=address) |
|
282 | 291 |
ports.append(port) |
283 | 292 |
else: |
284 |
raise faults.BadRequest("") |
|
293 |
raise faults.BadRequest("Network 'uuid' or 'port' attribute" |
|
294 |
" is required.") |
|
285 | 295 |
|
286 | 296 |
for index, port in enumerate(ports): |
287 | 297 |
associate_port_with_machine(port, vm) |
Also available in: Unified diff