wnm 0.0.8__py3-none-any.whl → 0.0.10__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of wnm might be problematic. Click here for more details.
- wnm/__init__.py +1 -1
- wnm/__main__.py +206 -953
- wnm/actions.py +45 -0
- wnm/common.py +21 -0
- wnm/config.py +653 -1
- wnm/decision_engine.py +388 -0
- wnm/executor.py +1292 -0
- wnm/firewall/__init__.py +13 -0
- wnm/firewall/base.py +71 -0
- wnm/firewall/factory.py +95 -0
- wnm/firewall/null_firewall.py +71 -0
- wnm/firewall/ufw_manager.py +118 -0
- wnm/migration.py +42 -0
- wnm/models.py +389 -122
- wnm/process_managers/__init__.py +23 -0
- wnm/process_managers/base.py +203 -0
- wnm/process_managers/docker_manager.py +371 -0
- wnm/process_managers/factory.py +83 -0
- wnm/process_managers/launchd_manager.py +592 -0
- wnm/process_managers/setsid_manager.py +340 -0
- wnm/process_managers/systemd_manager.py +443 -0
- wnm/reports.py +286 -0
- wnm/utils.py +403 -0
- wnm-0.0.10.dist-info/METADATA +316 -0
- wnm-0.0.10.dist-info/RECORD +28 -0
- {wnm-0.0.8.dist-info → wnm-0.0.10.dist-info}/WHEEL +1 -1
- wnm-0.0.8.dist-info/METADATA +0 -93
- wnm-0.0.8.dist-info/RECORD +0 -9
- {wnm-0.0.8.dist-info → wnm-0.0.10.dist-info}/entry_points.txt +0 -0
- {wnm-0.0.8.dist-info → wnm-0.0.10.dist-info}/top_level.txt +0 -0
wnm/actions.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"""Action model for representing planned node operations.
|
|
2
|
+
|
|
3
|
+
This module defines the action types and data structures used by the decision engine
|
|
4
|
+
to represent planned operations on nodes.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from dataclasses import dataclass
|
|
8
|
+
from enum import Enum
|
|
9
|
+
from typing import Optional
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ActionType(Enum):
|
|
13
|
+
"""Types of actions that can be performed on nodes."""
|
|
14
|
+
|
|
15
|
+
ADD_NODE = "add"
|
|
16
|
+
REMOVE_NODE = "remove"
|
|
17
|
+
UPGRADE_NODE = "upgrade"
|
|
18
|
+
START_NODE = "start"
|
|
19
|
+
STOP_NODE = "stop"
|
|
20
|
+
RESTART_NODE = "restart"
|
|
21
|
+
SURVEY_NODES = "survey"
|
|
22
|
+
RESURVEY_NODES = "resurvey"
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@dataclass
|
|
26
|
+
class Action:
|
|
27
|
+
"""Represents a planned action to be executed.
|
|
28
|
+
|
|
29
|
+
Attributes:
|
|
30
|
+
type: The type of action to perform
|
|
31
|
+
node_id: Optional node ID if action is node-specific
|
|
32
|
+
priority: Higher values indicate more urgent actions (default: 0)
|
|
33
|
+
reason: Human-readable explanation of why this action is needed
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
type: ActionType
|
|
37
|
+
node_id: Optional[int] = None
|
|
38
|
+
priority: int = 0
|
|
39
|
+
reason: str = ""
|
|
40
|
+
|
|
41
|
+
def __repr__(self) -> str:
|
|
42
|
+
"""Return a string representation of the action."""
|
|
43
|
+
if self.node_id is not None:
|
|
44
|
+
return f"Action({self.type.value}, node={self.node_id}, reason={self.reason})"
|
|
45
|
+
return f"Action({self.type.value}, reason={self.reason})"
|
wnm/common.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Primary node for want of one
|
|
2
|
+
QUEEN = 1
|
|
3
|
+
|
|
4
|
+
# Donation address, default to faucet vault, can be overridden in config
|
|
5
|
+
DONATE = "0x00455d78f850b0358E8cea5be24d415E01E107CF"
|
|
6
|
+
|
|
7
|
+
# Keep these as strings so they can be grepped in logs
|
|
8
|
+
STOPPED = "STOPPED" # 0 Node is not responding to it's metrics port
|
|
9
|
+
RUNNING = "RUNNING" # 1 Node is responding to it's metrics port
|
|
10
|
+
UPGRADING = "UPGRADING" # 2 Upgrade in progress
|
|
11
|
+
DISABLED = "DISABLED" # -1 Do not start
|
|
12
|
+
RESTARTING = "RESTARTING" # 3 re/starting a server intionally
|
|
13
|
+
MIGRATING = "MIGRATING" # 4 Moving volumes in progress
|
|
14
|
+
REMOVING = "REMOVING" # 5 Removing node in progress
|
|
15
|
+
DEAD = "DEAD" # -86 Broken node to cleanup
|
|
16
|
+
|
|
17
|
+
# Magic numbers extracted from codebase
|
|
18
|
+
MIN_NODES_THRESHOLD = 0 # Minimum nodes before considering actions
|
|
19
|
+
PORT_MULTIPLIER = 1000 # Port calculation: PortStart * 1000 + node_id
|
|
20
|
+
METRICS_PORT_BASE = 13000 # Metrics port calculation: 13000 + node_id
|
|
21
|
+
DEFAULT_CRISIS_BYTES = 2 * 10**9 # Default crisis threshold in bytes (2GB)
|