(20250210) Started working on MikroTik config automation.

This commit is contained in:
2025-02-10 19:35:28 +05:30
parent 95d90e807b
commit 94e5c81087
13 changed files with 789 additions and 836 deletions
+19 -159
View File
@@ -10,7 +10,7 @@
OBJECTIVE:
To provide a structure to receive auth details for MikroTik devices.
Maa chude, yaar. Ab fark nahin padtaa.
REFERENCES:
@@ -75,68 +75,26 @@ REGEX_SESSION_TOKEN = r"^[a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[89ab][a-f0-9]
# *****************************************************************************************************************
class MikroTikPPPoE1000Auth(BaseModel):
class MikroTikConfigAttemptResponse(BaseModel):
siteName: str = Field(
description = "Don't know, and don't want to know.",
min_length = 1,
frozen = True
success: bool = Field(
description = "To indicate whether or not, the action was a success",
frozen = False,
default = False
)
nasIp: str = Field(
description = "Don't know, and don't want to know.",
min_length = 1,
frozen = True
message: str = Field(
description = "To explain what happened in the process of handling the OAuth callback.",
frozen = False,
default = "ERR: Message not captured."
)
nasPort: int | None = Field(
description = "Don't know, and don't want to know.",
frozen = True,
exception: Any = Field(
description = "To pass on any exception that occurred in the process.",
frozen = False,
default = None
)
radius: str = Field(
description = "Don't know, and don't want to know.",
min_length = 1,
frozen = True
)
secret: str = Field(
description = "Don't know, and don't want to know.",
min_length = 1,
frozen = True
)
username: str = Field(
description = "Don't know, and don't want to know.",
min_length = 1,
frozen = True
)
password: str = Field(
description = "Don't know, and don't want to know.",
min_length = 1,
frozen = True
)
location: str = Field(
description = "Don't know, and don't want to know.",
min_length = 1,
frozen = True
)
snmpCommunity: str = Field(
description = "Don't know, and don't want to know.",
min_length = 1,
frozen = True
)
publicIpPool: str = Field(
description = "Don't know, and don't want to know.",
min_length = 1,
frozen = True
)
# ┏┓ ┏•
# ┃ ┏┓┏┓╋┓┏┓
# ┗┛┗┛┛┗┛┗┗┫
@@ -145,121 +103,23 @@ class MikroTikPPPoE1000Auth(BaseModel):
class Config:
extra = "forbid"
# ┓┏ ┓• ┓
# ┃┃┏┓┃┓┏┫┏┓╋┓┏┓┏┓
# ┗┛┗┻┗┗┗┻┗┻┗┗┛┛┗
# ┏┓ ┏┓
# ┃ ┓┏┏╋┏┓┏┳┓ ┣ ┓┏┏┓┏┏
# ┗┛┗┻┗┗┛┛┗┗ ┻ ┗┻┗┗┛
@field_validator("nasPort", mode = "before")
def validate_port_no(cls, value):
if isinstance(value, (str, float)): value = int(value)
return value
# ---------------------------------------------------------------------------------------------------------------------
class MikroTikHotspot1000Auth(BaseModel):
siteName: str = Field(
description = "Don't know, and don't want to know.",
min_length = 1,
frozen = True
)
nasIp: str = Field(
description = "Don't know, and don't want to know.",
min_length = 1,
frozen = True
)
nasPort: int | None = Field(
description = "Don't know, and don't want to know.",
frozen = True,
default = None
)
radius: str = Field(
description = "Don't know, and don't want to know.",
min_length = 1,
frozen = True
)
secret: str = Field(
description = "Don't know, and don't want to know.",
min_length = 1,
frozen = True
)
username: str = Field(
description = "Don't know, and don't want to know.",
min_length = 1,
frozen = True
)
password: str = Field(
description = "Don't know, and don't want to know.",
min_length = 1,
frozen = True
)
location: str = Field(
description = "Don't know, and don't want to know.",
min_length = 1,
frozen = True
)
snmpCommunity: str = Field(
description = "Don't know, and don't want to know.",
min_length = 1,
frozen = True
)
vlanRange: str = Field(
description = "Don't know, and don't want to know.",
min_length = 1,
frozen = True
)
privateIpPool: str = Field(
description = "Don't know, and don't want to know.",
min_length = 1,
frozen = True
)
publicIpPool: str = Field(
description = "Don't know, and don't want to know.",
min_length = 1,
frozen = True
)
domainName: str = Field(
description = "Don't know, and don't want to know.",
min_length = 1,
frozen = True
)
# ┏┓ ┏•
# ┃ ┏┓┏┓╋┓┏┓
# ┗┛┗┛┛┗┛┗┗┫
# ┛
class Config:
extra = "forbid"
pass
# ┓┏ ┓• ┓ •
# ┃┃┏┓┃┓┏┫┏┓╋┓┏┓┏┓
# ┗┛┗┻┗┗┗┻┗┻┗┗┗┛┛┗
@field_validator("nasPort", mode = "before")
def validate_port_no(cls, value):
if isinstance(value, (str, float)): value = int(value)
return value
pass
# ---------------------------------------------------------------------------------------------------------------------
class MikroTikAuthResponse(BaseModel):
class MikroTikRollBackAttemptResponse(BaseModel):
success: bool = Field(
description = "To indicate whether or not, the action was a success",