Revision 35ea7f67

b/snf-cyclades-app/synnefo/api/networks.py
117 117
    flavor = api.utils.get_attribute(network_dict, "type",
118 118
                                     attr_type=basestring)
119 119

  
120
    if flavor not in Network.FLAVORS.keys():
121
        raise api.faults.BadRequest("Invalid network type '%s'" % flavor)
122 120
    if flavor not in settings.API_ENABLED_NETWORK_FLAVORS:
123 121
        raise api.faults.Forbidden("Cannot create network of type '%s'." %
124 122
                                   flavor)
b/snf-cyclades-app/synnefo/api/util.py
310 310
def get_vm_nic(vm, nic_id):
311 311
    """Get a VMs NIC by its ID."""
312 312
    try:
313
        nic_id = int(nic_id)
313 314
        return vm.nics.get(id=nic_id)
314 315
    except NetworkInterface.DoesNotExist:
315 316
        raise faults.ItemNotFound("NIC '%s' not found" % nic_id)
317
    except (ValueError, TypeError):
318
        raise faults.BadRequest("Invalid NIC ID '%s'" % nic_id)
316 319

  
317 320

  
318 321
def get_nic(nic_id):
b/snf-cyclades-app/synnefo/logic/networks.py
141 141

  
142 142
@network_command("RENAME")
143 143
def rename(network, name):
144
    utils.check_name_length(name, Network.NETWORK_NAME_LENGTH, "Network name "
145
                            "is too long")
144 146
    network.name = name
145 147
    network.save()
146 148
    return network
b/snf-cyclades-app/synnefo/logic/servers.py
416 416

  
417 417
def rename(server, new_name):
418 418
    """Rename a VirtualMachine."""
419
    utils.check_name_length(new_name,
420
                            VirtualMachine.VIRTUAL_MACHINE_NAME_LENGTH,
421
                            "Server name is too long")
419 422
    old_name = server.name
420 423
    server.name = new_name
421 424
    server.save()
b/snf-cyclades-app/synnefo/logic/subnets.py
82 82
    network_id and the desired cidr are mandatory, everything else is optional
83 83

  
84 84
    """
85

  
85 86
    try:
87
        network_id = int(network_id)
86 88
        network = Network.objects.get(id=network_id)
89
    except (ValueError, TypeError):
90
        raise api.faults.BadRequest("Malformed network ID")
87 91
    except Network.DoesNotExist:
88
        raise api.faults.ItemNotFound("No network found with that id")
92
        raise api.faults.ItemNotFound("No network found with that ID")
89 93

  
90 94
    if network.deleted:
91 95
        raise api.faults.BadRequest("Network has been deleted")

Also available in: Unified diff