(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
+54 -24
View File
@@ -162,6 +162,7 @@ async def authorize_software_client(
# Start by assuming failure:
success = False
message = None
# ┏┳┓┓ ┏┓┏┓ ┏┓┏┏• ┏┓┳
# ┃ ┣┓┏┓ ┃ ┣┫ ┃┃╋╋┓┏┏┓ ┣┫┃
@@ -169,33 +170,61 @@ async def authorize_software_client(
if inbound_data.softwareClient == "theCaOfficeAi":
auth_token = CoreAuthTokenModel(
serviceType = "software",
client = inbound_data.softwareClient,
authType = "auth",
auth = inbound_data.auth.model_dump(),
user = kwargs.get("session_info"),
clientUserId = {},
status = "active",
syncFreq = 60
pass
# auth_token = CoreAuthTokenModel(
# serviceType = "software",
# client = inbound_data.softwareClient,
# authType = "auth",
# auth = inbound_data.auth.model_dump(),
# user = kwargs.get("session_info"),
# clientUserId = {},
# status = "active",
# syncFreq = 60
# )
#
# token_id = await current_app.core_auth_token_controller.get_token_id(
# db_conn = current_app.sql_writer,
# mongo_conn = current_app.data_mongo,
# auth_token = auth_token,
# token_notes = {},
# session_token = inbound_headers["X-Session-Token"]
# )
#
# success = await current_app.core_auth_token_controller.set_token(
# db_conn = current_app.sql_writer,
# mongo_conn = current_app.data_mongo,
# token_id = token_id,
# auth_token = auth_token,
# token_notes = {},
# session_token = inbound_headers["X-Session-Token"]
# )
# ┏┓ ┳┳┓•┓ ┏┳┓•┓ ┏┓┏┓┏┓ ┏┓ ┓┏┓┏┓┏┓
# ┣ ┏┓┏┓ ┃┃┃┓┃┏┏┓┏┓ ┃ ┓┃┏ ┃┃┃┃┃┃┏┓┣ ┃┃┫┃┫┃┫
# ┻ ┗┛┛ ┛ ┗┗┛┗┛ ┗┛ ┻ ┗┛┗ ┣┛┣┛┣┛┗┛┗┛ ┻┗┛┗┛┗┛
elif inbound_data.softwareClient == "mikrotikPPPoE1000":
# Make the client controller test and save the auth:
response = await current_app.mikrotik_pppoe_1000_controller.save_auth(
sql_conn = current_app.sql_writer,
mongo_data_conn = current_app.data_mongo,
mikrotik_auth = inbound_data.auth
)
token_id = await current_app.core_auth_token_controller.get_token_id(
db_conn = current_app.sql_writer,
mongo_conn = current_app.data_mongo,
auth_token = auth_token,
token_notes = {},
session_token = inbound_headers["X-Session-Token"]
)
# Note down the results:
success = response.success
message = response.message
success = await current_app.core_auth_token_controller.set_token(
db_conn = current_app.sql_writer,
mongo_conn = current_app.data_mongo,
token_id = token_id,
auth_token = auth_token,
token_notes = {},
session_token = inbound_headers["X-Session-Token"]
)
# ┏┓ ┳┳┓•┓ ┏┳┓•┓ ┓┏ ┓┏┓┏┓┏┓
# ┣ ┏┓┏┓ ┃┃┃┓┃┏┏┓┏┓ ┃ ┓┃┏ ┣┫┏┓╋┏┏┓┏┓╋ ┃┃┫┃┫┃┫
# ┻ ┗┛┛ ┛ ┗┗┛┗┛ ┗┛ ┻ ┗┛┗ ┛┗┗┛┗┛┣┛┗┛┗ ┻┗┛┗┛┗┛
# ┛
elif inbound_data.softwareClient == "mikrotikHotspot1000":
pass
# ┳┓
# ┣┫┏┓┏┏┓┏┓┏┓┏┏┓
@@ -206,6 +235,7 @@ async def authorize_software_client(
return ResponseModel(
status_code = StatusCodes.OK if success else StatusCodes.FAILED,
http_code = HttpCodes.SUCCESS if success else HttpCodes.INTERNAL_SERVER_ERROR,
message = message,
data = {
"client": inbound_data.softwareClient,
"authorized": success