Commit 63f01f60 authored by Dionysis Grigoropoulos's avatar Dionysis Grigoropoulos
Browse files

cyclades: Return 'links' in subnet and port calls

* Return 'links' attribute in subnet api response
* Return 'links' attribute in port api response
parent bdf75ba2
......@@ -227,6 +227,7 @@ def delete_port(request, port_id):
def port_to_dict(port, detail=True):
d = {'id': str(, 'name':}
d['links'] = util.port_to_links(
if detail:
user_id = port.userid
machine_id = port.machine_id
......@@ -41,6 +41,7 @@ from django.utils import simplejson as json
from snf_django.lib.api import utils
from synnefo.db.models import Subnet
from synnefo.logic import subnets
from synnefo.api import util
import ipaddr
......@@ -231,6 +232,7 @@ def subnet_to_dict(subnet):
if subnet.ipversion == 6:
dictionary['enable_slaac'] = subnet.dhcp
dictionary['links'] = util.subnet_to_links(
return dictionary
......@@ -435,6 +435,16 @@ def network_to_links(network_id):
return [{"rel": rel, "href": href} for rel in ("self", "bookmark")]
def subnet_to_links(subnet_id):
href = join_urls(SUBNETS_URL, str(subnet_id))
return [{"rel": rel, "href": href} for rel in ("self", "bookmark")]
def port_to_links(port_id):
href = join_urls(PORTS_URL, str(port_id))
return [{"rel": rel, "href": href} for rel in ("self", "bookmark")]
def flavor_to_links(flavor_id):
href = join_urls(FLAVORS_URL, str(flavor_id))
return [{"rel": rel, "href": href} for rel in ("self", "bookmark")]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment