Added support for call make_task for other scripts
This commit is contained in:
parent
e1710bf434
commit
c56366923f
6 changed files with 108 additions and 11 deletions
|
|
@ -3,8 +3,16 @@
|
|||
from modules.pastafari2.libraries.task import Task
|
||||
#from modules.pastafari.models.tasks import TaskModel
|
||||
from paramecio2.libraries.db import coreforms
|
||||
from paramecio2.libraries.db.extrafields.ipfield import IpField
|
||||
from paramecio2.libraries.formsutils import show_form
|
||||
from collections import OrderedDict
|
||||
from modules.pastafari2.models.pastafari2 import ServerDbTask
|
||||
try:
|
||||
from modules.mariadb.models.mariadb import DbServerMariaDb
|
||||
server_db=True
|
||||
except:
|
||||
server_db=False
|
||||
|
||||
|
||||
class ServerTask(Task):
|
||||
|
||||
|
|
@ -51,12 +59,43 @@ class ServerTask(Task):
|
|||
|
||||
self.arr_form['repeat_mysql_password'].label='Repeat MySQL password'
|
||||
|
||||
#self.commands_to_execute=[['modules/pastafari/scripts/servers/databases/mariadb/install_mariadb.py', '--password=%s' % self.data['mysql_password']]]
|
||||
self.arr_form['access_localhost']=coreforms.SimpleTextForm('access_localhost', '')
|
||||
|
||||
self.arr_form['access_localhost'].required=True
|
||||
|
||||
#self.arr_form['access_localhost'].default_value='1'
|
||||
|
||||
self.arr_form['access_localhost'].label='IP for access to mariadb server'
|
||||
self.arr_form['access_localhost'].help='Empty if you want only localhost access. If you want all ips, use 0.0.0.0 or if you want other ip, put it'
|
||||
|
||||
|
||||
#self.commands_to_execute=[['modules/pastafari/scripts/servers/databases/mariadb/install_mariadb.py', '--password=%s' % self.data['mysql_password']]]
|
||||
|
||||
def post_task(self):
|
||||
|
||||
if server_db:
|
||||
dbserver=DbServerMariaDb(self.connection)
|
||||
|
||||
dbserver.safe_query()
|
||||
|
||||
serverdb=ServerDbTask(self.connection)
|
||||
|
||||
arr_server=serverdb.set_conditions('WHERE ip=%s', [self.server]).select_a_row_where()
|
||||
|
||||
if arr_server:
|
||||
dbserver.insert({'server_id': arr_server['id']})
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def pre_task(self):
|
||||
|
||||
self.commands_to_execute=[['modules/pastafari2/scripts/servers/databases/mariadb/install_mariadb.py', '--password=%s' % self.data['mysql_password']]]
|
||||
ip_option=''
|
||||
|
||||
if 'ip' in self.data:
|
||||
ip_option='--ip='+self.data['ip']
|
||||
|
||||
self.commands_to_execute=[['modules/pastafari2/scripts/servers/databases/mariadb/install_mariadb.py', '--password=%s %s' % (self.data['mysql_password'], ip_option)]]
|
||||
|
||||
return True
|
||||
|
||||
|
|
@ -68,19 +107,42 @@ class ServerTask(Task):
|
|||
|
||||
def check_form(self, post):
|
||||
|
||||
error=False
|
||||
|
||||
if 'mysql_password' in post and 'repeat_mysql_password' in post:
|
||||
|
||||
if post['mysql_password'].strip()!='' and post['mysql_password']==post['repeat_mysql_password']:
|
||||
|
||||
self.data['mysql_password']=post['mysql_password'].strip()
|
||||
return True
|
||||
|
||||
else:
|
||||
|
||||
self.arr_form['mysql_password'].error=True
|
||||
self.arr_form['mysql_password'].txt_error='Passwords doesn\'t match'
|
||||
|
||||
return False
|
||||
error=True
|
||||
|
||||
if 'access_localhost' in post:
|
||||
ip_check=IpField('ip')
|
||||
|
||||
ip_host=post['access_localhost'].strip()
|
||||
|
||||
if ip_host!='':
|
||||
|
||||
ip_host=ip_check.check(ip_host)
|
||||
|
||||
if ip_host!='':
|
||||
self.data['ip']=ip_host
|
||||
|
||||
if ip_check.error:
|
||||
|
||||
self.arr_form['access_localhost'].error=True
|
||||
self.arr_form['access_localhost'].txt_error='Wrong ip format'
|
||||
error=True
|
||||
|
||||
|
||||
if error:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue