示例#1
0
def get(dry_run, logger, name, netns=None, root_ipdb=None):
    """
    Tries to find a dummy interface with the given name in the
    chosen namespace and returns it.
    """

    interface._log_get(logger, name, IF_DESCRIPTION, netns, root_ipdb)

    if dry_run:
        return Dummy(logger, name, None, netns, root_ipdb)

    ipdb = interface._ipdb_get(name, IF_DESCRIPTION, netns, root_ipdb)
    existing_if = interface._interface_get(name, ipdb, IF_TYPE)

    if existing_if:
        return Dummy(logger, name, existing_if, netns, root_ipdb)
    else:
        raise NotFoundError(name, IF_DESCRIPTION, netns, root_ipdb)
示例#2
0
def get(dry_run, logger, name, mode, netns=None, root_ipdb=None):
    """
    Tries to find a tun/tap interface with the given name in the
    chosen namespace and returns it.
    """

    description = "%s interface" % mode

    interface._log_get(logger, name, description, netns, root_ipdb)

    if dry_run:
        return Tuntap(logger, name, None, netns, root_ipdb, mode)

    ipdb = interface._ipdb_get(name, description, netns, root_ipdb)
    existing_if = interface._interface_get(name, ipdb, mode)

    if existing_if:
        return Tuntap(logger, name, existing_if, netns, root_ipdb, mode)
    else:
        raise NotFoundError(name, mode, netns, root_ipdb)
示例#3
0
文件: gre.py 项目: catalyst/l3overlay
def get(dry_run, logger, name, kind, netns=None, root_ipdb=None):
    '''
    Tries to find a gre/gretap interface with the given name in the
    chosen namespace and returns it.
    '''

    description = "%s interface" % kind

    interface._log_get(logger, name, description, netns, root_ipdb)

    if dry_run:
        return GRE(logger, name, None, netns, root_ipdb, kind)

    ipdb = interface._ipdb_get(name, description, netns, root_ipdb)
    existing_if = interface._interface_get(name, ipdb, kind)

    if existing_if:
        return GRE(logger, name, existing_if, netns, root_ipdb, kind)
    else:
        raise NotFoundError(name, kind, netns, root_ipdb)