Revision e221ade2 snf-cyclades-app/synnefo/api/actions.py

b/snf-cyclades-app/synnefo/api/actions.py
286 286

  
287 287

  
288 288
@server_action('firewallProfile')
289
@transaction.commit_on_success
290 289
def set_firewall_profile(request, vm, args):
291 290
    # Normal Response Code: 200
292 291
    # Error Response Codes: computeFault (400, 500),
......
318 317
    #                       itemNotFound (404),
319 318
    #                       overLimit (413)
320 319

  
320
    if net.state != 'ACTIVE':
321
        raise ServiceUnavailable('Network not active yet')
322

  
321 323
    server_id = args.get('serverRef', None)
322 324
    if not server_id:
323 325
        raise BadRequest('Malformed Request.')
324
    vm = get_vm(server_id, request.user_uniq)
325

  
326
    log.info("Connect VM %s to Network %s", vm, net)
327 326

  
328
    net = Network.objects.get(id=net.id)
329

  
330
    if net.state != 'ACTIVE':
331
        raise ServiceUnavailable('Network not active yet')
327
    vm = get_vm(server_id, request.user_uniq, non_suspended=True)
332 328

  
333 329
    address = None
334 330
    if net.dhcp:
......
366 362

  
367 363
    if not server_id or not nic_index:
368 364
        raise BadRequest('Malformed Request.')
369
    vm = get_vm(server_id, request.user_uniq)
365

  
366
    vm = get_vm(server_id, request.user_uniq, non_suspended=True)
370 367
    nic = get_nic_from_index(vm, nic_index)
371 368

  
372
    log.info("Disconnect VM %s NIC %s", vm, str(nic.index))
369
    log.info("Removing NIC %s from VM %s", str(nic.index), vm)
373 370

  
374 371
    if nic.dirty:
375 372
        raise BuildInProgress('Machine is busy.')

Also available in: Unified diff