Revision 24ea227b
b/snf-cyclades-app/synnefo/api/ports.py | ||
---|---|---|
227 | 227 |
|
228 | 228 |
def port_to_dict(port, detail=True): |
229 | 229 |
d = {'id': str(port.id), 'name': port.name} |
230 |
d['links'] = util.port_to_links(port.id) |
|
230 | 231 |
if detail: |
231 | 232 |
user_id = port.userid |
232 | 233 |
machine_id = port.machine_id |
b/snf-cyclades-app/synnefo/api/subnets.py | ||
---|---|---|
41 | 41 |
from snf_django.lib.api import utils |
42 | 42 |
from synnefo.db.models import Subnet |
43 | 43 |
from synnefo.logic import subnets |
44 |
from synnefo.api import util |
|
44 | 45 |
|
45 | 46 |
import ipaddr |
46 | 47 |
|
... | ... | |
231 | 232 |
if subnet.ipversion == 6: |
232 | 233 |
dictionary['enable_slaac'] = subnet.dhcp |
233 | 234 |
|
235 |
dictionary['links'] = util.subnet_to_links(subnet.id) |
|
234 | 236 |
return dictionary |
235 | 237 |
|
236 | 238 |
|
b/snf-cyclades-app/synnefo/api/util.py | ||
---|---|---|
435 | 435 |
return [{"rel": rel, "href": href} for rel in ("self", "bookmark")] |
436 | 436 |
|
437 | 437 |
|
438 |
def subnet_to_links(subnet_id): |
|
439 |
href = join_urls(SUBNETS_URL, str(subnet_id)) |
|
440 |
return [{"rel": rel, "href": href} for rel in ("self", "bookmark")] |
|
441 |
|
|
442 |
|
|
443 |
def port_to_links(port_id): |
|
444 |
href = join_urls(PORTS_URL, str(port_id)) |
|
445 |
return [{"rel": rel, "href": href} for rel in ("self", "bookmark")] |
|
446 |
|
|
447 |
|
|
438 | 448 |
def flavor_to_links(flavor_id): |
439 | 449 |
href = join_urls(FLAVORS_URL, str(flavor_id)) |
440 | 450 |
return [{"rel": rel, "href": href} for rel in ("self", "bookmark")] |
Also available in: Unified diff