Example #1
0
def read(logger, section, config):
    '''
    Read an interface from the given configuration object.
    '''

    interface_type, name = util.section_split(section)

    if interface_type == "static-bgp":
        return bgp.read(logger, name, config)
    elif interface_type == "static-dummy":
        return dummy.read(logger, name, config)
    elif interface_type == "static-overlay-link":
        return overlay_link.read(logger, name, config)
    elif interface_type == "static-tunnel":
        return tunnel.read(logger, name, config)
    elif interface_type == "static-tuntap":
        return tuntap.read(logger, name, config)
    elif interface_type == "static-veth":
        return veth.read(logger, name, config)
    elif interface_type == "static-vlan":
        return vlan.read(logger, name, config)
    elif name.startswith("static"):
        raise ReadError("unsupported static interface type '%s' with name '%s'" % (interface_type, name))
    else:
        raise ReadError("unsupported section type '%s'" % section)
Example #2
0
def section_type_is_static_interface(section):
    '''
    Return True if the type of the given section is a static
    interface of some kind.
    '''

    interface_type, name = util.section_split(section)

    return (interface_type == "static-bgp" or
            interface_type == "static-dummy" or
            interface_type == "static-overlay-link" or
            interface_type == "static-tunnel" or
            interface_type == "static-tuntap" or
            interface_type == "static-veth" or
            interface_type == "static-vlan")