Revision a96e84cf snf-cyclades-app/synnefo/logic/networks.py

b/snf-cyclades-app/synnefo/logic/networks.py
65 65

  
66 66

  
67 67
@transaction.commit_on_success
68
def create(user_id, name, flavor, subnet=None, gateway=None, subnet6=None,
68
def create(userid, name, flavor, subnet=None, gateway=None, subnet6=None,
69 69
           gateway6=None, public=False, dhcp=True, link=None, mac_prefix=None,
70 70
           mode=None, floating_ip_pool=False, tags=None, backends=None,
71 71
           lazy_create=True):
......
80 80
        raise faults.BadRequest("Can not override PHYSICAL_VLAN link")
81 81

  
82 82
    if subnet is None and floating_ip_pool:
83
        raise faults.BadRequest("IPv6 only networks can not be"
83
        raise faults.BadRequest("IPv6 only networks can not be floating"
84 84
                                " pools.")
85 85
    # Check that network parameters are valid
86 86
    validate_network_params(subnet, gateway, subnet6, gateway6)
......
107 107

  
108 108
    network = Network.objects.create(
109 109
        name=name,
110
        userid=user_id,
110
        userid=userid,
111 111
        flavor=flavor,
112 112
        mode=mode,
113 113
        link=link,
......
160 160
@network_command("DESTROY")
161 161
def delete(network):
162 162
    if network.machines.exists():
163
        raise faults.NetworkInUse("Can not delete network. Servers connected"
164
                                  " to this network exists.")
165
    if network.floating_ips.filter(deleted=False).exists():
163
        raise faults.Conflict("Can not delete network. Servers connected"
164
                              " to this network exists.")
165
    if network.ips.filter(deleted=False, floating_ip=True).exists():
166 166
        msg = "Can not delete netowrk. Network has allocated floating IPs."
167
        raise faults.NetworkInUse(msg)
167
        raise faults.Conflict(msg)
168 168

  
169 169
    network.action = "DESTROY"
170 170
    network.save()
......
180 180

  
181 181
def validate_network_params(subnet=None, gateway=None, subnet6=None,
182 182
                            gateway6=None):
183
    if (subnet is None) and (subnet6 is None):
184
        raise faults.BadRequest("subnet or subnet6 is required")
185

  
186 183
    if subnet:
187 184
        try:
188 185
            # Use strict option to not all subnets with host bits set

Also available in: Unified diff