id int64 0 458k | file_name stringlengths 4 119 | file_path stringlengths 14 227 | content stringlengths 24 9.96M | size int64 24 9.96M | language stringclasses 1
value | extension stringclasses 14
values | total_lines int64 1 219k | avg_line_length float64 2.52 4.63M | max_line_length int64 5 9.91M | alphanum_fraction float64 0 1 | repo_name stringlengths 7 101 | repo_stars int64 100 139k | repo_forks int64 0 26.4k | repo_open_issues int64 0 2.27k | repo_license stringclasses 12
values | repo_extraction_date stringclasses 433
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
24,600 | scst.py | truenas_middleware/src/middlewared/middlewared/plugins/iscsi_/scst.py | import asyncio
import pathlib
from middlewared.service import Service
SCST_BASE = '/sys/kernel/scst_tgt'
SCST_TARGETS_ISCSI_ENABLED_PATH = '/sys/kernel/scst_tgt/targets/iscsi/enabled'
SCST_DEVICES = '/sys/kernel/scst_tgt/devices'
SCST_SUSPEND = '/sys/kernel/scst_tgt/suspend'
SCST_CONTROLLER_A_TARGET_GROUPS_STATE = '/... | 5,442 | Python | .py | 115 | 37.443478 | 132 | 0.623161 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,601 | targets.py | truenas_middleware/src/middlewared/middlewared/plugins/iscsi_/targets.py | import asyncio
import errno
import os
import pathlib
import re
import subprocess
from collections import defaultdict
import middlewared.sqlalchemy as sa
from middlewared.schema import Bool, Dict, Int, IPAddr, List, Patch, Str, accepts
from middlewared.service import CallError, CRUDService, ValidationErrors, private
fr... | 34,518 | Python | .py | 702 | 37.749288 | 149 | 0.587254 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,602 | snapshot_delete.py | truenas_middleware/src/middlewared/middlewared/plugins/vmware_/snapshot_delete.py | from datetime import timedelta
from middlewared.service import periodic, private, Service
import middlewared.sqlalchemy as sa
from middlewared.utils.time_utils import utc_now
PENDING_SNAPSHOT_DELETE_INTERVAL = timedelta(hours=3)
PENDING_SNAPSHOT_DELETE_LIFETIME = timedelta(days=7)
class VMWarePendingSnapshotDelete... | 2,909 | Python | .py | 62 | 32.548387 | 120 | 0.572487 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,603 | cpu_temperatures.py | truenas_middleware/src/middlewared/middlewared/plugins/reporting/cpu_temperatures.py | from middlewared.service import private, Service
class ReportingService(Service):
@private
async def cpu_temperatures(self):
netdata_metrics = await self.middleware.call('netdata.get_all_metrics')
data = {}
temp_retrieved = False
for core, cpu_temp in netdata_metrics.get('cput... | 563 | Python | .py | 12 | 38.333333 | 116 | 0.649635 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,604 | netdata_configure.py | truenas_middleware/src/middlewared/middlewared/plugins/reporting/netdata_configure.py | import os
import subprocess
from middlewared.service import private, Service
from middlewared.utils.filesystem.copy import copytree, CopyTreeConfig
from .utils import get_netdata_state_path
class ReportingService(Service):
@private
def netdata_storage_location(self):
systemdataset_config = self.mid... | 1,697 | Python | .py | 37 | 37.864865 | 110 | 0.69436 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,605 | processes.py | truenas_middleware/src/middlewared/middlewared/plugins/reporting/processes.py | import time
import psutil
from middlewared.event import EventSource
from middlewared.service import CallError
class ProcessesEventSource(EventSource):
"""
Retrieve currently running processes stats.
Usage: reporting.processes:{"interval": 10, "cpu_percent": 0.1, "memory_percent": 0.1}
"""
def ... | 2,073 | Python | .py | 49 | 29.693878 | 107 | 0.550075 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,606 | rest.py | truenas_middleware/src/middlewared/middlewared/plugins/reporting/rest.py | import glob
import logging
from middlewared.service import accepts, Service
from middlewared.schema import Str, Dict, Int
from middlewared.utils.cpu import cpu_info
from middlewared.utils.disk_stats import get_disk_stats
from middlewared.utils.zfs import query_imported_fast_impl
from .netdata import ClientConnectErro... | 2,668 | Python | .py | 59 | 37.372881 | 118 | 0.667952 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,607 | export.py | truenas_middleware/src/middlewared/middlewared/plugins/reporting/export.py | import middlewared.sqlalchemy as sa
from middlewared.schema import accepts, Bool, Dict, Int, List, Patch, Str, returns
from middlewared.service import CRUDService, private, ValidationErrors
from .exporters.factory import export_factory
class ReportingExportsModel(sa.Model):
__tablename__ = 'reporting_exporters'... | 5,278 | Python | .py | 139 | 28.179856 | 119 | 0.585371 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,608 | netdata_web.py | truenas_middleware/src/middlewared/middlewared/plugins/reporting/netdata_web.py | import os
import shutil
import threading
import time
from middlewared.schema import accepts, returns, Str
from middlewared.service import cli_private, job, pass_app, periodic, private, CallError, Service
from middlewared.utils import MIDDLEWARE_RUN_DIR
from middlewared.utils.crypto import generate_string
from passlib.... | 3,317 | Python | .py | 73 | 36.315068 | 105 | 0.64921 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,609 | graphs.py | truenas_middleware/src/middlewared/middlewared/plugins/reporting/graphs.py | import collections
import errno
import time
import typing
from middlewared.schema import accepts, Dict, List, Ref, returns, Str
from middlewared.service import (
CallError, cli_private, filterable, filterable_returns, private, Service, ValidationErrors
)
from middlewared.utils import filter_list
from .netdata imp... | 5,590 | Python | .py | 142 | 29.760563 | 116 | 0.590892 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,610 | utils.py | truenas_middleware/src/middlewared/middlewared/plugins/reporting/utils.py | import collections
import contextlib
import os.path
import typing
from middlewared.plugins.system_dataset.utils import SYSDATASET_PATH
from .netdata.graph_base import GraphBase
# https://learn.netdata.cloud/docs/netdata-agent/configuration/optimizing-metrics-database/
# change-how-long-netdata-stores-metrics
TIER_0... | 8,080 | Python | .py | 180 | 34.1 | 112 | 0.577597 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,611 | events.py | truenas_middleware/src/middlewared/middlewared/plugins/reporting/events.py | import psutil
import time
from middlewared.event import EventSource
from middlewared.schema import Dict, Float, Int
from middlewared.utils.disks import get_disk_names, get_disks_with_identifiers
from middlewared.validators import Range
from .realtime_reporting import get_arc_stats, get_cpu_stats, get_disk_stats, get_... | 3,669 | Python | .py | 92 | 26.423913 | 116 | 0.515577 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,612 | attachments.py | truenas_middleware/src/middlewared/middlewared/plugins/reporting/attachments.py | from middlewared.common.ports import ServicePortDelegate
from .netdata.utils import NETDATA_PORT
class ReportingServicePortDelegate(ServicePortDelegate):
name = 'reporting'
namespace = 'reporting'
title = 'Reporting Service'
async def get_ports_bound_on_wildcards(self):
return [NETDATA_PORT... | 458 | Python | .py | 10 | 41.3 | 104 | 0.795918 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,613 | update.py | truenas_middleware/src/middlewared/middlewared/plugins/reporting/update.py | import middlewared.sqlalchemy as sa
from middlewared.schema import accepts, Bool, Dict, Int, List, Ref, returns, Str, Timestamp
from middlewared.service import cli_private, filterable, filterable_returns, ConfigService, private
from middlewared.validators import Range
from .netdata import GRAPH_PLUGINS
class Report... | 3,891 | Python | .py | 94 | 32.382979 | 112 | 0.610758 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,614 | client.py | truenas_middleware/src/middlewared/middlewared/plugins/reporting/netdata/client.py | import typing
import aiohttp
import aiohttp.client_exceptions
import asyncio
import contextlib
import json
import logging
from .exceptions import ApiException, ClientConnectError
from .utils import NETDATA_URI, NETDATA_REQUEST_TIMEOUT
logger = logging.getLogger('netdata_api')
class ClientMixin:
@classmethod
... | 4,775 | Python | .py | 92 | 40.086957 | 120 | 0.61235 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,615 | connector.py | truenas_middleware/src/middlewared/middlewared/plugins/reporting/netdata/connector.py | import errno
import typing
from .client import ClientMixin
from .exceptions import ApiException
from .utils import get_query_parameters
class Netdata(ClientMixin):
@classmethod
async def get_info(cls):
"""Get information about the running netdata instance"""
return await cls.api_call('info',... | 1,728 | Python | .py | 43 | 32.744186 | 100 | 0.655728 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,616 | graphs.py | truenas_middleware/src/middlewared/middlewared/plugins/reporting/netdata/graphs.py | import typing
from middlewared.utils.disk_temperatures import get_disks_for_temperature_reading
from .graph_base import GraphBase
from .utils import get_human_disk_name
class CPUPlugin(GraphBase):
title = 'CPU Usage'
uses_identifiers = False
vertical_label = '%CPU'
def get_chart_name(self, identif... | 9,916 | Python | .py | 227 | 36.45815 | 102 | 0.660297 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,617 | utils.py | truenas_middleware/src/middlewared/middlewared/plugins/reporting/netdata/utils.py | from urllib.parse import urlencode
NETDATA_PORT = 6999
NETDATA_REQUEST_TIMEOUT = 30 # seconds
NETDATA_URI = f'http://127.0.0.1:{NETDATA_PORT}/api'
NETDATA_UPDATE_EVERY = 2 # seconds
def get_query_parameters(query_params: dict | None, prefix: str = '&') -> str:
"""
retrieve complete uri by adding query par... | 1,321 | Python | .py | 33 | 35.030303 | 88 | 0.683386 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,618 | __init__.py | truenas_middleware/src/middlewared/middlewared/plugins/reporting/netdata/__init__.py | from .connector import Netdata # noqa
from .exceptions import ApiException, ClientConnectError # noqa
from .graph_base import GraphBase, GRAPH_PLUGINS # noqa
from .graphs import * # noqa
| 187 | Python | .py | 4 | 45.75 | 63 | 0.808743 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,619 | exceptions.py | truenas_middleware/src/middlewared/middlewared/plugins/reporting/netdata/exceptions.py | from middlewared.service import CallError
class ApiException(CallError):
pass
class ClientConnectError(CallError):
pass
| 132 | Python | .py | 5 | 23 | 41 | 0.837398 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,620 | graph_base.py | truenas_middleware/src/middlewared/middlewared/plugins/reporting/netdata/graph_base.py | import re
import statistics
import typing
from .connector import Netdata
GRAPH_PLUGINS = {}
RE_GRAPH_PLUGIN = re.compile(r'^(?P<name>.+)Plugin$')
class GraphMeta(type):
def __new__(cls, name, bases, dct):
klass = type.__new__(cls, name, bases, dct)
reg = RE_GRAPH_PLUGIN.search(name)
if ... | 7,037 | Python | .py | 148 | 35.939189 | 117 | 0.584537 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,621 | factory.py | truenas_middleware/src/middlewared/middlewared/plugins/reporting/exporters/factory.py | import errno
from middlewared.service_exception import CallError
from .graphite import GraphiteExporter
class ExportFactory:
def __init__(self):
self._creators = {}
def register(self, exporter):
self._creators[exporter.NAME.upper()] = exporter
def exporter(self, name):
name = ... | 681 | Python | .py | 20 | 28.35 | 86 | 0.700461 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,622 | graphite.py | truenas_middleware/src/middlewared/middlewared/plugins/reporting/exporters/graphite.py | from middlewared.schema import accepts, Bool, Dict, Int, Str
from middlewared.validators import Port, Range
from .base import Export
class GraphiteExporter(Export):
NAME = 'graphite'
SCHEMA = Dict(
'graphite',
Str('destination_ip', required=True),
Int('destination_port', required=Tru... | 774 | Python | .py | 20 | 32.25 | 74 | 0.655541 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,623 | base.py | truenas_middleware/src/middlewared/middlewared/plugins/reporting/exporters/base.py | class Export:
NAME = NotImplementedError()
SCHEMA = NotImplementedError()
@staticmethod
async def validate_config(data):
raise NotImplementedError()
| 175 | Python | .py | 6 | 23.833333 | 36 | 0.724551 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,624 | cgroup.py | truenas_middleware/src/middlewared/middlewared/plugins/reporting/realtime_reporting/cgroup.py | import collections
import typing
def get_cgroup_stats(netdata_metrics: dict, cgroups: typing.List[str]) -> dict[str, dict]:
data = collections.defaultdict(dict)
cgroup_keys = list(filter(lambda x: x.startswith('cgroup_'), netdata_metrics.keys()))
for cgroup in cgroups:
for i in filter(lambda x: x... | 788 | Python | .py | 16 | 40 | 90 | 0.595052 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,625 | memory.py | truenas_middleware/src/middlewared/middlewared/plugins/reporting/realtime_reporting/memory.py | import humanfriendly
from .utils import normalize_value, safely_retrieve_dimension
def get_memory_info(netdata_metrics: dict) -> dict:
with open('/proc/meminfo') as f:
meminfo = {
s[0]: humanfriendly.parse_size(s[1], binary=True)
for s in [
line.split(':', 1)
... | 2,117 | Python | .py | 49 | 33.836735 | 115 | 0.599418 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,626 | utils.py | truenas_middleware/src/middlewared/middlewared/plugins/reporting/realtime_reporting/utils.py | import contextlib
import typing
def safely_retrieve_dimension(
all_metrics: dict, chart: str, dimension: typing.Optional[str] = None, default: typing.Optional[typing.Any] = None
) -> typing.Any:
"""
Safely retrieve a dimension from a chart. If the dimension is not found, return the default value
and i... | 1,151 | Python | .py | 28 | 34.214286 | 118 | 0.666369 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,627 | __init__.py | truenas_middleware/src/middlewared/middlewared/plugins/reporting/realtime_reporting/__init__.py | from .arcstat import get_arc_stats # noqa
from .cpu import get_cpu_stats # noqa
from .ifstat import get_interface_stats # noqa
from .iostat import get_disk_stats # noqa
from .memory import get_memory_info # noqa
| 217 | Python | .py | 5 | 42.4 | 47 | 0.764151 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,628 | iostat.py | truenas_middleware/src/middlewared/middlewared/plugins/reporting/realtime_reporting/iostat.py | from .utils import normalize_value, safely_retrieve_dimension
def get_disk_stats(netdata_metrics: dict, disks: list[str], disk_mapping: dict[str, str]) -> dict:
total_disks = len(disks)
read_ops = read_bytes = write_ops = write_bytes = busy = 0
for disk in disks:
mapped_key = disk_mapping.get(disk... | 1,442 | Python | .py | 32 | 35.71875 | 98 | 0.604833 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,629 | ifstat.py | truenas_middleware/src/middlewared/middlewared/plugins/reporting/realtime_reporting/ifstat.py | import collections
import typing
from .utils import normalize_value, safely_retrieve_dimension
def get_interface_stats(netdata_metrics: dict, interfaces: typing.List[str]) -> dict:
data = collections.defaultdict(dict)
for interface_name in interfaces:
link_state = bool(safely_retrieve_dimension(netda... | 2,331 | Python | .py | 41 | 44.512195 | 115 | 0.627133 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,630 | cpu.py | truenas_middleware/src/middlewared/middlewared/plugins/reporting/realtime_reporting/cpu.py | from .utils import safely_retrieve_dimension
def get_cpu_core_stats(netdata_metrics: dict, core_number: int = None, chart_name: str = None) -> dict:
chart = f'cpu.cpu{core_number}' if core_number is not None else chart_name
data = {
'user': safely_retrieve_dimension(netdata_metrics, chart, 'user', 0),... | 1,752 | Python | .py | 30 | 51.566667 | 104 | 0.658892 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,631 | arcstat.py | truenas_middleware/src/middlewared/middlewared/plugins/reporting/realtime_reporting/arcstat.py | from .utils import normalize_value, safely_retrieve_dimension
def get_arc_stats(netdata_metrics: dict) -> dict:
data = {
'arc_max_size': normalize_value(
safely_retrieve_dimension(netdata_metrics, 'zfs.arc_size', 'max', 0), multiplier=1024 * 1024,
),
'arc_size': normalize_value... | 734 | Python | .py | 16 | 38.625 | 106 | 0.635854 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,632 | bridge.py | truenas_middleware/src/middlewared/middlewared/plugins/interface/bridge.py | from middlewared.service import private, Service
from .netif import netif
class InterfaceService(Service):
class Config:
namespace_alias = 'interfaces'
@private
def bridge_setup(self, bridge, parent_interfaces):
name = bridge['interface']['int_interface']
bridge_mtu = bridge['int... | 2,513 | Python | .py | 52 | 36.846154 | 98 | 0.605392 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,633 | interface_types.py | truenas_middleware/src/middlewared/middlewared/plugins/interface/interface_types.py | from enum import Enum
from middlewared.service import private, Service
class InterfaceType(Enum):
BRIDGE = 'BRIDGE'
LINK_AGGREGATION = 'LINK_AGGREGATION'
PHYSICAL = 'PHYSICAL'
UNKNOWN = 'UNKNOWN'
VLAN = 'VLAN'
class InterfaceService(Service):
class Config:
namespace_alias = 'interf... | 1,529 | Python | .py | 34 | 36.147059 | 115 | 0.648485 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,634 | vlan.py | truenas_middleware/src/middlewared/middlewared/plugins/interface/vlan.py | from middlewared.service import private, Service
from .netif import netif
class InterfaceService(Service):
class Config:
namespace_alias = 'interfaces'
@private
def vlan_setup(self, vlan, parent_interfaces):
self.logger.info('Setting up %r', vlan['vlan_vint'])
try:
if... | 1,562 | Python | .py | 36 | 31.611111 | 111 | 0.568511 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,635 | configure.py | truenas_middleware/src/middlewared/middlewared/plugins/interface/configure.py | import ipaddress
import os
import signal
import re
from .netif import netif
from .interface_types import InterfaceType
from middlewared.service import private, Service
class InterfaceService(Service):
class Config:
namespace_alias = 'interfaces'
@private
def configure(self, data, aliases, optio... | 8,152 | Python | .py | 164 | 38.530488 | 119 | 0.604044 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,636 | dhclient.py | truenas_middleware/src/middlewared/middlewared/plugins/interface/dhclient.py | import os
from contextlib import suppress
from subprocess import run, PIPE, STDOUT
from middlewared.service import private, Service
from middlewared.utils.cgroups import move_to_root_cgroups
LEASEFILE_TEMPLATE = '/var/lib/dhcp/dhclient.leases.{}'
PIDFILE_TEMPLATE = '/var/run/dhclient.{}.pid'
class InterfaceService... | 2,243 | Python | .py | 57 | 29.842105 | 98 | 0.610676 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,637 | lag_protocols.py | truenas_middleware/src/middlewared/middlewared/plugins/interface/lag_protocols.py | from middlewared.service import no_authz_required, private, Service
class InterfaceService(Service):
class Config:
namespace_alias = 'interfaces'
@private
@no_authz_required
async def lag_supported_protocols(self):
return ['LACP', 'FAILOVER', 'LOADBALANCE']
| 294 | Python | .py | 8 | 31.25 | 67 | 0.723404 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,638 | internal_ifaces.py | truenas_middleware/src/middlewared/middlewared/plugins/interface/internal_ifaces.py | from middlewared.service import private, Service
from .netif import netif
class InterfaceService(Service):
class Config:
namespace_alias = 'interfaces'
@private
async def internal_interfaces(self):
# expicit call to list() is important here
result = list(netif.INTERNAL_INTERFACE... | 1,021 | Python | .py | 18 | 48.5 | 96 | 0.714142 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,639 | listen.py | truenas_middleware/src/middlewared/middlewared/plugins/interface/listen.py | from collections import namedtuple
from itertools import zip_longest
from middlewared.schema import Dict, List, returns, Str
from middlewared.service import accepts, Service, private
PreparedDelegate = namedtuple("PreparedDelegate", ["delegate", "state", "addresses"])
PRE_SYNC_LISTEN_DELEGATES = []
POST_ROLLBACK_LIS... | 4,080 | Python | .py | 81 | 41.259259 | 116 | 0.659955 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,640 | capabilities.py | truenas_middleware/src/middlewared/middlewared/plugins/interface/capabilities.py | from middlewared.service_exception import ValidationErrors
from middlewared.service import Service, private
from middlewared.schema import Dict, Str, List, accepts, returns
from middlewared.plugins.interface.netif_linux import ethernet_settings
EHS = ethernet_settings.EthernetHardwareSettings
class InterfaceCapabil... | 2,851 | Python | .py | 60 | 38.583333 | 90 | 0.643397 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,641 | control.py | truenas_middleware/src/middlewared/middlewared/plugins/interface/control.py | from middlewared.service import Service, private
from .netif import netif
class InterfaceService(Service):
class Config:
namespace_alias = 'interfaces'
@private
def destroy(self, name):
netif.destroy_interface(name)
| 249 | Python | .py | 8 | 26 | 48 | 0.741525 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,642 | lag.py | truenas_middleware/src/middlewared/middlewared/plugins/interface/lag.py | from middlewared.service import private, Service
from .netif import netif
class InterfaceService(Service):
class Config:
namespace_alias = 'interfaces'
@private
def lag_setup(self, lagg, members, parent_interfaces, sync_interface_opts):
name = lagg['lagg_interface']['int_interface']
... | 4,477 | Python | .py | 84 | 40.892857 | 107 | 0.598948 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,643 | lag_options.py | truenas_middleware/src/middlewared/middlewared/plugins/interface/lag_options.py | import enum
class XmitHashChoices(enum.Enum):
LAYER2 = 'LAYER2'
LAYER23 = 'LAYER2+3'
LAYER34 = 'LAYER3+4'
class LacpduRateChoices(enum.Enum):
SLOW = 'SLOW'
FAST = 'FAST'
| 194 | Python | .py | 8 | 20.25 | 35 | 0.681319 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,644 | link_address.py | truenas_middleware/src/middlewared/middlewared/plugins/interface/link_address.py | import re
from sqlalchemy.exc import IntegrityError
from middlewared.service import private, Service
INTERFACE_FILTERS = [["type", "=", "PHYSICAL"]]
RE_FREEBSD_BRIDGE = re.compile(r"bridge([0-9]+)$")
RE_FREEBSD_LAGG = re.compile(r"lagg([0-9]+)$")
class DuplicateHardwareInterfaceLinkAddresses(Exception):
def __... | 13,801 | Python | .py | 240 | 41.7375 | 120 | 0.568478 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,645 | bits.py | truenas_middleware/src/middlewared/middlewared/plugins/interface/netif_linux/bits.py | from enum import IntEnum
__all__ = ["InterfaceFlags", "InterfaceV6Flags", "InterfaceLinkState", "NeighborDiscoveryFlags"]
class InterfaceFlags(IntEnum):
# include/uapi/linux/if.h
UP = 1 << 0 # sysfs
BROADCAST = 1 << 1 # volatile
DEBUG = 1 << 2 # sysfs
LOOPBACK = 1 << 3 # volatile
POINTOPO... | 1,418 | Python | .py | 50 | 23.66 | 96 | 0.622517 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,646 | bridge.py | truenas_middleware/src/middlewared/middlewared/plugins/interface/netif_linux/bridge.py | import json
import logging
from pyroute2 import NDB
from .utils import run
logger = logging.getLogger(__name__)
__all__ = ["create_bridge", "BridgeMixin"]
def create_bridge(name):
with NDB(log="off") as ndb:
ndb.interfaces.create(ifname=name, kind="bridge").set("state", "up").commit()
class BridgeMix... | 1,217 | Python | .py | 33 | 29.454545 | 90 | 0.580205 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,647 | vlan.py | truenas_middleware/src/middlewared/middlewared/plugins/interface/netif_linux/vlan.py | import glob
import logging
import os
import re
from pyroute2 import NDB
from .utils import run
logger = logging.getLogger(__name__)
__all__ = ["create_vlan", "VlanMixin"]
def create_vlan(name, parent, tag):
with NDB(log="off") as ndb:
ndb.interfaces[parent].set("state", "up").commit() # make sure pare... | 981 | Python | .py | 27 | 31.074074 | 109 | 0.646872 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,648 | interface.py | truenas_middleware/src/middlewared/middlewared/plugins/interface/netif_linux/interface.py | from pyroute2 import NDB
from .address import AddressMixin
from .bridge import BridgeMixin
from .bits import InterfaceFlags, InterfaceV6Flags
from .lagg import LaggMixin
from .utils import bitmask_to_set, INTERNAL_INTERFACES
from .vlan import VlanMixin
from .vrrp import VrrpMixin
from .ethernet_settings import Etherne... | 5,580 | Python | .py | 143 | 29.643357 | 109 | 0.589236 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,649 | lagg.py | truenas_middleware/src/middlewared/middlewared/plugins/interface/netif_linux/lagg.py | import enum
import logging
import pathlib
from pyroute2 import NDB
from .utils import run
logger = logging.getLogger(__name__)
__all__ = ["AggregationProtocol", "create_lagg"]
class AggregationProtocol(enum.Enum):
LACP = "802.3ad"
FAILOVER = "active-backup"
LOADBALANCE = "balance-xor"
def create_lagg... | 4,280 | Python | .py | 93 | 34.365591 | 107 | 0.579011 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,650 | utils.py | truenas_middleware/src/middlewared/middlewared/plugins/interface/netif_linux/utils.py | import subprocess
__all__ = ["bitmask_to_set", "INTERNAL_INTERFACES", "run"]
# Keep this as an immutable type since this
# is used all over the place and we don't want
# the contents to change
INTERNAL_INTERFACES = (
"wg", "lo", "tun", "tap", "docker", "veth", "vnet", "macvtap", "ix", "tailscale",
)
def bitmas... | 688 | Python | .py | 17 | 37.176471 | 85 | 0.688253 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,651 | routing.py | truenas_middleware/src/middlewared/middlewared/plugins/interface/netif_linux/routing.py | # -*- coding=utf-8 -*-
import collections
import enum
import ipaddress
import logging
import os
import socket
import bidict
from pyroute2 import IPRoute
from pyroute2.netlink.exceptions import NetlinkDumpInterrupted
from .address.ipv6 import ipv6_netmask_to_prefixlen
from .address.types import AddressFamily
logger =... | 8,680 | Python | .py | 221 | 29.656109 | 114 | 0.577363 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,652 | netif.py | truenas_middleware/src/middlewared/middlewared/plugins/interface/netif_linux/netif.py | import logging
from pyroute2 import IPRoute, NetlinkDumpInterrupted
from .bridge import create_bridge
from .interface import Interface, CLONED_PREFIXES
from .lagg import AggregationProtocol, create_lagg
from .utils import run
from .vlan import create_vlan
logger = logging.getLogger(__name__)
__all__ = ["AggregationP... | 1,993 | Python | .py | 45 | 35.822222 | 106 | 0.644961 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,653 | __init__.py | truenas_middleware/src/middlewared/middlewared/plugins/interface/netif_linux/__init__.py | from .address import * # noqa
from .bits import * # noqa
from .interface import * # noqa
from .netif import * # noqa
from .routing import * # noqa
from .utils import * # noqa
| 181 | Python | .py | 6 | 29.166667 | 32 | 0.691429 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,654 | ethernet_settings.py | truenas_middleware/src/middlewared/middlewared/plugins/interface/netif_linux/ethernet_settings.py | from logging import getLogger
from pyroute2.ethtool import Ethtool
from pyroute2.ethtool.ioctl import NotSupportedError, NoSuchDevice
logger = getLogger(__name__)
class EthernetHardwareSettings:
def __init__(self, interface):
self._name = interface
self._eth = Ethtool()
self._caps = sel... | 6,456 | Python | .py | 136 | 35.941176 | 114 | 0.591285 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,655 | vrrp.py | truenas_middleware/src/middlewared/middlewared/plugins/interface/netif_linux/vrrp.py | # -*- coding=utf-8 -*-
__all__ = ['VrrpMixin']
class VrrpMixin:
@property
def vrrp_config(self):
try:
return self.data
except AttributeError:
# Interface class doesn't initialize
# this class on inheritance so return None
# until this attribute... | 946 | Python | .py | 24 | 30.958333 | 69 | 0.643716 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,656 | mixin.py | truenas_middleware/src/middlewared/middlewared/plugins/interface/netif_linux/address/mixin.py | import ipaddress
import time
from pyroute2 import IPRoute
from pyroute2.netlink.exceptions import NetlinkDumpInterrupted
from middlewared.plugins.interface.netif_linux.utils import run
from .ipv6 import ipv6_netmask_to_prefixlen
from .types import AddressFamily, InterfaceAddress, LinkAddress
__all__ = ["AddressMixin... | 3,209 | Python | .py | 68 | 34.529412 | 112 | 0.581626 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,657 | __init__.py | truenas_middleware/src/middlewared/middlewared/plugins/interface/netif_linux/address/__init__.py | from .mixin import * # noqa
from .types import * # noqa
| 58 | Python | .py | 2 | 28 | 28 | 0.678571 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,658 | ipv6.py | truenas_middleware/src/middlewared/middlewared/plugins/interface/netif_linux/address/ipv6.py | # -*- coding=utf-8 -*-
import ipaddress
import logging
logger = logging.getLogger(__name__)
__all__ = ["ipv6_netmask_to_prefixlen"]
def ipv6_netmask_to_prefixlen(netmask):
bits = bin(ipaddress.IPv6Address._ip_int_from_string(netmask))[2:].rstrip("0")
if not all(c == "1" for c in bits):
raise ValueEr... | 382 | Python | .py | 10 | 34.7 | 82 | 0.686649 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,659 | types.py | truenas_middleware/src/middlewared/middlewared/plugins/interface/netif_linux/address/types.py | # -*- coding=utf-8 -*-
import enum
import ipaddress
import logging
logger = logging.getLogger(__name__)
__all__ = ['AddressFamily', 'LinkAddress', 'InterfaceAddress']
class AddressFamily(enum.IntEnum):
UNIX = 1
INET = 2
# IMPLINK = defs.AF_IMPLINK
# PUP = defs.AF_PUP
# CHAOS = defs.AF_CHAOS
... | 4,121 | Python | .py | 116 | 27.137931 | 119 | 0.584171 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,660 | download.py | truenas_middleware/src/middlewared/middlewared/plugins/update_/download.py | # -*- coding=utf-8 -*-
import errno
import itertools
import os
import subprocess
import time
import requests
import requests.exceptions
from middlewared.service import CallError, private, Service
from middlewared.utils.size import format_size
from .utils import DOWNLOAD_UPDATE_FILE, scale_update_server
class Updat... | 3,500 | Python | .py | 71 | 31.56338 | 107 | 0.50249 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,661 | upload_location_linux.py | truenas_middleware/src/middlewared/middlewared/plugins/update_/upload_location_linux.py | # -*- coding=utf-8 -*-
import contextlib
import os
import shutil
import subprocess
from middlewared.service import private, Service
from .utils import UPLOAD_LOCATION
from .utils_linux import run_kw
class UpdateService(Service):
@private
def get_upload_location(self):
return UPLOAD_LOCATION
@pr... | 1,184 | Python | .py | 31 | 30.225806 | 107 | 0.645415 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,662 | utils.py | truenas_middleware/src/middlewared/middlewared/plugins/update_/utils.py | # -*- coding=utf-8 -*-
import configparser
import itertools
import os
import re
from middlewared.utils import MIDDLEWARE_RUN_DIR
DEFAULT_SCALE_UPDATE_SERVER = "https://update.ixsystems.com/scale"
SCALE_MANIFEST_FILE = "/data/manifest.json"
DOWNLOAD_UPDATE_FILE = "update.sqsh"
UPLOAD_LOCATION = os.path.join(MIDDLEWARE... | 1,596 | Python | .py | 44 | 28.25 | 100 | 0.573099 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,663 | utils_linux.py | truenas_middleware/src/middlewared/middlewared/plugins/update_/utils_linux.py | # -*- coding=utf-8 -*-
import contextlib
import logging
import subprocess
import tempfile
from middlewared.service import CallError
logger = logging.getLogger(__name__)
run_kw = dict(check=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, encoding="utf-8", errors="ignore")
@contextlib.contextmanager
def moun... | 765 | Python | .py | 19 | 34.578947 | 110 | 0.68691 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,664 | trains.py | truenas_middleware/src/middlewared/middlewared/plugins/update_/trains.py | import json
from aiohttp import ClientResponseError, ClientSession, ClientTimeout
from middlewared.service import CallError, private, Service
from middlewared.utils.network import INTERNET_TIMEOUT
from middlewared.utils.functools_ import cache
from .utils import can_update, scale_update_server, SCALE_MANIFEST_FILE
... | 2,540 | Python | .py | 59 | 32.59322 | 113 | 0.59571 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,665 | download_linux.py | truenas_middleware/src/middlewared/middlewared/plugins/update_/download_linux.py | from middlewared.service import private, Service
class UpdateService(Service):
@private
async def download_impl(self, job, train, location, progress_proportion):
return await self.middleware.call('update.download_impl_scale', job, train, location, progress_proportion)
| 287 | Python | .py | 5 | 52.8 | 114 | 0.778571 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,666 | install_linux.py | truenas_middleware/src/middlewared/middlewared/plugins/update_/install_linux.py | import json
import logging
import os
from middlewared.plugins.config import UPLOADED_DB_PATH
from middlewared.service import CallError, private, Service
from middlewared.utils import sw_info
from .utils import can_update
from .utils_linux import mount_update
logger = logging.getLogger(__name__)
class UpdateService... | 1,859 | Python | .py | 40 | 36.625 | 116 | 0.63571 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,667 | pending_linux.py | truenas_middleware/src/middlewared/middlewared/plugins/update_/pending_linux.py | # -*- coding=utf-8 -*-
import json
import os
import subprocess
from middlewared.service import private, Service
from .utils import SCALE_MANIFEST_FILE, DOWNLOAD_UPDATE_FILE
from .utils_linux import mount_update
run_kw = dict(check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="utf-8", errors="ignore... | 1,310 | Python | .py | 35 | 26.6 | 108 | 0.557222 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,668 | install.py | truenas_middleware/src/middlewared/middlewared/plugins/update_/install.py | import errno
import json
import logging
import os
import subprocess
import time
from middlewared.service import CallError, private, Service
from middlewared.utils.size import format_size
logger = logging.getLogger(__name__)
run_kw = dict(check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="utf-8", e... | 4,796 | Python | .py | 111 | 31.855856 | 117 | 0.566617 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,669 | ui.py | truenas_middleware/src/middlewared/middlewared/plugins/system_general/ui.py | import asyncio
from middlewared.schema import accepts, Dict, Int, returns, Str
from middlewared.service import CallError, rest_api_metadata, private, Service
from middlewared.validators import Range
from .utils import HTTPS_PROTOCOLS
class SystemGeneralService(Service):
ui_allowlist = []
class Config:
... | 6,086 | Python | .py | 140 | 33.5 | 122 | 0.587589 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,670 | language.py | truenas_middleware/src/middlewared/middlewared/plugins/system_general/language.py | from middlewared.i18n import set_language
from middlewared.schema import accepts, Dict, returns
from middlewared.service import private, Service
LANGUAGES = dict([
('af', 'Afrikaans'),
('ar', 'Arabic'),
('ast', 'Asturian'),
('az', 'Azerbaijani'),
('bg', 'Bulgarian'),
('be', 'Belarusian'),
... | 2,958 | Python | .py | 109 | 22 | 101 | 0.513371 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,671 | timezone.py | truenas_middleware/src/middlewared/middlewared/plugins/system_general/timezone.py | from subprocess import run
from middlewared.schema import accepts, Dict, returns
from middlewared.service import Service
from middlewared.utils.functools_ import cache
class SystemGeneralService(Service):
class Config:
namespace = 'system.general'
cli_namespace = 'system.general'
@accepts()... | 741 | Python | .py | 18 | 34.555556 | 105 | 0.688022 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,672 | keymap.py | truenas_middleware/src/middlewared/middlewared/plugins/system_general/keymap.py | import collections
import re
from middlewared.schema import accepts, Dict, returns
from middlewared.service import private, Service
class SystemGeneralService(Service):
KBDMAP_CHOICES = None
class Config:
namespace = 'system.general'
cli_namespace = 'system.general'
@accepts()
@ret... | 1,340 | Python | .py | 34 | 30.029412 | 98 | 0.598304 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,673 | country.py | truenas_middleware/src/middlewared/middlewared/plugins/system_general/country.py | import csv
from middlewared.schema import accepts, Dict, returns
from middlewared.service import private, Service
class SystemGeneralService(Service):
COUNTRY_CHOICES = None
class Config:
namespace = 'system.general'
cli_namespace = 'system.general'
@accepts()
@returns(Dict('countr... | 1,928 | Python | .py | 46 | 29.086957 | 108 | 0.547059 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,674 | attachments.py | truenas_middleware/src/middlewared/middlewared/plugins/system_general/attachments.py | from middlewared.common.ports import ServicePortDelegate
class SystemGeneralServicePortDelegate(ServicePortDelegate):
bind_address_field = 'ui_address'
name = 'webui'
namespace = 'system.general'
port_fields = ['ui_port', 'ui_httpsport']
title = 'WebUI Service'
def bind_address(self, config)... | 1,208 | Python | .py | 29 | 32.758621 | 108 | 0.639316 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,675 | update.py | truenas_middleware/src/middlewared/middlewared/plugins/system_general/update.py | import asyncio
import syslog
import middlewared.sqlalchemy as sa
from middlewared.async_validators import validate_port
from middlewared.schema import accepts, Bool, Datetime, Dict, Int, IPAddr, List, Patch, returns, Str
from middlewared.service import ConfigService, private, ValidationErrors
from middlewared.utils i... | 14,503 | Python | .py | 285 | 40.308772 | 120 | 0.618405 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,676 | map2.py | truenas_middleware/src/middlewared/middlewared/plugins/enclosure_/map2.py | # Copyright (c) - iXsystems Inc.
#
# Licensed under the terms of the TrueNAS Enterprise License Agreement
# See the file LICENSE.IX for complete terms and conditions
import logging
from .constants import HEAD_UNIT_DISK_SLOT_START_NUMBER
from .enums import ControllerModels, JbofModels
logger = logging.getLogger(__nam... | 4,770 | Python | .py | 92 | 41.684783 | 103 | 0.632312 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,677 | enums.py | truenas_middleware/src/middlewared/middlewared/plugins/enclosure_/enums.py | from enum import Enum, unique
@unique
class ElementStatusesToIgnore(Enum):
UNSUPPORTED = 'unsupported'
@unique
class ElementDescriptorsToIgnore(Enum):
ADISE0 = 'arraydevicesinsubenclsr0'
ADS = 'array device slot'
EMPTY = '<empty>'
AD = 'arraydevices'
DS = 'drive slots'
@unique
class Contro... | 3,506 | Python | .py | 117 | 25.564103 | 91 | 0.672112 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,678 | sysfs_disks.py | truenas_middleware/src/middlewared/middlewared/plugins/enclosure_/sysfs_disks.py | # Copyright (c) - iXsystems Inc.
#
# Licensed under the terms of the TrueNAS Enterprise License Agreement
# See the file LICENSE.IX for complete terms and conditions
from dataclasses import dataclass
from os import scandir
from pathlib import Path
from .enums import ControllerModels
@dataclass(slots=True, frozen=Tr... | 5,039 | Python | .py | 121 | 31.710744 | 87 | 0.590974 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,679 | jbof_enclosures.py | truenas_middleware/src/middlewared/middlewared/plugins/enclosure_/jbof_enclosures.py | import asyncio
from logging import getLogger
from middlewared.plugins.enclosure_.enums import JbofModels
from middlewared.plugins.enclosure_.jbof.es24n import (is_this_an_es24n,
map_es24n)
from middlewared.plugins.jbof.redfish import (AsyncRedfishClient,
... | 3,653 | Python | .py | 80 | 36.25 | 99 | 0.640023 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,680 | nvme2.py | truenas_middleware/src/middlewared/middlewared/plugins/enclosure_/nvme2.py | # Copyright (c) - iXsystems Inc.
#
# Licensed under the terms of the TrueNAS Enterprise License Agreement
# See the file LICENSE.IX for complete terms and conditions
import pathlib
import re
from pyudev import Context, Devices, DeviceNotFoundAtPathError
from ixhardware import parse_dmi
from .constants import (
D... | 10,748 | Python | .py | 246 | 33.947154 | 115 | 0.587083 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,681 | enclosure_class.py | truenas_middleware/src/middlewared/middlewared/plugins/enclosure_/enclosure_class.py | # Copyright (c) - iXsystems Inc.
#
# Licensed under the terms of the TrueNAS Enterprise License Agreement
# See the file LICENSE.IX for complete terms and conditions
import logging
from middlewared.utils.scsi_generic import inquiry
from ixhardware import parse_dmi
from .constants import (
MINI_MODEL_BASE,
MI... | 27,577 | Python | .py | 714 | 27.372549 | 112 | 0.562323 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,682 | fseries_drive_identify.py | truenas_middleware/src/middlewared/middlewared/plugins/enclosure_/fseries_drive_identify.py | # Copyright (c) - iXsystems Inc.
#
# Licensed under the terms of the TrueNAS Enterprise License Agreement
# See the file LICENSE.IX for complete terms and conditions
from subprocess import run, PIPE, STDOUT
from middlewared.service_exception import CallError
class InsufficientPrivilege(Exception):
pass
def ge... | 1,908 | Python | .py | 55 | 27.527273 | 85 | 0.585776 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,683 | constants.py | truenas_middleware/src/middlewared/middlewared/plugins/enclosure_/constants.py | SYSFS_SLOT_KEY = 'sysfs_slot'
MAPPED_SLOT_KEY = 'mapped_slot'
SUPPORTS_IDENTIFY_KEY = 'supports_identify_light'
SUPPORTS_IDENTIFY_STATUS_KEY = 'supports_identify_light_status'
DRIVE_BAY_LIGHT_STATUS = 'drive_bay_light_status'
MINI_MODEL_BASE = 'MINI'
MINIR_MODEL_BASE = f'{MINI_MODEL_BASE}-R'
HEAD_UNIT_DISK_SLOT_START_N... | 442 | Python | .py | 12 | 35.833333 | 63 | 0.753488 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,684 | element_types.py | truenas_middleware/src/middlewared/middlewared/plugins/enclosure_/element_types.py | from .enums import ElementStatus, ElementType
def alarm(value_raw):
"""See SES-4 7.3.8 Audible Alarm element, Table 98 — Audible Alarm status element
Returns a comma-separated string for each alarm bit set or None otherwise
"""
values = {
'Identify on': (value_raw >> 16) & 0x80,
'Fail... | 11,744 | Python | .py | 241 | 42.136929 | 110 | 0.637866 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,685 | slot_mappings.py | truenas_middleware/src/middlewared/middlewared/plugins/enclosure_/slot_mappings.py | # Copyright (c) - iXsystems Inc.
#
# Licensed under the terms of the TrueNAS Enterprise License Agreement
# See the file LICENSE.IX for complete terms and conditions
from .constants import (
DISK_FRONT_KEY,
DISK_TOP_KEY,
DISK_REAR_KEY,
DISK_INTERNAL_KEY,
SYSFS_SLOT_KEY,
MAPPED_SLOT_KEY,
SUP... | 35,514 | Python | .py | 707 | 30.363508 | 108 | 0.452028 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,686 | nvme.py | truenas_middleware/src/middlewared/middlewared/plugins/enclosure_/nvme.py | # Copyright (c) - iXsystems Inc.
#
# Licensed under the terms of the TrueNAS Enterprise License Agreement
# See the file LICENSE.IX for complete terms and conditions
import re
from pathlib import Path
from pyudev import Context, Devices, DeviceNotFoundAtPathError
from middlewared.service import Service, private
cl... | 9,496 | Python | .py | 217 | 29.599078 | 119 | 0.490321 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,687 | ses_enclosure.py | truenas_middleware/src/middlewared/middlewared/plugins/enclosure_/ses_enclosure.py | # Copyright (c) - iXsystems Inc.
#
# Licensed under the terms of the TrueNAS Enterprise License Agreement
# See the file LICENSE.IX for complete terms and conditions
from pyudev import Context
from libsg3.ses import EnclosureDevice
from middlewared.service import private, Service
class EnclosureService(Service):
... | 1,178 | Python | .py | 29 | 31.586207 | 103 | 0.633333 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,688 | ses_enclosures2.py | truenas_middleware/src/middlewared/middlewared/plugins/enclosure_/ses_enclosures2.py | from contextlib import suppress
from logging import getLogger
from pathlib import Path
from libsg3.ses import EnclosureDevice
from .enclosure_class import Enclosure
logger = getLogger(__name__)
def get_ses_enclosure_status(bsg_path):
try:
return EnclosureDevice(bsg_path).status()
except OSError:
... | 924 | Python | .py | 24 | 30.041667 | 87 | 0.62486 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,689 | map.py | truenas_middleware/src/middlewared/middlewared/plugins/enclosure_/map.py | # Copyright (c) - iXsystems Inc.
#
# Licensed under the terms of the TrueNAS Enterprise License Agreement
# See the file LICENSE.IX for complete terms and conditions
from collections import namedtuple
import re
from middlewared.service import Service, private
ProductMapping = namedtuple("ProductMapping", ["product_r... | 18,125 | Python | .py | 457 | 27.059081 | 116 | 0.50898 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,690 | enclosure2.py | truenas_middleware/src/middlewared/middlewared/plugins/enclosure_/enclosure2.py | # Copyright (c) - iXsystems Inc.
#
# Licensed under the terms of the TrueNAS Enterprise License Agreement
# See the file LICENSE.IX for complete terms and conditions
import errno
from middlewared.schema import Dict, Int, Str, accepts
from middlewared.service import Service, filterable
from middlewared.service_exceptio... | 7,901 | Python | .py | 141 | 45.468085 | 119 | 0.64582 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,691 | r30_drive_identify.py | truenas_middleware/src/middlewared/middlewared/plugins/enclosure_/r30_drive_identify.py | # Copyright (c) - iXsystems Inc.
#
# Licensed under the terms of the TrueNAS Enterprise License Agreement
# See the file LICENSE.IX for complete terms and conditions
from subprocess import run
NVME_CONTROLLERS = ('0xc0', '0xc2', '0xc4')
def slot_to_controller_and_bay_mapping(slot):
mapping = {
# bays 1-... | 2,774 | Python | .py | 66 | 35.015152 | 100 | 0.618377 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,692 | es24n.py | truenas_middleware/src/middlewared/middlewared/plugins/enclosure_/jbof/es24n.py | from logging import getLogger
from middlewared.plugins.enclosure_.enums import ElementType, JbofModels
from middlewared.plugins.enclosure_.jbof.utils import (fake_jbof_enclosure,
map_cooling,
map_power_supplie... | 6,111 | Python | .py | 139 | 33.151079 | 108 | 0.593015 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,693 | utils.py | truenas_middleware/src/middlewared/middlewared/plugins/enclosure_/jbof/utils.py | from logging import getLogger
from middlewared.plugins.enclosure_.constants import (
DISK_FRONT_KEY,
DISK_REAR_KEY,
DISK_TOP_KEY,
DISK_INTERNAL_KEY,
DRIVE_BAY_LIGHT_STATUS,
SUPPORTS_IDENTIFY_KEY,
SUPPORTS_IDENTIFY_STATUS_KEY,
)
from middlewared.plugins.enclosure_.enums import (
ElementS... | 10,848 | Python | .py | 263 | 33.889734 | 118 | 0.623139 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,694 | enclosure.py | truenas_middleware/src/middlewared/middlewared/plugins/webui/enclosure.py | from middlewared.schema import accepts
from middlewared.service import Service
class WebUIEnclosureService(Service):
class Config:
namespace = 'webui.enclosure'
private = True
cli_private = True
role_prefix = 'ENCLOSURE'
def disk_detail_dict(self):
return {
... | 5,704 | Python | .py | 128 | 26.03125 | 101 | 0.427211 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,695 | main_dashboard.py | truenas_middleware/src/middlewared/middlewared/plugins/webui/main_dashboard.py | from datetime import datetime, timezone
from time import clock_gettime, CLOCK_MONOTONIC_RAW, time
from middlewared.schema import accepts
from middlewared.service import Service
from middlewared.utils import sw_version, sw_codename
class WebUIMainDashboardService(Service):
class Config:
namespace = 'webui... | 2,461 | Python | .py | 54 | 36.12963 | 88 | 0.63193 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,696 | crypto.py | truenas_middleware/src/middlewared/middlewared/plugins/webui/crypto.py | from middlewared.schema import accepts, Int
from middlewared.service import Service
class WebUICryptoService(Service):
class Config:
namespace = 'webui.crypto'
private = True
cli_private = True
@accepts(roles=['READONLY_ADMIN'])
async def certificate_profiles(self):
retur... | 906 | Python | .py | 19 | 41.473684 | 94 | 0.730682 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,697 | journal_exceptions.py | truenas_middleware/src/middlewared/middlewared/plugins/failover_/journal_exceptions.py | # Copyright (c) - iXsystems Inc.
#
# Licensed under the terms of the TrueNAS Enterprise License Agreement
# See the file LICENSE.IX for complete terms and conditions
class UnableToDetermineOSVersion(Exception):
"""
Raised in JournalSync thread when we're unable
to detect the remote node's OS version.
(... | 565 | Python | .py | 17 | 29.470588 | 70 | 0.737615 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,698 | detect_enclosure.py | truenas_middleware/src/middlewared/middlewared/plugins/failover_/detect_enclosure.py | # Copyright (c) - iXsystems Inc.
#
# Licensed under the terms of the TrueNAS Enterprise License Agreement
# See the file LICENSE.IX for complete terms and conditions
import pathlib
import subprocess
from pyudev import Context
from ixhardware import PLATFORM_PREFIXES
from middlewared.service import Service
from midd... | 5,254 | Python | .py | 103 | 36.417476 | 106 | 0.548199 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,699 | event.py | truenas_middleware/src/middlewared/middlewared/plugins/failover_/event.py | # Copyright (c) - iXsystems Inc.
#
# Licensed under the terms of the TrueNAS Enterprise License Agreement
# See the file LICENSE.IX for complete terms and conditions
import asyncio
import os
import time
import contextlib
import threading
import logging
import errno
from collections import defaultdict
from middlewared... | 45,927 | Python | .py | 890 | 39.996629 | 116 | 0.616613 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |