Aidaho 2024-08-02 18:48:11 +03:00
parent 178116b9c1
commit 81d28536f6
9 changed files with 53 additions and 91 deletions

View File

@ -4,7 +4,11 @@ import sys
import distro import distro
sys.path.append(os.path.join(sys.path[0], '/var/www/haproxy-wi/')) sys.path.append(os.path.join(sys.path[0], '/var/www/haproxy-wi/'))
from app.modules.db.db_model import * from app.modules.db.db_model import (
connect, Setting, Role, User, UserGroups, Groups, Services, RoxyTool, Version, SmonHttpCheck, GeoipCodes, SmonTcpCheck, SMON,
SmonPingCheck, migrate, mysql_enable, create_tables
)
from peewee import DateTimeField, IntegerField, CharField, SQL
conn = connect() conn = connect()
@ -696,7 +700,7 @@ def update_db_v_7_4():
def update_ver(): def update_ver():
try: try:
Version.update(version='7.3.3.0').execute() Version.update(version='8.0').execute()
except Exception: except Exception:
print('Cannot update version') print('Cannot update version')

View File

@ -199,7 +199,7 @@ class Cred(BaseModel):
class Meta: class Meta:
table_name = 'cred' table_name = 'cred'
constraints = [SQL('UNIQUE (name, `groups`)')] constraints = [SQL('UNIQUE (name, `group_id`)')]
class Backup(BaseModel): class Backup(BaseModel):

View File

@ -32,9 +32,7 @@ class HAView(MethodView):
name: 'service' name: 'service'
description: 'Can be only "cluster"' description: 'Can be only "cluster"'
required: true required: true
schema: type: 'string'
type: 'string'
enum: ['cluster']
- in: 'path' - in: 'path'
name: 'cluster_id' name: 'cluster_id'
description: 'ID of the HA cluster to retrieve information from.' description: 'ID of the HA cluster to retrieve information from.'
@ -124,9 +122,7 @@ class HAView(MethodView):
name: 'service' name: 'service'
description: 'Can be only "cluster"' description: 'Can be only "cluster"'
required: true required: true
schema: type: 'string'
type: 'string'
enum: ['cluster']
- in: body - in: body
name: body name: body
required: true required: true
@ -523,7 +519,7 @@ class HAVIPView(MethodView):
required: true required: true
type: 'string' type: 'string'
- in: 'path' - in: 'path'
name: 'cluster_id' name: 'router_id'
description: 'ID of the VIP to delete' description: 'ID of the VIP to delete'
required: true required: true
type: 'integer' type: 'integer'

View File

@ -27,9 +27,7 @@ class InstallView(MethodView):
parameters: parameters:
- in: path - in: path
name: service name: service
schema: type: 'integer'
type: string
enum: [haproxy, nginx, apache, keepalived]
required: true required: true
description: The type of service (haproxy, nginx, apache, keepalived) description: The type of service (haproxy, nginx, apache, keepalived)
- in: path - in: path

View File

@ -270,8 +270,7 @@ class ServerView(MethodView):
name: 'server_id' name: 'server_id'
description: 'ID of server to delete' description: 'ID of server to delete'
required: true required: true
schema: type: 'integer'
type: 'integer'
responses: responses:
204: 204:
description: Server deletion successful description: Server deletion successful
@ -614,14 +613,6 @@ class CredView(MethodView):
description: 'Username associated with the credential' description: 'Username associated with the credential'
404: 404:
description: 'Credential not found' description: 'Credential not found'
content:
application/json:
schema:
type: 'object'
properties:
error:
type: 'string'
description: 'Error message'
""" """
group_id = int(g.user_params['group_id']) group_id = int(g.user_params['group_id'])
try: try:
@ -835,28 +826,26 @@ class CredsView(MethodView):
responses: responses:
200: 200:
description: 'Credentials Information' description: 'Credentials Information'
content: schema:
application/json: type: 'array'
schema: items:
type: 'array' type: 'object'
items: properties:
type: 'object' group_id:
properties: type: 'integer'
group_id: description: 'Group ID the credential belongs to'
type: 'integer' id:
description: 'Group ID the credential belongs to' type: 'integer'
id: description: 'Credential ID'
type: 'integer' key_enabled:
description: 'Credential ID' type: 'integer'
key_enabled: description: 'Key status of the credential'
type: 'integer' name:
description: 'Key status of the credential' type: 'string'
name: description: 'Name of the credential'
type: 'string' username:
description: 'Name of the credential' type: 'string'
username: description: 'Username of the credential'
type: 'string'
description: 'Username of the credential'
""" """
group_id = SupportClass.return_group_id(query) group_id = SupportClass.return_group_id(query)
try: try:

View File

@ -33,9 +33,7 @@ class ServiceView(MethodView):
parameters: parameters:
- in: path - in: path
name: service name: service
schema: type: 'string'
type: string
enum: [haproxy, nginx, apache, keepalived]
required: true required: true
description: The type of service (haproxy, nginx, apache, keepalived) description: The type of service (haproxy, nginx, apache, keepalived)
- in: path - in: path
@ -160,9 +158,7 @@ class ServiceActionView(MethodView):
parameters: parameters:
- in: path - in: path
name: service name: service
schema: type: 'integer'
type: string
enum: [haproxy, nginx, apache, keepalived, waf_haproxy, waf_nginx]
required: true required: true
description: The type of service (haproxy, nginx, apache, keepalived, waf_haproxy, waf_nginx) description: The type of service (haproxy, nginx, apache, keepalived, waf_haproxy, waf_nginx)
- in: path - in: path
@ -172,9 +168,7 @@ class ServiceActionView(MethodView):
description: The ID or IP of the server description: The ID or IP of the server
- in: path - in: path
name: action name: action
schema: type: 'string'
type: string
enum: [start, stop, reload, restart]
required: true required: true
description: The action to be performed on the service (start, stop, reload, restart) description: The action to be performed on the service (start, stop, reload, restart)
responses: responses:
@ -217,9 +211,7 @@ class ServiceBackendView(MethodView):
parameters: parameters:
- in: path - in: path
name: service name: service
schema: type: 'integer'
type: string
enum: [haproxy, nginx, apache, keepalived]
required: true required: true
description: The type of service (haproxy, nginx, apache, keepalived) description: The type of service (haproxy, nginx, apache, keepalived)
- in: path - in: path
@ -265,9 +257,7 @@ class ServiceConfigView(MethodView):
parameters: parameters:
- in: path - in: path
name: service name: service
schema: type: 'integer'
type: string
enum: [haproxy, nginx, apache, keepalived]
required: true required: true
description: The type of service (haproxy, nginx, apache, keepalived) description: The type of service (haproxy, nginx, apache, keepalived)
- in: path - in: path
@ -277,14 +267,12 @@ class ServiceConfigView(MethodView):
description: The ID or IP of the server description: The ID or IP of the server
- in: query - in: query
name: file_name name: file_name
schema: type: 'string'
type: string
required: false required: false
description: The full path to the configuration file (used only for nginx and apache, replace "/" with 92) description: The full path to the configuration file (used only for nginx and apache, replace "/" with 92)
- in: query - in: query
name: version name: version
schema: type: 'string'
type: string
required: false required: false
description: The version of the configuration file description: The version of the configuration file
responses: responses:
@ -423,15 +411,12 @@ class ServiceConfigVersionsView(MethodView):
parameters: parameters:
- in: path - in: path
name: service name: service
schema: type: 'integer'
type: string
enum: [haproxy, nginx, apache, keepalived]
required: true required: true
description: The type of service (haproxy, nginx, apache, keepalived) description: The type of service (haproxy, nginx, apache, keepalived)
- in: path - in: path
name: server_id name: server_id
schema: type: 'integer'
type: string
required: true required: true
description: The ID or IP of the server description: The ID or IP of the server
responses: responses:

View File

@ -29,15 +29,12 @@ class CheckerView(MethodView):
parameters: parameters:
- in: path - in: path
name: service name: service
schema: type: 'integer'
type: string
enum: [haproxy, nginx, apache, keepalived]
required: true required: true
description: The type of service (haproxy, nginx, apache, keepalived) description: The type of service (haproxy, nginx, apache, keepalived)
- in: path - in: path
name: server_id name: server_id
schema: type: 'integer'
type: string
required: true required: true
description: The ID or IP of the server description: The ID or IP of the server
responses: responses:

View File

@ -41,7 +41,6 @@ class UDPListener(MethodView):
type: integer type: integer
required: true required: true
description: The listener's identifier description: The listener's identifier
responses: responses:
200: 200:
description: Listener configuration returned successfully description: Listener configuration returned successfully
@ -137,8 +136,7 @@ class UDPListener(MethodView):
name: 'service' name: 'service'
description: 'Can be only "udp"' description: 'Can be only "udp"'
required: true required: true
schema: type: 'string'
type: 'string'
- in: body - in: body
name: body name: body
required: true required: true
@ -221,14 +219,12 @@ class UDPListener(MethodView):
name: 'service' name: 'service'
description: 'Can be only "udp"' description: 'Can be only "udp"'
required: true required: true
schema: type: 'string'
type: 'string'
- in: 'path' - in: 'path'
name: 'listener_id' name: 'listener_id'
description: 'ID of the UDP listener' description: 'ID of the UDP listener'
required: true required: true
schema: type: 'integer'
type: 'integer'
- in: body - in: body
name: body name: body
required: true required: true
@ -310,14 +306,12 @@ class UDPListener(MethodView):
name: 'service' name: 'service'
description: 'Can be only "udp"' description: 'Can be only "udp"'
required: true required: true
schema: type: 'string'
type: 'string'
- in: 'path' - in: 'path'
name: 'listener_id' name: 'listener_id'
description: 'ID of the UDP listener' description: 'ID of the UDP listener'
required: true required: true
schema: type: 'integer'
type: 'integer'
responses: responses:
204: 204:
description: UDP listener deletion successful description: UDP listener deletion successful
@ -447,18 +441,16 @@ class UDPListenerActionView(MethodView):
- in: path - in: path
name: service name: service
required: true required: true
type: 'string'
description: Can be only "udp" description: Can be only "udp"
- in: path - in: path
name: listener_id name: listener_id
schema: type: 'integer'
type: integer
required: true required: true
description: The ID af the UDP listener description: The ID af the UDP listener
- in: path - in: path
name: action name: action
schema: type: 'string'
type: string
enum: [start, stop, reload, restart]
required: true required: true
description: The action to be performed on the service (start, stop, reload, restart) description: The action to be performed on the service (start, stop, reload, restart)
responses: responses:

View File

@ -283,7 +283,8 @@ class UserGroupView(MethodView):
methods = ["GET", "POST", "PUT", "DELETE", "PATCH"] methods = ["GET", "POST", "PUT", "DELETE", "PATCH"]
decorators = [jwt_required(), get_user_params(), page_for_admin(level=4), check_group()] decorators = [jwt_required(), get_user_params(), page_for_admin(level=4), check_group()]
def get(self, user_id: int): @staticmethod
def get(user_id: int):
""" """
Fetch a specific User Group. Fetch a specific User Group.
--- ---