Revision 4e3789fd snf-cyclades-app/synnefo/logic/subnets.py

b/snf-cyclades-app/synnefo/logic/subnets.py
83 83

  
84 84
    """
85 85
    try:
86
        network = Network.objects.get(id=network_id)
86
        network = Network.objects.select_for_update().get(id=network_id)
87 87
    except Network.DoesNotExist:
88 88
        raise api.faults.ItemNotFound("No network found with that id")
89 89

  
......
121 121
                                dhcp=dhcp, host_routes=host_routes,
122 122
                                dns_nameservers=dns_nameservers)
123 123

  
124
    network.subnet_ids.append(sub.id)
125
    network.save()
126

  
124 127
    gateway_ip = ipaddr.IPAddress(gateway) if gateway else None
125 128

  
126 129
    if allocation_pools is not None:

Also available in: Unified diff