refactor(models): UserDict and ProcessDict in os_models.py, re-exported from models
models.py stays within its line baseline; the baseline drops to what is left.
This commit is contained in:
1 parent
5c2bfb7dfa
commit
0f33653ca8
3 files changed
+46
-34
No files matched your search
@@ -9,7 +9,8 @@ from typing import Literal, NotRequired, get_args
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
# The SNMP health profile shapes live in snmp_health_profile.py, those of the access
|
||||
# point getters in access_point_models.py; re-exported here, where they were.
|
||||
# point getters in access_point_models.py, an OS's accounts and processes in
|
||||
# os_models.py; re-exported here, where they were.
|
||||
from napalm_device_types.access_point_models import ChannelScanEntryDict as ChannelScanEntryDict
|
||||
from napalm_device_types.access_point_models import (
|
||||
FastTransitionConfigDict as FastTransitionConfigDict,
|
||||
@@ -22,6 +23,8 @@ from napalm_device_types.access_point_models import SSIDDict as SSIDDict
|
||||
from napalm_device_types.access_point_models import WirelessClientDict as WirelessClientDict
|
||||
from napalm_device_types.access_point_models import WirelessConfigDict as WirelessConfigDict
|
||||
from napalm_device_types.kernel_models import KernelFactsDict as KernelFactsDict
|
||||
from napalm_device_types.os_models import ProcessDict as ProcessDict
|
||||
from napalm_device_types.os_models import UserDict as UserDict
|
||||
from napalm_device_types.snmp_health_profile import SnmpHealthProfile as SnmpHealthProfile
|
||||
from napalm_device_types.snmp_health_profile import SnmpInterfacesSpec as SnmpInterfacesSpec
|
||||
from napalm_device_types.snmp_health_profile import SnmpMemorySpec as SnmpMemorySpec
|
||||
@@ -911,38 +914,6 @@ class ReplicationJobDict(TypedDict):
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class UserDict(TypedDict):
|
||||
"""A local OS user account."""
|
||||
|
||||
username: str
|
||||
#: POSIX's uid; on Windows the relative identifier, the last part of the SID
|
||||
#: (500 for the built-in Administrator, 1000 and up for accounts created).
|
||||
uid: int
|
||||
gid: int
|
||||
home: str
|
||||
shell: str
|
||||
groups: list[str] # all supplementary group names
|
||||
#: The account's security identifier, where the host names accounts by one
|
||||
#: (Windows: "S-1-5-21-...-1001"); left out on a POSIX host.
|
||||
sid: NotRequired[str]
|
||||
|
||||
|
||||
class ProcessDict(TypedDict):
|
||||
"""A running OS process."""
|
||||
|
||||
pid: int
|
||||
ppid: int
|
||||
user: str
|
||||
cpu: float # CPU utilisation 0.0–100.0
|
||||
memory: float # RSS percentage of total RAM 0.0–100.0
|
||||
vsz: int # virtual memory size in KiB
|
||||
rss: int # resident set size in KiB
|
||||
tty: str # controlling terminal; empty string if none
|
||||
state: str # "R" running, "S" sleeping, "D" uninterruptible, "Z" zombie, etc.
|
||||
started: str # start time string as reported by ``ps`` (e.g. "12:34" or "May28")
|
||||
command: str # full command line
|
||||
|
||||
|
||||
class ApplyUpdatesResultDict(TypedDict):
|
||||
"""Result of an ``apply_updates()`` call."""
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
"""What an OS driver reports about the host's accounts and processes (``OSDriver``).
|
||||
|
||||
``get_os_users`` gives :class:`UserDict`, ``get_processes`` :class:`ProcessDict`. Both
|
||||
lived in :mod:`napalm_device_types.models` and are re-exported there.
|
||||
"""
|
||||
|
||||
from typing import NotRequired
|
||||
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
class UserDict(TypedDict):
|
||||
"""A local OS user account."""
|
||||
|
||||
username: str
|
||||
#: POSIX's uid; on Windows the relative identifier, the last part of the SID
|
||||
#: (500 for the built-in Administrator, 1000 and up for accounts created).
|
||||
uid: int
|
||||
gid: int
|
||||
home: str
|
||||
shell: str
|
||||
groups: list[str] # all supplementary group names
|
||||
#: The account's security identifier, where the host names accounts by one
|
||||
#: (Windows: "S-1-5-21-...-1001"); left out on a POSIX host.
|
||||
sid: NotRequired[str]
|
||||
|
||||
|
||||
class ProcessDict(TypedDict):
|
||||
"""A running OS process."""
|
||||
|
||||
pid: int
|
||||
ppid: int
|
||||
user: str
|
||||
cpu: float # CPU utilisation 0.0–100.0
|
||||
memory: float # RSS percentage of total RAM 0.0–100.0
|
||||
vsz: int # virtual memory size in KiB
|
||||
rss: int # resident set size in KiB
|
||||
tty: str # controlling terminal; empty string if none
|
||||
state: str # "R" running, "S" sleeping, "D" uninterruptible, "Z" zombie, etc.
|
||||
started: str # start time string as reported by ``ps`` (e.g. "12:34" or "May28")
|
||||
command: str # full command line
|
||||
@@ -31,7 +31,7 @@
|
||||
},
|
||||
"mypy_relaxed": [],
|
||||
"python_file_lines": {
|
||||
"napalm_device_types/models.py": 1336
|
||||
"napalm_device_types/models.py": 1312
|
||||
},
|
||||
"untyped_public": []
|
||||
}
|
||||
Reference in new issue
Block a user