π Overview
The MirrorRule model links a main Link to its immediate mirror/backup link.
main_linkandmirror_linkare one-to-one, so each link can have at most one βnextβ and one βpreviousβ.- Multiple
MirrorRulerecords form a chain of backups.
The model is responsible for switching traffic in Voluum when an active link is blocked.
π Fields
| Field | Type | Description |
|---|---|---|
main_link | OneToOne Link | Current (working) link. |
mirror_link | OneToOne Link | Next backup link. |
created_at | datetime | Creation timestamp. |
updated_at | datetime | Update timestamp. |
switched | bool | Whether the switch was completed successfully. |
switched_at | datetime | When the switch was completed. |
owner | Foreign Key User | Owner of the link chain (nullable). |
π§© Methods
switch(action_by="system")
Attempts to switch traffic from main_link.link to mirror_link.link by updating Voluum.
Behavior
- Raises an error if the rule was already switched (
switched=True). - Calls
VoluumController.update_link(old_link, new_link). - On Voluum failure:
- sends a Telegram notification
- marks the mirror link (and its backups) as
ignored
- On success:
- sets
switched=Trueandswitched_at=now() - promotes the mirror link to
active - sends a Telegram notification
- warns if there are no further backups available.
- sets