Ejemplo n.º 1
0
Archivo: views.py Proyecto: LiuJux/nav
def fetch_voice_vlan_for_netbox(request, factory, config=None):
    """Fetch the voice vlan for this netbox

    There may be multiple voice vlans configured. Pick the one that exists
    on this netbox. If multiple vlans exist, we cannot know which one to use.

    """
    if config is None:
        config = read_config()

    voice_vlans = fetch_voice_vlans(config)
    if not voice_vlans:
        return

    voice_vlans_on_netbox = list(
        set(voice_vlans) & set(factory.get_available_vlans()))
    if not voice_vlans_on_netbox:
        # Should this be reported? At the moment I do not think so.
        return
    if len(voice_vlans_on_netbox) > 1:
        messages.error(request, 'Multiple voice vlans configured on this '
                       'netbox')
        return

    return voice_vlans_on_netbox[0]
Ejemplo n.º 2
0
def fetch_voice_vlan_for_netbox(request, factory):
    """Fetch the voice vlan for this netbox

    There may be multiple voice vlans configured. Pick the one that exists
    on this netbox. If multiple vlans exist, we cannot know which one to use.

    """
    voice_vlans = fetch_voice_vlans()
    if not voice_vlans:
        return

    voice_vlans_on_netbox = list(set(voice_vlans) &
                                 set(factory.get_available_vlans()))
    if not voice_vlans_on_netbox:
        # Should this be reported? At the moment I do not think so.
        return
    if len(voice_vlans_on_netbox) > 1:
        messages.error(request, 'Multiple voice vlans configured on this '
                                'netbox')
        return

    return voice_vlans_on_netbox[0]