πŸ” Overview

The MirrorRule model links a main Link to its immediate mirror/backup link.

  • main_link and mirror_link are one-to-one, so each link can have at most one β€œnext” and one β€œprevious”.
  • Multiple MirrorRule records form a chain of backups.

The model is responsible for switching traffic in Voluum when an active link is blocked.


πŸ“‘ Fields

FieldTypeDescription
main_linkOneToOne LinkCurrent (working) link.
mirror_linkOneToOne LinkNext backup link.
created_atdatetimeCreation timestamp.
updated_atdatetimeUpdate timestamp.
switchedboolWhether the switch was completed successfully.
switched_atdatetimeWhen the switch was completed.
ownerForeign Key UserOwner 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=True and switched_at=now()
    • promotes the mirror link to active
    • sends a Telegram notification
    • warns if there are no further backups available.