From 8a0354b85b64939681446d4476a30d18fc97f530 Mon Sep 17 00:00:00 2001 From: Antonio de la Rosa Date: Fri, 9 Feb 2024 02:04:08 +0100 Subject: [PATCH] Fixes in dashboard, added distro field for serverdbtask table --- admin/dashboard.py | 4 +++- libraries/task.py | 1 + models/pastafari2.py | 1 + tasks/system/task.py | 14 +++++++++++++- templates/admin/dash_pastafari.phtml | 11 ++++++++++- 5 files changed, 28 insertions(+), 3 deletions(-) diff --git a/admin/dashboard.py b/admin/dashboard.py index 63fbc48..b3ef133 100644 --- a/admin/dashboard.py +++ b/admin/dashboard.py @@ -62,8 +62,10 @@ def pastafari2_dashboard(): for module in pastafari_paths: select_task=scandir(module, config_parser, select_task, 'tasks') + + task_path=request.args.get('task_path', '') - return t.load_template('dash_pastafari.phtml', title=I18n.lang('pastafari2', 'servers_dashboard', 'Servers Dashboard'), path_module='admin_app.pastafari2_dashboard', select_task=select_task) + return t.load_template('dash_pastafari.phtml', title=I18n.lang('pastafari2', 'servers_dashboard', 'Servers Dashboard'), path_module='admin_app.pastafari2_dashboard', select_task=select_task, task_path=task_path) @admin_app.route('/pastafari2/settings/') def pastafari2_settings(): diff --git a/libraries/task.py b/libraries/task.py index 56c0192..8e7413f 100644 --- a/libraries/task.py +++ b/libraries/task.py @@ -494,6 +494,7 @@ class Task: #{'result': 1, 'message': {'username': 'hosting', 'uid': 1002, 'gid': 1002, 'home': '/srv/sites'}, 'error': 0, 'progress': 100, 'task_id': 483, 'server': '192.168.122.55'} #json_code['message']=json.dumps(json_code['message']) #print(json_code) + json_code['message']=json.loads(json_code['message']) self.resulttask.insert(json_code) #print(self.resulttask.show_errors()) else: diff --git a/models/pastafari2.py b/models/pastafari2.py index dc13b40..68f3158 100644 --- a/models/pastafari2.py +++ b/models/pastafari2.py @@ -45,6 +45,7 @@ class ServerDbTask(Server): self.fields['group'].required=False self.register(corefields.ForeignKeyField('group_id', ServerGroup(connection), 11, False, 'id', 'group', select_fields=[])) self.register(corefields.IntegerField('ssh_port'), True) + self.register(corefields.CharField('distro')) class UpdateServerScripts(WebModel): diff --git a/tasks/system/task.py b/tasks/system/task.py index ed72c56..8a1bb20 100644 --- a/tasks/system/task.py +++ b/tasks/system/task.py @@ -1,5 +1,7 @@ from modules.pastafari2.libraries.task import Task from modules.pastafari2.models.pastafari2 import ServerDbTask +from modules.pastafari2.models.tasks import ResultTask +import json class ServerTask(Task): @@ -35,12 +37,22 @@ class ServerTask(Task): def post_task(self): + distro='' + + resulttask=ResultTask(self.connection) + + arr_result=resulttask.set_conditions('WHERE task_id=%s', [self.id]).select_a_row_where() + + if arr_result: + #r=json.loads(arr_result['message']) + distro=json.loads(arr_result['message'])['distro'] + server=ServerDbTask(self.connection) server.safe_query() #'subdomain_id': self.data['subdomain_id'] - server.insert({'hostname': self.data['hostname'], 'ip': self.data['ip'], 'group_id': self.data['group_id'], 'ssh_port': self.port}) + server.insert({'hostname': self.data['hostname'], 'ip': self.data['ip'], 'group_id': self.data['group_id'], 'ssh_port': self.port, 'distro': distro}) return True diff --git a/templates/admin/dash_pastafari.phtml b/templates/admin/dash_pastafari.phtml index a36800a..d99d1ec 100644 --- a/templates/admin/dash_pastafari.phtml +++ b/templates/admin/dash_pastafari.phtml @@ -22,7 +22,16 @@ form_set=[] % if len(value)>=2: % for script in enumerate(value, 1): %if script[1][2]==1: -