Revision af6a3bc5 snf-cyclades-app/synnefo/api/util.py

b/snf-cyclades-app/synnefo/api/util.py
59 59
                                BadMediaType)
60 60
from synnefo.db.models import (Flavor, VirtualMachine, VirtualMachineMetadata,
61 61
                               Network, BackendNetwork, NetworkInterface,
62
                               BridgePoolTable)
62
                               BridgePoolTable, MacPrefixPoolTable)
63 63

  
64 64
from synnefo.lib.astakos import get_user
65 65
from synnefo.plankton.backend import ImageBackend
......
395 395
    return "-".join(["nic", unicode(nic.machine.id), unicode(nic.index)])
396 396

  
397 397

  
398
def network_link_from_type(network_type):
399
    if network_type == 'PRIVATE_MAC_FILTERED':
398
def net_resources(net_type):
399
    mac_prefix = settings.MAC_POOL_BASE
400
    if net_type == 'PRIVATE_MAC_FILTERED':
400 401
        link = settings.PRIVATE_MAC_FILTERED_BRIDGE
401
    elif network_type == 'PRIVATE_PHYSICAL_VLAN':
402
        mac_pool = MacPrefixPoolTable.get_pool()
403
        mac_prefix = mac_pool.get()
404
        mac_pool.save()
405
    elif net_type == 'PRIVATE_PHYSICAL_VLAN':
402 406
        pool = BridgePoolTable.get_pool()
403 407
        link = pool.get()
404 408
        pool.save()
405
    elif network_type == 'CUSTOM_ROUTED':
409
    elif net_type == 'CUSTOM_ROUTED':
406 410
        link = settings.CUSTOM_ROUTED_ROUTING_TABLE
407
    elif network_type == 'CUSTOM_BRIDGED':
411
    elif net_type == 'CUSTOM_BRIDGED':
408 412
        link = settings.CUSTOM_BRIDGED_BRIDGE
409
    elif network_type == 'PUBLIC_ROUTED':
413
    elif net_type == 'PUBLIC_ROUTED':
410 414
        link = settings.PUBLIC_ROUTED_ROUTING_TABLE
411 415
    else:
412
        raise BadRequest('Unknown network network_type')
416
        raise BadRequest('Unknown network type')
413 417

  
414
    return link
418
    return link, mac_prefix

Also available in: Unified diff