Example #1
0
def iface(name, cache=None):
    """
    calls on checks to determine best interface type match for the named interface

    :return: regular :class:`linux.iface <netshowlib.linux.iface.Iface>` or \
    :class:`linux bond or bond member<netshowlib.linux.bond.Bond>`  or  \
    :class:`linux bridge or bridge member <netshowlib.linux.bridge.Bridge>` \
    interface
    """
    # create test iface.
    test_iface = Iface(name, cache=cache)
    if test_iface.is_bridge():
        bridge = nn.import_module('netshowlib.linux.bridge')
        return bridge.Bridge(name, cache=cache)
    elif test_iface.is_bond():
        bond = nn.import_module('netshowlib.linux.bond')
        return bond.Bond(name, cache=cache)
    elif test_iface.is_bondmem():
        bondmem = nn.import_module('netshowlib.linux.bond')
        return bondmem.BondMember(name, cache=cache)
    elif test_iface.is_bridgemem():
        bridge = nn.import_module('netshowlib.linux.bridge')
        return bridge.BridgeMember(name, cache=cache)

    return test_iface
Example #2
0
def iface(name, cache=None):
    """
    calls on checks to determine best interface type match for the named interface

    :return: regular :class:`linux.iface <netshowlib.linux.iface.Iface>` or \
    :class:`linux bond or bond member<netshowlib.linux.bond.Bond>`  or  \
    :class:`linux bridge or bridge member <netshowlib.linux.bridge.Bridge>` \
    interface
    """
    # create test iface.
    test_iface = Iface(name, cache=cache)
    if test_iface.is_bridge():
        bridge = nn.import_module('netshowlib.linux.bridge')
        return bridge.Bridge(name, cache=cache)
    elif test_iface.is_bond():
        bond = nn.import_module('netshowlib.linux.bond')
        return bond.Bond(name, cache=cache)
    elif test_iface.is_bondmem():
        bondmem = nn.import_module('netshowlib.linux.bond')
        return bondmem.BondMember(name, cache=cache)
    elif test_iface.is_bridgemem():
        bridge = nn.import_module('netshowlib.linux.bridge')
        return bridge.BridgeMember(name, cache=cache)

    return test_iface
Example #3
0
def run():
    """
    Executes ``run()`` function from netshow plugin identified
    from the provider check.
    """
    # set the LOCPATH to find locale files in the virtualenv instance or
    # system /usr/share/locale location. needed by gettext
    # for translation files.
    os.environ['LOCPATH'] = os.path.join(sys.prefix, 'share', 'locale')
    if os.environ.get('LANGUAGE') == 'C':
        os.environ['LANGUAGE'] = 'en'
    _ostype = nn.provider_check()
    if not _ostype:
        raise UnableToFindProviderException
    import_str = 'netshow.%s.show' % _ostype
    nn.import_module(import_str).run()
def iface(name, cache=None):
    """
    :return: ``:class:PrintIface`` instance that matches \
        correct iface type of the named interface
    :return: None if interface does not exist
    """
    # create test iface.
    test_iface = cumulus_iface.iface(name, cache=cache)
    if not test_iface.exists():
        return None
    if test_iface.is_bridge():
        bridge = nn.import_module('netshow.cumulus.print_bridge')
        return bridge.PrintBridge(test_iface)
    elif test_iface.is_bond():
        bond = nn.import_module('netshow.cumulus.print_bond')
        return bond.PrintBond(test_iface)
    elif test_iface.is_bondmem():
        bondmem = nn.import_module('netshow.cumulus.print_bond')
        return bondmem.PrintBondMember(test_iface)
    elif test_iface.is_bridgemem():
        bridge = nn.import_module('netshow.cumulus.print_bridge')
        return bridge.PrintBridgeMember(test_iface)
    return PrintIface(test_iface)
Example #5
0
    def run(self, features=None):
        """
        :param features:  List of features to enable. If set to ``None`` \
            cache from all features is obtained

        :return:  returns Cache instance of appropriate OS type
        """
        _featurelist = self.feature_list
        if features:
            _featurelist = features

        for _feature, _provider in _featurelist.items():
            _feature_mod = nnlib.import_module("netshowlib.%s.%s" % (_provider,
                                                                     _feature))
            self.__dict__[_feature] = _feature_mod.cacheinfo()
def test_import_module():
    """ test import module """
    ospath = nn.import_module('os.path')
    assert_equals(ospath.exists('/etc/hosts'), True)