<commit_before>"""
storlever.mngr.network.route
~~~~~~~~~~~~~~~~

This module implements some functions of DNS for linux network.

:copyright: (c) 2014 by OpenSight (www.opensight.cn).
:license: AGPLv3, see LICENSE for more details.

"""


from storlever.lib.lock import lock
from storlever.mngr.system.cfgmgr import cfg_mgr
from storlever.lib import logger
import logging
from storlever.lib.exception import StorLeverError
from storlever.mngr.system.modulemgr import ModuleManager
from storlever.lib.command import check_output


MODULE_INFO = {
    "module_name": "route_tab",
    "rpms": [
        "net-tools",
    ],
    "comment": "Provides the functions to handle IP route table in the network system"
}


ROUTE_CMD = "/sbin/route"

class RouteManager(object):
    """contains all methods to manage dns configure"""

    def __init__(self):
        # need a mutex to protect name servers config
        pass

    def get_ipv4_route_list(self):
        route_list = []
        route_lines = check_output([ROUTE_CMD, "-n"]).splitlines()

        for line in route_lines[2:]:
            words = line.split()
            if len(words) < 8 :
                continue
            if words[0] == "Destination":
                continue
            route_list.append({
                "destination": words[0],
                "gateway": words[1],
                "genmask": words[2],
                "flags": words[3],
                "metric": int(words[4]),
                "ref": int(words[5]),
                "use": int(words[6]),
                "iface": words[7]
            })

        return route_list

    def get_ipv6_route_list(self):
        route_list = []
        route_lines = check_output([ROUTE_CMD, "-n", "-A", "inet6"]).splitlines()

        for line in route_lines[2:]:
            words = line.split()
            if len(words) < 7 :
                continue
            if words[0] == "Destination":
                continue<commit_msg>return empty list for ipv6 route list if the kernel does not support ipv6<commit_after>"""
storlever.mngr.network.route
~~~~~~~~~~~~~~~~

This module implements some functions of DNS for linux network.

:copyright: (c) 2014 by OpenSight (www.opensight.cn).
:license: AGPLv3, see LICENSE for more details.

"""


from storlever.lib.lock import lock
from storlever.mngr.system.cfgmgr import cfg_mgr
from storlever.lib import logger
import logging
from storlever.lib.exception import StorLeverError
from storlever.mngr.system.modulemgr import ModuleManager
from storlever.lib.command import check_output


MODULE_INFO = {
    "module_name": "route_tab",
    "rpms": [
        "net-tools",
    ],
    "comment": "Provides the functions to handle IP route table in the network system"
}


ROUTE_CMD = "/sbin/route"

class RouteManager(object):
    """contains all methods to manage dns configure"""

    def __init__(self):
        # need a mutex to protect name servers config
        pass

    def get_ipv4_route_list(self):
        route_list = []
        route_lines = check_output([ROUTE_CMD, "-n"]).splitlines()

        for line in route_lines[2:]:
            words = line.split()
            if len(words) < 8 :
                continue
            if words[0] == "Destination":
                continue
            route_list.append({
                "destination": words[0],
                "gateway": words[1],
                "genmask": words[2],
                "flags": words[3],
                "metric": int(words[4]),
                "ref": int(words[5]),
                "use": int(words[6]),
                "iface": words[7]
            })

        return route_list

    def get_ipv6_route_list(self):
        route_list = []
        try:
            route_lines = check_output([ROUTE_CMD, "-n", "-A", "inet6"]).splitlines()
        except Exception:
            return route_list

        for line in route_lines[2:]:
            words = line.split()
            if len(words) < 7 :
                continue
            if words[0] == "Destination":
                continue
{'fraction_non_alphanumeric': 0.11700814613675635, 'fraction_numerical': 0.011355220933102938, 'mean_word_length': 2.124132613723978, 'pattern_counts': {'":': 26, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5263632', 'n_tokens_mistral': 1215, 'n_tokens_neox': 1170, 'n_words': 321}