Revision 5d83d2ff snf-cyclades-app/synnefo/api/subnets.py

b/snf-cyclades-app/synnefo/api/subnets.py
77 77
@api.api_method(http_method='GET', user_required=True, logger=log)
78 78
def list_subnets(request):
79 79
    """List all subnets of a user"""
80
    subnets_dict = subnets.list_subnets(request.user_uniq)
80
    subnet_list = subnets.list_subnets(request.user_uniq)
81
    subnets_dict = [subnet_to_dict(sub)
82
                    for sub in subnet_list.order_by('id')]
83

  
81 84
    data = json.dumps({'subnets': subnets_dict})
82 85

  
83 86
    return HttpResponse(data, status=200)
......
104 107
        pool = parse_ip_pools(allocation_pools)
105 108
        allocation_pools = string_to_ipaddr(pool)
106 109

  
110
    name = subnet.get('name', None)
111
    ipversion = subnet.get('ip_version', 4)
112
    gateway = subnet.get('gateway_ip', None)
113
    dhcp = subnet.get('enable_dhcp', True)
114
    slac = subnet.get('enable_slac', None)
115
    dns = subnet.get('dns_nameservers', None)
116
    hosts = subnet.get('host_routes', None)
117

  
107 118
    sub = subnets.create_subnet(network_id=network_id,
108 119
                                cidr=cidr,
109 120
                                name=name,
......
130 141
    if subnet.network.userid != user_id:
131 142
        raise api.failts.Unauthorized("You're not allowed to view this subnet")
132 143

  
133
    subnet_dict = subnet
144
    subnet_dict = subnet_to_dict(subnet)
134 145
    data = json.dumps({'subnet': subnet_dict})
135 146
    return HttpResponse(data, status=200)
136 147

  
......
159 170
    except KeyError:
160 171
        raise api.faults.BadRequest("Malformed request")
161 172

  
162
    if len(subnet) != 1:
173
    if len(subnet) != 1 or "name" not in subnet:
163 174
        raise api.faults.BadRequest("Only the name of subnet can be updated")
164 175

  
165 176
    name = subnet.get("name", None)

Also available in: Unified diff