Fixes in tasks
This commit is contained in:
parent
283d5249dc
commit
7fe9966808
4 changed files with 4 additions and 146 deletions
|
|
@ -116,23 +116,6 @@ def pastafari2_dashboard():
|
|||
|
||||
@admin_app.route('/pastafari2/settings/')
|
||||
def pastafari2_settings():
|
||||
"""
|
||||
forms={}
|
||||
|
||||
forms['ssh_key_priv']=FileForm('ssh_key_priv', '', '')
|
||||
forms['ssh_key_pub']=FileForm('ssh_key_pub', '', '')
|
||||
|
||||
forms['ssh_key_priv'].help=_('Global private SSH key used for enter in servers')
|
||||
forms['ssh_key_pub'].help=_('Global public SSH key used for enter in servers')
|
||||
|
||||
forms['ssh_key_priv'].label=_('Global private SSH')
|
||||
forms['ssh_key_pub'].label=_('Global public SSH')
|
||||
|
||||
forms['ssh_key_priv'].required=True
|
||||
forms['ssh_key_pub'].required=True
|
||||
|
||||
html_forms=show_form({}, forms, t, yes_error=False, pass_values=True, modelform_tpl='forms/modelform.phtml')
|
||||
"""
|
||||
|
||||
txt_error=''
|
||||
txt_generate_key='<p>You have created your ssh keys</p>'
|
||||
|
|
@ -180,49 +163,6 @@ def pastafari2_edit_global_ssh_keys():
|
|||
|
||||
error=1
|
||||
|
||||
"""
|
||||
if not 'ssh_key_priv_file' in request.files:
|
||||
error=1
|
||||
form['ssh_key_priv']='ssh private key file required'
|
||||
|
||||
if not 'ssh_key_pub_file' in request.files:
|
||||
error=1
|
||||
form['ssh_key_pub']='ssh public key file required'
|
||||
|
||||
if not error:
|
||||
ssh_key_priv=request.files['ssh_key_priv_file']
|
||||
ssh_key_pub=request.files['ssh_key_pub_file']
|
||||
|
||||
if ssh_key_priv.filename=='':
|
||||
error=1
|
||||
form['ssh_key_priv']='ssh private key file required'
|
||||
|
||||
if ssh_key_pub.filename=='':
|
||||
error=1
|
||||
form['ssh_key_pub']='ssh private key file required'
|
||||
|
||||
if not os.path.isdir(system_path):
|
||||
|
||||
try:
|
||||
Path(system_path).mkdir(mode=511)
|
||||
|
||||
except:
|
||||
|
||||
error=1
|
||||
form['ssh_key_priv']='You need create ssh directory for save ssh keys'
|
||||
|
||||
if not error:
|
||||
|
||||
#Load keys
|
||||
|
||||
#Check keys
|
||||
|
||||
|
||||
|
||||
pass
|
||||
"""
|
||||
|
||||
#return {'form': form, 'error': error}
|
||||
return {'error': error}
|
||||
|
||||
@admin_app.route('/pastafari2/add_server/')
|
||||
|
|
@ -240,14 +180,6 @@ def pastafari2_add_server_task():
|
|||
|
||||
db=g.connection
|
||||
|
||||
#task=Task(db)
|
||||
|
||||
#task.safe_query()
|
||||
|
||||
#logtask=LogTask(db)
|
||||
|
||||
#server=ServerTask(db)
|
||||
#(self, server, conn, remote_user='root', remote_password='', private_key='./ssh/id_rsa', password_key='', remote_path='leviathan', task_id=0, data={}):
|
||||
error_form={}
|
||||
|
||||
server_host=request.form.get('server_host', '')
|
||||
|
|
@ -289,7 +221,7 @@ def pastafari2_add_server_task():
|
|||
txt_error=''
|
||||
|
||||
try:
|
||||
#print("IP address of %s: %s" %(remote_host, socket.gethostbyname(remote_host)))
|
||||
|
||||
ip=socket.gethostbyname(server_host)
|
||||
pass
|
||||
except socket.error as err_msg:
|
||||
|
|
@ -305,7 +237,7 @@ def pastafari2_add_server_task():
|
|||
arr_group=server_group.set_conditions('WHERE id=%s', [group_id]).select_a_row_where()
|
||||
group_name=arr_group['code_group']
|
||||
|
||||
# 'url_stats': config.domain_url+url_for('monit_app.monit_get_data', api_key=config.monit_api_key)
|
||||
|
||||
|
||||
data={'ssh_user': ssh_user, 'pub_key': public_key, 'hostname': server_host, 'ip': ip, 'group_id': group_id, 'group_name': group_name}
|
||||
|
||||
|
|
@ -340,27 +272,6 @@ def pastafari2_add_server_task():
|
|||
def pastafari2_progress():
|
||||
|
||||
db=g.connection
|
||||
"""
|
||||
task_id=request.args.get('task_id', '0')
|
||||
|
||||
position=request.args.get('position', '0')
|
||||
|
||||
task=Task(db)
|
||||
|
||||
arr_task=task.set_conditions('WHERE id=%s', [task_id]).select_a_row_where()
|
||||
|
||||
url_return=arr_task['url_return']
|
||||
|
||||
#print(url_return)
|
||||
|
||||
#print(arr_task)
|
||||
if arr_task:
|
||||
return t.load_template('progress.phtml', title=_('Task progress'), path_module='admin_app.pastafari2_dashboard', name_task=arr_task['name_task'], description_task=arr_task['description_task'], position=position, task_id=task_id, server=arr_task['server'], hostname=arr_task['hostname'], url_return=url_return)
|
||||
else:
|
||||
|
||||
return ""
|
||||
|
||||
"""
|
||||
|
||||
return load_progress(db, t)
|
||||
|
||||
|
|
@ -439,8 +350,6 @@ def pastafari2_getprogress():
|
|||
|
||||
db.close()
|
||||
|
||||
#header=response.headers
|
||||
|
||||
resp=make_response(json.dumps(arr_rows))
|
||||
|
||||
resp.headers['Content-Type']='application/json'
|
||||
|
|
@ -468,41 +377,21 @@ def get_servers_task():
|
|||
sql_data=[group_id]
|
||||
group_sql=' WHERE `group_id`=%s'
|
||||
|
||||
|
||||
|
||||
fields=[[_('Hostname'), True], ['IP', True], [_('Selected'), False], [_('Options'), False]]
|
||||
arr_order_fields=['hostname', 'ip']
|
||||
|
||||
count_query=['select count(serverdbtask.id) as num_elements from serverdbtask'+group_sql_count, count_data]
|
||||
|
||||
# server.id as select_id,
|
||||
|
||||
# select hostname, ip, date, num_updates, id from serverofuser where user_id=%s;
|
||||
|
||||
str_query=['select serverdbtask.hostname, serverdbtask.ip, serverdbtask.id as select_id, serverdbtask.id from serverdbtask'+group_sql, sql_data]
|
||||
|
||||
ajax=AjaxList(db, fields, arr_order_fields, count_query, str_query)
|
||||
|
||||
#ajax.func_fields['id']=options_server
|
||||
#ajax.func_fields['ip']=options_ip
|
||||
ajax.func_fields['select_id']=options_selected
|
||||
ajax.func_fields['id']=options_options
|
||||
ajax.limit=0
|
||||
|
||||
#{'fields': [['Hostname', True], ['IP', True], ['Status', True], ['Options', False]], 'rows': [{'hostname': 'debian-pc.localdomain', 'ip': '<span id="ip_192.168.122.125">192.168.122.125</span>', 'date': '<img src="/mediafrom/pastafari2/images/status_green.png" />', 'id': '<a href="#">View stats</a>'}, {'hostname': 'DESKTOP-HLHPSSO', 'ip': '<span id="ip_192.168.122.81">192.168.122.81</span>', 'date': '<img src="/mediafrom/pastafari2/images/status_green.png" />', 'id': '<a href="#">View stats</a>'}], 'html_pages': ''}
|
||||
|
||||
return ajax.show()
|
||||
|
||||
"""
|
||||
def options_server(row_id, row):
|
||||
|
||||
#'<a href="{}">{}</a>'.format(url_for('.services', server_id=row_id), _('Services'))
|
||||
|
||||
arr_options=['<a href="{}">{}</a>'.format("", _('Edit'))]
|
||||
arr_options.append('<a href="{}">{}</a>'.format("", _('Make task')))
|
||||
arr_options.append('<a href="{}">{}</a>'.format("", _('Delete')))
|
||||
"""
|
||||
|
||||
def options_selected(row_id, row):
|
||||
|
||||
return '<input type="checkbox" name="server_id_{}" class="server_id" value="{}"/>'.format(row_id, row_id)
|
||||
|
|
@ -510,7 +399,7 @@ def options_selected(row_id, row):
|
|||
def options_options(row_id, row):
|
||||
|
||||
arr_options=['<a href="{}">{}</a>'.format(url_for('admin_app.pastafari2_edit_server', id=row_id, op_admin=1), _('Edit'))]
|
||||
#arr_options.append('<a href="{}">{}</a>'.format("", _('Make task')))
|
||||
|
||||
arr_options.append('<a href="{}">{}</a>'.format(url_for('admin_app.pastafari2_delete_server', server_id=row_id), _('Delete')))
|
||||
|
||||
arr_options.append('<a href="{}">{}</a>'.format(url_for('admin_app.pastafari2_edit_update', server_id=row_id), _('Edit update task')))
|
||||
|
|
@ -550,8 +439,6 @@ def pastafari2_update_task():
|
|||
|
||||
where_sql='WHERE id IN ('+",".join(arr_ids)+') order by hostname ASC'
|
||||
|
||||
#print(where_sql)
|
||||
|
||||
task=Task(db)
|
||||
|
||||
task_id=0
|
||||
|
|
@ -655,14 +542,11 @@ def pastafari2_make_task():
|
|||
|
||||
pass
|
||||
|
||||
#print(ids)
|
||||
for v in ids:
|
||||
arr_ids.append(str(int(v)))
|
||||
|
||||
where_sql='WHERE id IN ('+",".join(arr_ids)+') order by hostname ASC'
|
||||
|
||||
#print(where_sql)
|
||||
|
||||
path_task=task_file
|
||||
|
||||
#Load task, check if have question
|
||||
|
|
@ -740,8 +624,6 @@ def pastafari2_get_multiprogress():
|
|||
|
||||
ids=request.args.get('ids', '[]')
|
||||
|
||||
#position=0
|
||||
|
||||
try:
|
||||
position=int(request.args.get('position', '0'))
|
||||
except:
|
||||
|
|
@ -807,8 +689,6 @@ def pastafari2_edit_server():
|
|||
|
||||
server=ServerDbTask(db)
|
||||
|
||||
#server_id=request.form.get('server_id', '0')
|
||||
|
||||
url=url_for('.pastafari2_edit_server')
|
||||
|
||||
admin=GenerateAdminClass(server, url, t)
|
||||
|
|
@ -849,8 +729,6 @@ def pre_update_server(admin):
|
|||
admin.model.fields['ssh_port'].error=True
|
||||
|
||||
return False
|
||||
#txt_error=ssh_task.txt_error #_('Error: cannot connect to server')
|
||||
#error_form['#server_host_error']=txt_error #_('Error: cannot connect to server')
|
||||
|
||||
|
||||
return True
|
||||
|
|
@ -893,15 +771,6 @@ def pastafari2_edit_update():
|
|||
|
||||
admin.list.order_field='position'
|
||||
|
||||
"""
|
||||
self.arr_extra_fields=[_('Options')]
|
||||
|
||||
self.arr_extra_options=[SimpleList.standard_options]
|
||||
"""
|
||||
|
||||
#admin.list.arr_extra_fields.insert(0, _('Position'))
|
||||
#admin.list.arr_extra_options.insert(0, field_position)
|
||||
|
||||
form_admin=admin.show()
|
||||
|
||||
if type(form_admin).__name__=='str':
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ def pastafari2_tasks():
|
|||
|
||||
admin.list.raw_query=False
|
||||
|
||||
#request.args['order']=request.args.get('order', '1')
|
||||
admin.list.order='1'
|
||||
|
||||
admin.list.fields_showed=['id', 'name_task', 'description_task', 'path', 'is_parent', 'server', 'hostname', 'parent_id']
|
||||
|
|
|
|||
|
|
@ -61,16 +61,6 @@ def pastafari2_tasks_edit():
|
|||
return ""
|
||||
|
||||
def scripts_options(url, row_id, row):
|
||||
"""
|
||||
if row['is_parent']:
|
||||
|
||||
return ['<a target="_blank" href="'+url_for('admin_app.pastafari2_multiprogress', task_id=row_id)+'">'+_('View task log')+'</a>']
|
||||
|
||||
else:
|
||||
|
||||
return ['<a target="_blank" href="'+url_for('admin_app.pastafari2_progress', task_id=row_id)+'">'+_('View task log')+'</a>']
|
||||
"""
|
||||
#return ['<a href="">'+_('Edit scripts')+'</a>']
|
||||
|
||||
arr_options=SimpleList.standard_options(url, row_id, row)
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ name=Database servers
|
|||
description=Install databases daemon in server standalone, for example mysql or postgres
|
||||
|
||||
[modules]
|
||||
mysql/standalone_mysql=Standalone mysql server, MySQL is the most famous database sql server in the web
|
||||
mysql/standalone_mysql=Standalone MariaDB server, MariaDB is a database sql server, forked from MySQL with improvenments.
|
||||
|
||||
[form]
|
||||
mysql/standalone_mysql=1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue