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,400 | test_element_types.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/enclosure/test_element_types.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 pytest
from middlewared.plugins.enclosure_ import element_types
@pytest.mark.parametrize('data', [
(0x800000, 'Identify on'),
(0x400000... | 13,014 | Python | .py | 302 | 38.529801 | 112 | 0.66953 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,401 | san.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/crypto/san.py | import pytest
from middlewared.plugins.crypto_.generate_utils import normalize_san
@pytest.mark.parametrize("reference,expected_results", [
(['truenas.domain', '192.168.0.10'], [['DNS', 'truenas.domain'], ['IP', '192.168.0.10']]),
(['DNS:truenas.domain', '192.168.0.10'], [['DNS', 'truenas.domain'], ['IP', '1... | 551 | Python | .py | 9 | 58.111111 | 101 | 0.660482 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,402 | extensions.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/crypto/extensions.py | import pytest
from middlewared.plugins.crypto_.generate_ca import generate_certificate_authority
from middlewared.plugins.crypto_.load_utils import load_certificate
from middlewared.plugins.crypto_.utils import DEFAULT_LIFETIME_DAYS
@pytest.mark.parametrize('generate_params,extension_info', [
(
{
... | 5,225 | Python | .py | 154 | 20.857143 | 113 | 0.441002 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,403 | csr.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/crypto/csr.py | import pytest
from cryptography.hazmat.primitives.asymmetric import rsa
from middlewared.plugins.crypto_.csr import generate_certificate_signing_request
from middlewared.plugins.crypto_.load_utils import load_certificate_request, load_private_key
@pytest.mark.parametrize('generate_params,key_type,key_size,csr_info'... | 2,789 | Python | .py | 73 | 27.780822 | 102 | 0.527286 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,404 | self_signed_cert.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/crypto/self_signed_cert.py | from cryptography.hazmat.primitives.asymmetric import rsa
from middlewared.plugins.crypto_.generate_self_signed import DEFAULT_LIFETIME_DAYS, generate_self_signed_certificate
from middlewared.plugins.crypto_.load_utils import load_certificate, load_private_key
SELF_SIGNED_CERT = {
'country': 'US',
'state': '... | 1,251 | Python | .py | 27 | 41.481481 | 116 | 0.710181 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,405 | private_key.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/crypto/private_key.py | import pytest
import textwrap
from cryptography.hazmat.primitives.asymmetric import ec, rsa
from middlewared.plugins.crypto_.key_utils import load_private_key, generate_private_key
@pytest.mark.parametrize('generate_params,expected_type,key_size', [
({}, rsa.RSAPrivateKey, 2048),
({'type': 'EC'}, ec.Ellipti... | 3,547 | Python | .py | 70 | 41.471429 | 88 | 0.744742 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,406 | certs.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/crypto/certs.py | import textwrap
import pytest
from cryptography import x509
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.asymmetric import rsa
from middlewared.plugins.crypto_.generate_certs import generate_certificate
from middlewared.plugins.crypto_.generate_utils import sign_csr_wi... | 22,289 | Python | .py | 393 | 43.628499 | 105 | 0.697295 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,407 | ca.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/crypto/ca.py | import pytest
import textwrap
from cryptography.hazmat.primitives.asymmetric import rsa
from middlewared.plugins.crypto_.generate_ca import generate_certificate_authority
from middlewared.plugins.crypto_.load_utils import load_certificate, load_private_key
from middlewared.plugins.crypto_.utils import DEFAULT_LIFETIM... | 8,701 | Python | .py | 188 | 32.5 | 105 | 0.569951 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,408 | test_custom_scale_version_checks.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/catalog/test_custom_scale_version_checks.py | import pytest
from middlewared.plugins.catalog.apps_util import custom_scale_version_checks
@pytest.mark.parametrize('min_version, max_version, sys_scale_version, expected', [
(
'21.0',
'23.1',
'22.01',
''
),
(
'22.15',
'21.05',
'22.01',
'Yo... | 1,017 | Python | .py | 37 | 20.783784 | 119 | 0.578301 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,409 | test_get_app_details.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/catalog/test_get_app_details.py | import unittest
import pytest
from middlewared.plugins.catalog.apps_util import get_app_details
@pytest.mark.parametrize('app_data, versions, expected', [
(
{
'app_readme': '',
'categories': [
'media'
],
'description': '',
'heal... | 5,566 | Python | .py | 150 | 22.473333 | 117 | 0.423397 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,410 | test_retrieve_cached_versions_data.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/catalog/test_retrieve_cached_versions_data.py | import textwrap
import unittest
import pytest
from middlewared.plugins.catalog.apps_util import retrieve_cached_versions_data
from middlewared.service import CallError
@pytest.mark.parametrize('file, should_work', [
(
'''
version: 1.0.1
''',
False
),
(
'''
... | 2,433 | Python | .py | 77 | 17.805195 | 120 | 0.410464 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,411 | test_min_max_scale_version_update.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/catalog/test_min_max_scale_version_update.py | import unittest
import pytest
from middlewared.plugins.catalog.apps_util import minimum_scale_version_check_update
@pytest.mark.parametrize('version_data, expected', [
(
{
'healthy': True,
'supported': True,
'healthy_error': None,
'location': '/mnt/.ix-app... | 5,261 | Python | .py | 154 | 19.655844 | 94 | 0.412894 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,412 | test_netdata_stats_func.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/reporting/test_netdata_stats_func.py | from unittest.mock import patch, mock_open
from middlewared.plugins.reporting.netdata.utils import NETDATA_UPDATE_EVERY
from middlewared.plugins.reporting.realtime_reporting import (
get_arc_stats, get_cpu_stats, get_disk_stats, get_interface_stats, get_memory_info,
)
from middlewared.plugins.reporting.realtime_re... | 20,842 | Python | .py | 648 | 20.776235 | 119 | 0.453126 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,413 | test_netdata_graphs.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/reporting/test_netdata_graphs.py | import pytest
from unittest.mock import AsyncMock, patch
from middlewared.plugins.reporting.netdata.graphs import (
CPUPlugin, CPUTempPlugin, DiskTempPlugin, DISKPlugin, InterfacePlugin, LoadPlugin, MemoryPlugin,
UptimePlugin, ARCActualRatePlugin, ARCRatePlugin, ARCSizePlugin
)
from middlewared.pytest.unit.mi... | 1,757 | Python | .py | 35 | 44.685714 | 113 | 0.674242 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,414 | test_netdata_approximation.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/reporting/test_netdata_approximation.py | import pytest
from middlewared.plugins.reporting.utils import get_metrics_approximation, calculate_disk_space_for_netdata
@pytest.mark.parametrize('disk_count,core_count,interface_count,pool_count,services_count,vms_count,expected_output', [
(4, 2, 1, 2, 10, 2, {1: 796, 60: 4}),
(1600, 32, 4, 4, 10, 1, {1: 9... | 2,724 | Python | .py | 54 | 44.944444 | 120 | 0.630116 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,415 | test_docker_address_pools_validtaion.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/docker/test_docker_address_pools_validtaion.py | import pytest
from middlewared.plugins.docker.validation_utils import validate_address_pools
from middlewared.service_exception import ValidationErrors
IP_IN_USE = [
{
'type': 'INET',
'address': '172.20.0.33',
'netmask': 16,
'broadcast': '172.20.0.63'
}
]
@pytest.mark.parametrize('user_specifie... | 1,383 | Python | .py | 38 | 30.710526 | 90 | 0.625093 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,416 | test_convert_aliases_to_datastore.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/network/test_convert_aliases_to_datastore.py | import pytest
from unittest.mock import Mock
from middlewared.plugins.network import InterfaceService
OBJ = InterfaceService(Mock())
non_ha_with_1_v4ip = (
{
'aliases': [
{
'address': '1.1.1.1',
'type': 'INET',
'netmask': 24,
},
... | 8,522 | Python | .py | 368 | 12.255435 | 59 | 0.327845 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,417 | test_get_latest_version.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/apps/test_get_latest_version.py | import pytest
from middlewared.plugins.apps.version_utils import get_latest_version_from_app_versions
from middlewared.service import CallError
@pytest.mark.parametrize('versions, should_work, expected', [
(
{
'1.1.9': {
'healthy': True,
'supported': True,
... | 2,826 | Python | .py | 87 | 19.264368 | 97 | 0.452851 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,418 | test_normalize_CA.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/apps/test_normalize_CA.py | import textwrap
import pytest
from middlewared.plugins.apps.schema_normalization import AppSchemaService
from middlewared.pytest.unit.middleware import Middleware
from middlewared.schema import Int
@pytest.mark.parametrize('cert, value, should_work', [
(
textwrap.dedent(
'''
----... | 5,783 | Python | .py | 98 | 48.377551 | 106 | 0.780144 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,419 | test_get_schema.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/apps/test_get_schema.py | import pytest
from middlewared.plugins.apps.schema_utils import get_schema, SCHEMA_MAPPING
@pytest.mark.parametrize('data', [
{
'variable': 'actual_budget',
'label': '',
'group': 'Actual Budget Configuration',
'schema': {
'type': 'dict',
'attrs': [
... | 12,436 | Python | .py | 306 | 16.356209 | 106 | 0.282578 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,420 | test_normalize_questions.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/apps/test_normalize_questions.py | import pytest
from middlewared.plugins.apps.schema_normalization import AppSchemaService, REF_MAPPING
from middlewared.pytest.unit.middleware import Middleware
from middlewared.schema import Dict, List
@pytest.mark.parametrize('question_attr, ref, value, update', [
(
Dict(),
'definitions/certific... | 2,032 | Python | .py | 66 | 23.878788 | 90 | 0.611735 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,421 | test_list_apps.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/apps/test_list_apps.py | import collections
import unittest
import pytest
from middlewared.plugins.apps.ix_apps.query import list_apps
AVAILABLE_MAPPING = {
'community': {
'whoogle': {
'version': '1.0.20',
'app_version': '0.9.0'
},
'rsyncd': {
'version': '1.0.14',
... | 18,351 | Python | .py | 476 | 25.109244 | 115 | 0.512262 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,422 | test_normalize_values.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/apps/test_normalize_values.py | import pytest
from middlewared.plugins.apps.schema_normalization import AppSchemaService
from middlewared.pytest.unit.middleware import Middleware
from middlewared.schema import Dict
@pytest.mark.parametrize('dict_obj, values, update, context, expected', [
(
Dict(
'actual-budget',
... | 2,171 | Python | .py | 79 | 16.468354 | 77 | 0.424605 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,423 | test_normalize_acl.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/apps/test_normalize_acl.py | import pytest
from middlewared.plugins.apps.schema_normalization import AppSchemaService
from middlewared.pytest.unit.middleware import Middleware
from middlewared.schema import Dict
@pytest.mark.parametrize('attr, value, context', [
(
Dict(),
{
'entries': [{'type': 'ALLOW', 'permissi... | 1,840 | Python | .py | 66 | 15.621212 | 74 | 0.388481 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,424 | test_construct_schema.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/apps/test_construct_schema.py | import pytest
from middlewared.plugins.apps.schema_utils import construct_schema
from middlewared.schema import Dict, ValidationErrors
@pytest.mark.parametrize('data, new_values, update', [
(
{
'schema': {
'groups': [
{
'name': 'Actu... | 9,531 | Python | .py | 216 | 16.87963 | 115 | 0.274339 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,425 | test_normalize_and_validate.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/apps/test_normalize_and_validate.py | import pytest
from middlewared.plugins.apps.schema_normalization import AppSchemaService
from middlewared.pytest.unit.middleware import Middleware
from middlewared.schema import Dict
@pytest.mark.parametrize('app_detail, values, expected', [
(
{
'healthy': True,
'supported': True,... | 4,490 | Python | .py | 120 | 19.491667 | 115 | 0.380124 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,426 | test_normalize_gpu_options.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/apps/test_normalize_gpu_options.py |
import pytest
from middlewared.plugins.apps.schema_normalization import AppSchemaService
from middlewared.pytest.unit.middleware import Middleware
@pytest.mark.parametrize('gpu_list, value, expected', [
(
[
{
'pci_slot': '0000:00:02.0',
'addr': {
... | 4,181 | Python | .py | 121 | 20.92562 | 107 | 0.415844 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,427 | test_get_list_item_from_value.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/apps/test_get_list_item_from_value.py | import pytest
from middlewared.plugins.apps.schema_utils import get_list_item_from_value
from middlewared.schema import List
@pytest.mark.parametrize('values, question_attr, should_work', [
(
['val1', 'val2', 'val3'],
List(
items=[
List({'question1': 'desc1'}),
... | 1,408 | Python | .py | 53 | 17.056604 | 74 | 0.460799 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,428 | test_normalize_ix_volumes.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/apps/test_normalize_ix_volumes.py | import pytest
from middlewared.plugins.apps.schema_normalization import AppSchemaService
from middlewared.pytest.unit.middleware import Middleware
from middlewared.schema import Dict
@pytest.mark.parametrize('attr, value, complete_config, context', [
(
Dict(),
{
'dataset_name': 'volum... | 2,872 | Python | .py | 106 | 15.179245 | 92 | 0.375589 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,429 | test_normalize_certificate.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/apps/test_normalize_certificate.py | import textwrap
import pytest
from middlewared.plugins.apps.schema_normalization import AppSchemaService
from middlewared.pytest.unit.middleware import Middleware
from middlewared.schema import Int
@pytest.mark.parametrize('cert, value, should_work', [
(
textwrap.dedent(
'''
----... | 5,765 | Python | .py | 98 | 48.183673 | 96 | 0.780113 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,430 | test_get_normalized_gpus.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/apps/test_get_normalized_gpus.py | import pytest
from middlewared.plugins.apps.resources_utils import get_normalized_gpu_choices
@pytest.mark.parametrize('all_gpu_info, nvidia_gpus, should_work', [
(
[
{
'addr': {
'pci_slot': '0000:00:02.0',
'domain': '0000',
... | 7,376 | Python | .py | 181 | 26.033149 | 107 | 0.412542 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,431 | test_device_info.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/device/test_device_info.py | from unittest.mock import Mock
import pytest
from middlewared.plugins.device_.device_info import DeviceService
@pytest.mark.parametrize("host_type,disk_data,get_rotation_rate,result", [
(None, {"rota": True}, Mock(return_value=7200), ("HDD", 7200)),
(None, {"rota": True}, Mock(return_value=None), ("SSD", No... | 741 | Python | .py | 14 | 49.357143 | 85 | 0.69018 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,432 | test_audit_utils.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/audit/test_audit_utils.py | import pytest
from middlewared.utils import filter_list
from middlewared.plugins.audit.utils import (
AUDITED_SERVICES,
parse_query_filters,
requires_python_filtering,
SQL_SAFE_FIELDS,
)
def test_service_filter_equal():
services = [s[0] for s in AUDITED_SERVICES]
to_check, filters = parse_quer... | 3,961 | Python | .py | 79 | 45.658228 | 96 | 0.669001 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,433 | test_recordsize_choices.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/pool/test_recordsize_choices.py | import io
from unittest.mock import patch
from middlewared.plugins.pool_.dataset_recordsize import PoolDatasetService
def test_recordsize_choices():
with patch("middlewared.plugins.pool_.dataset_recordsize.open") as mock:
mock.return_value = io.StringIO("32768\n")
assert PoolDatasetService(None).... | 398 | Python | .py | 7 | 52.571429 | 117 | 0.724227 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,434 | test_unlock.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/pool/test_unlock.py | from unittest.mock import Mock
import pytest
from middlewared.plugins.pool_.dataset_encryption_lock import PoolDatasetService
@pytest.mark.parametrize("request_datasets,keys_supplied,queried_datasets,result", [
(
[{"name": "tank/test", "recursive": True}, {"name": "tank/test/child", "recursive": True},
... | 1,200 | Python | .py | 22 | 47.272727 | 114 | 0.672913 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,435 | test_schedule.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/smart/test_schedule.py | from middlewared.plugins.smart_.schedule import smartd_schedule_piece
def test__smartd_schedule_piece__every_day_of_week():
assert smartd_schedule_piece("1,2,3,4,5,6,7", 1, 7) == "."
def test__smartd_schedule_piece__every_day_of_week_wildcard():
assert smartd_schedule_piece("*", 1, 7) == "."
def test__sma... | 1,500 | Python | .py | 25 | 56.12 | 77 | 0.674707 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,436 | test_crud.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/smart/test_crud.py | import pytest
from middlewared.plugins.smart import smart_test_schedules_intersect_at
DEFAULTS = {"hour": "*", "month": "*", "dom": "*", "dow": "*"}
@pytest.mark.parametrize("a,b,result", [
({"hour": "1"}, {"hour": "2"}, None),
({"hour": "*"}, {"hour": "2"}, "02:00"),
({"hour": "*/3"}, {"hour": "1,7,15... | 1,000 | Python | .py | 17 | 54.882353 | 100 | 0.471853 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,437 | test_vm_devices_xml.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/vm/test_vm_devices_xml.py | import pytest
from unittest.mock import patch
from xml.etree import ElementTree as etree
from middlewared.plugins.vm.devices import CDROM, DISK, NIC, RAW, DISPLAY
from middlewared.plugins.vm.supervisor.domain_xml import devices_xml
from middlewared.pytest.unit.middleware import Middleware
GUEST_CHANEL = '<channel ty... | 8,137 | Python | .py | 162 | 42.283951 | 128 | 0.594747 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,438 | test_attachments.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/vm/test_attachments.py | import pytest
from middlewared.plugins.vm.attachments import determine_recursive_search
@pytest.mark.parametrize('recursive,device,child_datasets,result', [
(True, {'attributes': {'path': '/mnt/tank/somefile'}, 'dtype': 'CDROM'}, ['tank/child'], True),
(False, {'attributes': {'path': '/dev/zvol/tank/somezvol... | 764 | Python | .py | 11 | 66.363636 | 105 | 0.689333 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,439 | test_vm_gpu_pci_choices.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/vm/test_vm_gpu_pci_choices.py | from unittest.mock import Mock, patch
from middlewared.pytest.unit.helpers import load_compound_service
from middlewared.pytest.unit.middleware import Middleware
VMDeviceService = load_compound_service('vm.device')
AVAILABLE_GPUs = [
{
'addr': {
'pci_slot': '0000:16:0e.0',
'domai... | 5,637 | Python | .py | 210 | 14.709524 | 104 | 0.354916 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,440 | test_pci_device_iommu_groups.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/vm/test_pci_device_iommu_groups.py | from pathlib import PosixPath
from unittest.mock import Mock, patch
from middlewared.utils.iommu import get_iommu_groups_info
DEVICES_PATH = [
PosixPath('/sys/kernel/iommu_groups/55/devices/0000:64:0a.1'),
PosixPath('/sys/kernel/iommu_groups/83/devices/0000:b2:0f.0'),
PosixPath('/sys/kernel/iommu_groups/... | 2,459 | Python | .py | 85 | 18.129412 | 97 | 0.441959 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,441 | test_passthrough_choices.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/vm/test_passthrough_choices.py | from unittest.mock import Mock
import pytest
from middlewared.plugins.vm.pci import VMDeviceService
from middlewared.pytest.unit.middleware import Middleware
@pytest.mark.parametrize('pcidevs,results', [
(
Mock(
sys_name='0000:00:00.0',
attributes={'class': b'0x060000'},
... | 3,849 | Python | .py | 116 | 19.008621 | 112 | 0.408152 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,442 | test_vm_libvirt_xml.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/vm/test_vm_libvirt_xml.py | import pytest
from xml.etree import ElementTree as etree
from middlewared.plugins.vm.supervisor.domain_xml import clock_xml, commandline_xml, cpu_xml, features_xml
@pytest.mark.parametrize('vm_data,expected_xml', [
({'hyperv_enlightenments': False, 'time': 'LOCAL'}, '<clock offset="localtime" />'),
({'hyper... | 5,307 | Python | .py | 126 | 35.071429 | 120 | 0.567008 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,443 | test_smart_attributes.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/disk/test_smart_attributes.py | import textwrap
from unittest.mock import AsyncMock
import pytest
from middlewared.plugins.disk_.smart_attributes import DiskService
from middlewared.pytest.unit.middleware import Middleware
@pytest.mark.asyncio
async def test__disk_service__sata_dom_lifetime_left():
m = Middleware()
m["disk.smartctl"] = A... | 2,001 | Python | .py | 28 | 64.642857 | 113 | 0.604071 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,444 | test_label_to_dev.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/disk/test_label_to_dev.py | import stat
import pytest
from middlewared.plugins.disk_.disk_info import DiskService
@pytest.mark.parametrize("label,dev,block_devices,symlinks", [
# Normal label (by-partuuid)
(
"disk/by-partuuid/4a3469b8-4c2f-11ee-9e9d-ac1f6b0a9d32",
"sda1",
["/dev/sda1"],
[("/dev/disk/by-... | 923 | Python | .py | 33 | 21.848485 | 86 | 0.60452 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,445 | test_dev_to_ident.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/disk/test_dev_to_ident.py | import pytest
from unittest.mock import Mock
from middlewared.plugins.disk_.sync import DiskService
OBJ = DiskService(Mock())
BY_UUID = (
"pmem0",
{
"pmem0": {
"name": "pmem0",
"serial": None,
"serial_lunid": None,
"parts": [{
"partition_... | 1,355 | Python | .py | 56 | 16.982143 | 110 | 0.512741 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,446 | test_availability.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/disk/test_availability.py | from unittest.mock import AsyncMock
import pytest
from middlewared.plugins.disk_.availability import DiskService
from middlewared.pytest.unit.middleware import Middleware
@pytest.mark.parametrize("disks,allow_duplicate_serials,errors", [
(["sda", "sda"], False, []),
(["sdi"], False, ["The following disks we... | 1,564 | Python | .py | 28 | 50.821429 | 107 | 0.623775 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,447 | test_ident_to_dev.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/disk/test_ident_to_dev.py | import pytest
from unittest.mock import Mock
from middlewared.plugins.disk_.sync import DiskService
OBJ = DiskService(Mock())
BY_UUID = (
"{uuid}b9253137-a0a4-11ec-b194-3cecef615fde",
{
"pmem0": {
"name": "pmem0",
"serial": None,
"serial_lunid": None,
"p... | 1,403 | Python | .py | 58 | 16.706897 | 106 | 0.500373 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,448 | test_utils.py | truenas_middleware/src/middlewared/middlewared/pytest/unit/plugins/update/test_utils.py | import pytest
from middlewared.plugins.update_.utils import can_update
@pytest.mark.parametrize("old_version,new_version,result", [
("FreeNAS-11", "FreeNAS-11.1", True),
("FreeNAS-11.1", "FreeNAS-11.1-U1", True),
("FreeNAS-11.3-U2", "FreeNAS-11.3-U2.1", True),
("FreeNAS-11.3-U2", "FreeNAS-12.0", True... | 2,047 | Python | .py | 38 | 49.421053 | 103 | 0.663836 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,449 | service_mixin.py | truenas_middleware/src/middlewared/middlewared/service/service_mixin.py | from middlewared.service_exception import CallError
class ServiceChangeMixin:
async def _service_change(self, service, verb, options=None):
svc_state = (await self.middleware.call(
'service.query',
[('service', '=', service)],
{'get': True}
))['state'].lower()
... | 958 | Python | .py | 20 | 36 | 91 | 0.589056 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,450 | compound_service.py | truenas_middleware/src/middlewared/middlewared/service/compound_service.py | import itertools
from .base import service_config
from .service import Service
class CompoundService(Service):
def __init__(self, middleware, parts):
super().__init__(middleware)
config_specified = {}
for part1, part2 in itertools.combinations(parts, 2):
for key in set(part1.... | 1,699 | Python | .py | 36 | 33.444444 | 107 | 0.545124 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,451 | service_part.py | truenas_middleware/src/middlewared/middlewared/service/service_part.py | import inspect
from middlewared.utils.type import copy_function_metadata
from .base import ServiceBase
class ServicePartBaseMeta(ServiceBase):
def __new__(cls, name, bases, attrs):
klass = super().__new__(cls, name, bases, attrs)
if name == 'ServicePartBase':
return klass
i... | 1,718 | Python | .py | 33 | 40.242424 | 119 | 0.621783 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,452 | core_service.py | truenas_middleware/src/middlewared/middlewared/service/core_service.py | import asyncio
import errno
import inspect
import ipaddress
import os
import re
import socket
import threading
import time
import traceback
import uuid
from collections import defaultdict
from remote_pdb import RemotePdb
from subprocess import run
import middlewared.main
from middlewared.api import api_method
from m... | 34,009 | Python | .py | 765 | 31.665359 | 150 | 0.549272 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,453 | crud_service.py | truenas_middleware/src/middlewared/middlewared/service/crud_service.py | import asyncio
import copy
import errno
from pydantic import create_model, Field
from typing_extensions import Annotated
from middlewared.api import api_method
from middlewared.api.base.model import BaseModel
from middlewared.api.current import QueryArgs, QueryOptions
from middlewared.service_exception import CallErr... | 15,747 | Python | .py | 334 | 35.080838 | 118 | 0.574109 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,454 | system_service.py | truenas_middleware/src/middlewared/middlewared/service/system_service.py | from middlewared.schema import accepts
from .config_service import ConfigService
from .decorators import private
class SystemServiceService(ConfigService):
"""
System service class
Meant for services that manage system services configuration.
"""
@accepts()
async def config(self):
r... | 1,073 | Python | .py | 27 | 31.222222 | 113 | 0.647738 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,455 | __init__.py | truenas_middleware/src/middlewared/middlewared/service/__init__.py | from middlewared.schema import accepts, returns # noqa
from middlewared.service_exception import ( # noqa
CallException, CallError, InstanceNotFound, ValidationError, ValidationErrors
)
from middlewared.utils import filter_list # noqa
from .compound_service import CompoundService # noqa
from .config_service import... | 1,145 | Python | .py | 22 | 50 | 98 | 0.816964 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,456 | config_service.py | truenas_middleware/src/middlewared/middlewared/service/config_service.py | import asyncio
import copy
from middlewared.schema import accepts, Dict, Patch, returns
from .base import ServiceBase
from .decorators import private
from .service import Service
from .service_mixin import ServiceChangeMixin
get_or_insert_lock = asyncio.Lock()
class ConfigServiceMetabase(ServiceBase):
def __... | 3,517 | Python | .py | 78 | 34.089744 | 93 | 0.596081 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,457 | base.py | truenas_middleware/src/middlewared/middlewared/service/base.py | def service_config(klass, config):
namespace = klass.__name__
if namespace.endswith('Service'):
namespace = namespace[:-7]
namespace = namespace.lower()
config_attrs = {
'datastore': None,
'datastore_prefix': '',
'datastore_extend': None,
'datastore_extend_contex... | 3,062 | Python | .py | 73 | 33.726027 | 111 | 0.624454 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,458 | sharing_service.py | truenas_middleware/src/middlewared/middlewared/service/sharing_service.py | from middlewared.async_validators import check_path_resides_within_volume
from middlewared.plugins.zfs_.validation_utils import check_zvol_in_boot_pool_using_path
from middlewared.utils.path import FSLocation, path_location, strip_location_prefix
from .crud_service import CRUDService
from .decorators import pass_app, ... | 6,395 | Python | .py | 137 | 37.620438 | 111 | 0.654551 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,459 | service.py | truenas_middleware/src/middlewared/middlewared/service/service.py | from middlewared.logger import Logger
from .base import ServiceBase
class Service(object, metaclass=ServiceBase):
"""
Generic service abstract class
This is meant for services that do not follow any standard.
"""
def __init__(self, middleware):
self.logger = Logger(type(self).__name__).g... | 368 | Python | .py | 10 | 31.8 | 63 | 0.714689 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,460 | decorators.py | truenas_middleware/src/middlewared/middlewared/service/decorators.py | import asyncio
import threading
from collections import defaultdict, namedtuple
from functools import wraps
from middlewared.schema import accepts, Int, List, OROperator, Ref, returns
LOCKS = defaultdict(asyncio.Lock)
PeriodicTaskDescriptor = namedtuple('PeriodicTaskDescriptor', ['interval', 'run_on_start'])
THREAD... | 8,998 | Python | .py | 182 | 41.659341 | 120 | 0.670094 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,461 | bootenv.py | truenas_middleware/src/middlewared/middlewared/plugins/bootenv.py | from middlewared.plugins.zfs_.validation_utils import validate_dataset_name
from middlewared.schema import accepts, Bool, Datetime, Dict, Int, returns, Str
from middlewared.service import (
CallError, CRUDService, ValidationErrors, filterable, item_method, job, private
)
from middlewared.utils import filter_list, P... | 12,681 | Python | .py | 265 | 35.664151 | 117 | 0.555277 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,462 | fcport.py | truenas_middleware/src/middlewared/middlewared/plugins/fcport.py | import middlewared.sqlalchemy as sa
class FCPortModel(sa.Model):
__tablename__ = 'services_fibrechanneltotarget'
id = sa.Column(sa.Integer(), primary_key=True)
fc_port = sa.Column(sa.String(10))
fc_target_id = sa.Column(sa.ForeignKey('services_iscsitarget.id'), nullable=True, index=True)
| 308 | Python | .py | 6 | 47.166667 | 97 | 0.735786 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,463 | filesystem.py | truenas_middleware/src/middlewared/middlewared/plugins/filesystem.py | import binascii
import errno
import functools
import os
import pathlib
import shutil
import stat as statlib
import time
import pyinotify
from itertools import product
from middlewared.event import EventSource
from middlewared.plugins.pwenc import PWENC_FILE_SECRET, PWENC_FILE_SECRET_MODE
from middlewared.plugins.dock... | 26,640 | Python | .py | 622 | 32.572347 | 121 | 0.586988 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,464 | ipmi.py | truenas_middleware/src/middlewared/middlewared/plugins/ipmi.py | import os
from middlewared.schema import accepts, returns, Bool
from middlewared.service import Service
class IPMIService(Service):
class Config:
cli_namespace = 'system.ipmi'
@accepts(roles=['READONLY_ADMIN'])
@returns(Bool('ipmi_loaded'))
def is_loaded(self):
"""Returns a boolean ... | 984 | Python | .py | 18 | 48.611111 | 110 | 0.711157 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,465 | ldap.py | truenas_middleware/src/middlewared/middlewared/plugins/ldap.py | import enum
import errno
import ipaddress
import ldap as pyldap
import os
import socket
import struct
from urllib.parse import urlparse
from middlewared.schema import accepts, returns, Bool, Dict, Int, List, Str, Ref, LDAP_DN
from middlewared.service import job, private, ConfigService, Service, ValidationErrors
from m... | 40,310 | Python | .py | 841 | 36.675386 | 118 | 0.604008 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,466 | failover.py | truenas_middleware/src/middlewared/middlewared/plugins/failover.py | import asyncio
import base64
import errno
import json
import itertools
import logging
import os
import shutil
import stat
import time
from functools import partial
from middlewared.auth import TrueNasNodeSessionManagerCredentials
from middlewared.schema import accepts, Bool, Dict, Int, List, NOT_PROVIDED, Str, returns... | 52,952 | Python | .py | 1,099 | 37.020928 | 119 | 0.608229 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,467 | device.py | truenas_middleware/src/middlewared/middlewared/plugins/device.py | from middlewared.schema import accepts, Bool, Dict, Int, List, OROperator, returns, Str
from middlewared.service import Service
class DeviceService(Service):
class Config:
cli_namespace = 'system.device'
@accepts(
Dict(
'data',
Str('type', enum=['SERIAL', 'DISK', 'GPU... | 2,474 | Python | .py | 64 | 27.265625 | 99 | 0.534719 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,468 | migration.py | truenas_middleware/src/middlewared/middlewared/plugins/migration.py | import asyncio
import os
import sqlite3
from middlewared.service import Service
import middlewared.sqlalchemy as sa
from middlewared.utils.plugins import load_modules
from middlewared.utils.python import get_middlewared_dir
def load_migrations(middleware):
return sorted(load_modules(os.path.join(get_middlewared... | 2,078 | Python | .py | 42 | 39.642857 | 120 | 0.652454 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,469 | snmp.py | truenas_middleware/src/middlewared/middlewared/plugins/snmp.py | import middlewared.sqlalchemy as sa
import subprocess
import os
from contextlib import suppress
from middlewared.common.ports import ServicePortDelegate
from middlewared.plugins.snmp_.utils_snmp_user import (
SNMPSystem, _add_system_user,
add_snmp_user, delete_snmp_user, get_users_cmd
)
from middlewared.schema... | 11,041 | Python | .py | 220 | 40.25 | 115 | 0.621531 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,470 | acme_protocol.py | truenas_middleware/src/middlewared/middlewared/plugins/acme_protocol.py | import josepy as jose
import json
import requests
from middlewared.api import api_method
from middlewared.api.current import (
ACMERegistrationCreateArgs, ACMERegistrationCreateResult, DNSAuthenticatorUpdateArgs, DNSAuthenticatorUpdateResult,
DNSAuthenticatorCreateArgs, DNSAuthenticatorCreateResult, DNSAuthent... | 11,650 | Python | .py | 274 | 31.145985 | 119 | 0.591303 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,471 | zettarepl.py | truenas_middleware/src/middlewared/middlewared/plugins/zettarepl.py | from collections import defaultdict
from contextlib import asynccontextmanager
from ctypes import c_bool
from datetime import time as _time, timedelta
import errno
import logging
import multiprocessing
import os
import pytz
import queue
import re
import setproctitle
import signal
import socket
import threading
import t... | 48,569 | Python | .py | 889 | 39.813273 | 120 | 0.587476 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,472 | kerberos.py | truenas_middleware/src/middlewared/middlewared/plugins/kerberos.py | import asyncio
import base64
import errno
import gssapi
import os
import subprocess
import tempfile
import time
from middlewared.schema import accepts, Dict, Int, List, Patch, Str, OROperator, Password, Ref, Bool
from middlewared.service import CallError, ConfigService, CRUDService, job, periodic, private, ValidationE... | 36,004 | Python | .py | 839 | 31.45292 | 111 | 0.578196 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,473 | config.py | truenas_middleware/src/middlewared/middlewared/plugins/config.py | from datetime import datetime
import glob
import os
import pathlib
import re
import shutil
import subprocess
import tarfile
import tempfile
from middlewared.schema import accepts, Bool, Dict, returns
from middlewared.service import CallError, Service, job, pass_app, private
from middlewared.plugins.pwenc import PWENC_... | 12,748 | Python | .py | 253 | 37.84585 | 120 | 0.59669 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,474 | network.py | truenas_middleware/src/middlewared/middlewared/plugins/network.py | import asyncio
import contextlib
import ipaddress
from collections import defaultdict
from itertools import zip_longest
from ipaddress import ip_address, ip_interface
import middlewared.sqlalchemy as sa
from middlewared.service import CallError, CRUDService, filterable, pass_app, private
from middlewared.utils import ... | 87,457 | Python | .py | 1,748 | 36.589245 | 120 | 0.560426 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,475 | cron.py | truenas_middleware/src/middlewared/middlewared/plugins/cron.py | import contextlib
import errno
import syslog
from middlewared.schema import accepts, Bool, Cron, Dict, Int, Patch, returns, Str
from middlewared.service import CallError, CRUDService, job, private, ValidationErrors
import middlewared.sqlalchemy as sa
from middlewared.utils.user_context import run_command_with_user_con... | 9,023 | Python | .py | 233 | 26.429185 | 110 | 0.51865 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,476 | ssh.py | truenas_middleware/src/middlewared/middlewared/plugins/ssh.py | import base64
import hashlib
import os
import subprocess
import syslog
import middlewared.sqlalchemy as sa
from middlewared.async_validators import validate_port
from middlewared.common.ports import ServicePortDelegate
from middlewared.schema import accepts, Bool, Dict, Int, List, Patch, returns, Str, ValidationError... | 10,368 | Python | .py | 221 | 37.266968 | 115 | 0.594127 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,477 | etc.py | truenas_middleware/src/middlewared/middlewared/plugins/etc.py | import asyncio
from collections import defaultdict
import imp
import os
from mako import exceptions
from middlewared.service import CallError, Service
from middlewared.utils.io import write_if_changed, FileChanges
from middlewared.utils.mako import get_template
DEFAULT_ETC_PERMS = 0o644
DEFAULT_ETC_XID = 0
class Fi... | 20,137 | Python | .py | 459 | 31.023965 | 116 | 0.482012 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,478 | pwenc.py | truenas_middleware/src/middlewared/middlewared/plugins/pwenc.py | import base64
import fcntl
import os
import threading
from contextlib import contextmanager
from Cryptodome.Cipher import AES
from Cryptodome.Util import Counter
from middlewared.service import Service
from middlewared.utils.path import pathref_open
PWENC_BLOCK_SIZE = 32
PWENC_FILE_SECRET = os.environ.get('FREENAS_P... | 4,342 | Python | .py | 108 | 32.055556 | 103 | 0.640305 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,479 | init_shutdown_script.py | truenas_middleware/src/middlewared/middlewared/plugins/init_shutdown_script.py | import asyncio
import os
import stat
import subprocess
from middlewared.schema import Bool, Dict, Int, Patch, Str, ValidationErrors, accepts
from middlewared.service import CRUDService, job, private
from middlewared.service_exception import CallError
import middlewared.sqlalchemy as sa
from middlewared.utils import ru... | 6,877 | Python | .py | 152 | 35.763158 | 119 | 0.611194 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,480 | nvidia.py | truenas_middleware/src/middlewared/middlewared/plugins/nvidia.py | import contextlib
import os
import shutil
import subprocess
import tempfile
import requests
from middlewared.service import job, Service
from middlewared.utils.gpu import get_gpus
from middlewared.utils.rootfs import ReadonlyRootfsManager
HEADERS = {"User-Agent": "curl/7.88.1"}
class NvidiaService(Service):
cl... | 4,783 | Python | .py | 99 | 36.636364 | 114 | 0.589677 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,481 | smb.py | truenas_middleware/src/middlewared/middlewared/plugins/smb.py | import asyncio
import codecs
import errno
import middlewared.sqlalchemy as sa
import os
import re
from pathlib import Path
import uuid
import unicodedata
from copy import deepcopy
from middlewared.common.attachment import LockableFSAttachmentDelegate
from middlewared.common.listen import SystemServiceListenMultipleDe... | 76,742 | Python | .py | 1,589 | 36.261171 | 119 | 0.584202 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,482 | cloud_sync.py | truenas_middleware/src/middlewared/middlewared/plugins/cloud_sync.py | from middlewared.alert.base import Alert, AlertCategory, AlertClass, AlertLevel, OneShotAlertClass
from middlewared.api import api_method
from middlewared.api.current import (CloudCredentialEntry,
CloudCredentialCreateArgs, CloudCredentialCreateResult,
... | 45,460 | Python | .py | 975 | 34.628718 | 118 | 0.575449 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,483 | account.py | truenas_middleware/src/middlewared/middlewared/plugins/account.py | from collections import defaultdict
import errno
import glob
import json
import os
import pam
import shlex
import shutil
import stat
import wbclient
from pathlib import Path
from collections import defaultdict
from contextlib import suppress
from sqlalchemy.orm import relationship
from dataclasses import asdict
from ... | 80,364 | Python | .py | 1,716 | 33.389277 | 120 | 0.54507 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,484 | auth.py | truenas_middleware/src/middlewared/middlewared/plugins/auth.py | import asyncio
import random
from datetime import timedelta
import errno
import pam
import time
from middlewared.api import api_method
from middlewared.api.base.server.ws_handler.rpc import RpcWebSocketAppEvent
from middlewared.api.current import (
AuthLegacyPasswordLoginArgs, AuthLegacyApiKeyLoginArgs, AuthLegacy... | 41,486 | Python | .py | 894 | 32.940716 | 114 | 0.570973 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,485 | cache.py | truenas_middleware/src/middlewared/middlewared/plugins/cache.py | from middlewared.schema import Any, Str, Int, accepts
from middlewared.service import Service, private
from collections import namedtuple
import time
class CacheService(Service):
class Config:
private = True
def __init__(self, *args, **kwargs):
super(CacheService, self).__init__(*args, **kw... | 1,990 | Python | .py | 64 | 22.59375 | 65 | 0.548269 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,486 | activedirectory.py | truenas_middleware/src/middlewared/middlewared/plugins/activedirectory.py | import errno
import json
import ipaddress
import os
import contextlib
from middlewared.plugins.smb import SMBCmd
from middlewared.plugins.kerberos import krb5ccache
from middlewared.schema import (
accepts, Bool, Dict, Int, IPAddr, LDAP_DN, List, NetbiosName, Ref, returns, Str
)
from middlewared.service import job... | 39,346 | Python | .py | 760 | 38.123684 | 130 | 0.59127 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,487 | snapshot.py | truenas_middleware/src/middlewared/middlewared/plugins/snapshot.py | from datetime import datetime, time, timedelta
import os
from middlewared.common.attachment import FSAttachmentDelegate
from middlewared.schema import accepts, returns, Bool, Cron, Dataset, Dict, Int, List, Patch, Str
from middlewared.service import CallError, CRUDService, item_method, private, ValidationErrors
import... | 15,323 | Python | .py | 341 | 32.680352 | 121 | 0.562659 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,488 | boot.py | truenas_middleware/src/middlewared/middlewared/plugins/boot.py | import asyncio
import os
from contextlib import asynccontextmanager
from middlewared.schema import accepts, Bool, Dict, Int, List, Str, returns, Patch
from middlewared.service import CallError, Service, job, private
from middlewared.utils import run
from middlewared.utils.disks import valid_zfs_partition_uuids
from mi... | 13,595 | Python | .py | 304 | 34.848684 | 116 | 0.596675 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,489 | keychain.py | truenas_middleware/src/middlewared/middlewared/plugins/keychain.py | import asyncio
import base64
import enum
import errno
import os
import re
import ssl
import subprocess
import tempfile
import urllib.parse
from truenas_api_client import Client, ClientException
from middlewared.api import api_method
from middlewared.api.current import (
KeychainCredentialEntry,
KeychainCreden... | 25,955 | Python | .py | 543 | 36.322284 | 134 | 0.604108 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,490 | replication.py | truenas_middleware/src/middlewared/middlewared/plugins/replication.py | from datetime import datetime, time
import os
import re
from middlewared.auth import fake_app
from middlewared.common.attachment import FSAttachmentDelegate
from middlewared.schema import accepts, Bool, Cron, Dataset, Dict, Int, List, Patch, returns, Str
from middlewared.service import item_method, job, pass_app, priv... | 44,536 | Python | .py | 834 | 40.231415 | 128 | 0.583433 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,491 | api_key.py | truenas_middleware/src/middlewared/middlewared/plugins/api_key.py | import pam
import errno
from typing import Literal, TYPE_CHECKING
from datetime import datetime, UTC
from middlewared.api import api_method
from middlewared.api.current import (
ApiKeyEntry, ApiKeyCreateArgs, ApiKeyCreateResult, ApiKeyUpdateArgs, ApiKeyUpdateResult,
ApiKeyDeleteArgs, ApiKeyDeleteResult, ApiKe... | 13,132 | Python | .py | 319 | 31.122257 | 103 | 0.584314 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,492 | usage.py | truenas_middleware/src/middlewared/middlewared/plugins/usage.py | import asyncio
import json
import os
import random
import subprocess
from collections import defaultdict
import aiohttp
from middlewared.service import Service
from middlewared.utils.mount import getmntinfo
from middlewared.utils.time_utils import utc_now
USAGE_URL = 'https://usage.truenas.com/submit'
class Usage... | 19,156 | Python | .py | 405 | 33.088889 | 120 | 0.512331 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,493 | ftp.py | truenas_middleware/src/middlewared/middlewared/plugins/ftp.py | from middlewared.async_validators import check_path_resides_within_volume, resolve_hostname, validate_port
from middlewared.schema import accepts, Bool, Dict, Dir, Int, Patch, Str
from middlewared.validators import Exact, Match, Or, Range
from middlewared.service import private, SystemServiceService, ValidationErrors
i... | 12,298 | Python | .py | 206 | 51.033981 | 119 | 0.671814 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,494 | enclosure.py | truenas_middleware/src/middlewared/middlewared/plugins/enclosure.py | import asyncio
import errno
import logging
import re
import pathlib
from collections import OrderedDict
from libsg3.ses import EnclosureDevice
from middlewared.schema import Dict, Int, Str, accepts
from middlewared.service import CallError, CRUDService, filterable, private
from middlewared.service_exception import Ma... | 39,345 | Python | .py | 1,001 | 28.475524 | 117 | 0.556401 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,495 | keyvalue.py | truenas_middleware/src/middlewared/middlewared/plugins/keyvalue.py | from truenas_api_client import json
from middlewared.schema import Any, Str, accepts, Dict
from middlewared.service import Service
import middlewared.sqlalchemy as sa
class KeyValueModel(sa.Model):
__tablename__ = 'system_keyvalue'
id = sa.Column(sa.Integer(), primary_key=True)
key = sa.Column(sa.String... | 1,959 | Python | .py | 52 | 28.807692 | 118 | 0.586061 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,496 | ntp.py | truenas_middleware/src/middlewared/middlewared/plugins/ntp.py | import errno
import subprocess
import middlewared.sqlalchemy as sa
from middlewared.plugins.ntp_.enums import Mode, State
from middlewared.schema import Bool, Dict, Int, IPAddr, Patch, Str, accepts
from middlewared.service import CRUDService, ValidationErrors, filterable, private
from middlewared.service_exception imp... | 8,373 | Python | .py | 199 | 32.497487 | 117 | 0.605759 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,497 | dlm.py | truenas_middleware/src/middlewared/middlewared/plugins/dlm.py | import asyncio
from middlewared.service import Service, private
class DistributedLockManagerService(Service):
"""
Support the configuration of the kernel dlm in a multi-controller environment.
This will handle the following events:
- kernel udev online lockspace event (aka dlm.join_lockspace)
- ... | 17,176 | Python | .py | 312 | 44.711538 | 140 | 0.653887 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,498 | service.py | truenas_middleware/src/middlewared/middlewared/plugins/service.py | import asyncio
import errno
import psutil
from middlewared.plugins.service_.services.all import all_services
from middlewared.plugins.service_.services.base import IdentifiableServiceInterface
from middlewared.plugins.service_.utils import app_has_write_privilege_for_service
from middlewared.schema import accepts, B... | 18,118 | Python | .py | 392 | 35.915816 | 120 | 0.623349 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,499 | directoryservices.py | truenas_middleware/src/middlewared/middlewared/plugins/directoryservices.py | import enum
import struct
from base64 import b64decode
from middlewared.schema import accepts, Dict, List, OROperator, returns, Str
from middlewared.service import no_authz_required, Service, private, job
from middlewared.service_exception import CallError, MatchNotFound
from middlewared.utils.directoryservices.consta... | 9,130 | Python | .py | 201 | 36.706468 | 112 | 0.647648 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |