Fixes in tasks
This commit is contained in:
parent
ec52e45969
commit
6cd4598708
4 changed files with 50 additions and 54 deletions
|
|
@ -27,6 +27,7 @@ from importlib import import_module, reload
|
|||
from modules.pastafari2.libraries.progress import load_progress
|
||||
from modules.pastafari2.libraries.load_task import load_db_in_task
|
||||
from importlib import import_module
|
||||
from subprocess import call
|
||||
|
||||
try:
|
||||
import ujson as json
|
||||
|
|
@ -147,21 +148,38 @@ def pastafari2_edit_global_ssh_keys():
|
|||
|
||||
form={}
|
||||
|
||||
error=0
|
||||
error=1
|
||||
|
||||
if not os.path.isfile(system_path+'id_rsa'):
|
||||
# -C "your_email@example.com" -f $HOME/.ssh/id_rsa
|
||||
|
||||
try:
|
||||
arr_type={'dsa': 'ssh-keygen -t dsa', 'ecdsa': 'ssh-keygen -t ecdsa -b 521', 'ed25519': 'ssh-keygen -t ed25519'}
|
||||
|
||||
ssh_key_type=request.args.get('ssh_key_type')
|
||||
|
||||
if ssh_key_type in arr_type:
|
||||
|
||||
key=paramiko.RSAKey.generate(2048)
|
||||
key.write_private_key_file(system_path+'id_rsa')
|
||||
|
||||
with open(system_path+'id_rsa.pub',"w") as pub_key:
|
||||
pub_key.write("%s %s" % (key.get_name(), key.get_base64()))
|
||||
|
||||
except:
|
||||
file_ssh_path='-f {}/id_rsa -q -N ""'.format(system_path)
|
||||
|
||||
if not os.path.isfile(system_path+'id_rsa'):
|
||||
|
||||
error=1
|
||||
if call(arr_type[ssh_key_type]+' '+file_ssh_path, shell=True) > 0:
|
||||
|
||||
error=1
|
||||
else:
|
||||
error=0
|
||||
|
||||
#try:
|
||||
|
||||
#key=paramiko.RSAKey.generate(2048)
|
||||
#key=paramiko.Ed25519Key.generate()
|
||||
#key.write_private_key_file(system_path+'id_rsa')
|
||||
|
||||
#with open(system_path+'id_rsa.pub',"w") as pub_key:
|
||||
# pub_key.write("%s %s" % (key.get_name(), key.get_base64()))
|
||||
|
||||
#except:
|
||||
|
||||
# error=1
|
||||
|
||||
return {'error': error}
|
||||
|
||||
|
|
@ -398,7 +416,7 @@ 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(url_for('admin_app.pastafari2_edit_users', id=row_id, op_admin=1), _('Users')))
|
||||
#arr_options.append('<a href="{}">{}</a>'.format(url_for('admin_app.pastafari2_edit_users', id=row_id, op_admin=1), _('Users')))
|
||||
|
||||
arr_options.append('<a href="{}">{}</a>'.format(url_for('admin_app.pastafari2_delete_server', server_id=row_id), _('Delete')))
|
||||
|
||||
|
|
@ -839,7 +857,7 @@ def pastafari2_save_positions():
|
|||
pass
|
||||
|
||||
return {'error': error, 'form': error_form, 'txt_error': txt_error}
|
||||
|
||||
"""
|
||||
@admin_app.route('/pastafari2/edit_users')
|
||||
def pastafari2_edit_users():
|
||||
|
||||
|
|
@ -852,41 +870,6 @@ def pastafari2_get_server_users():
|
|||
|
||||
# {"fields": [{"Username": true, "Options": false}], "rows": [{"username": "developer", "options": ""}], "html_pages": ""}
|
||||
|
||||
|
||||
"""
|
||||
db=g.connection
|
||||
|
||||
group_sql=''
|
||||
|
||||
count_data=[]
|
||||
sql_data=[]
|
||||
|
||||
group_id=request.form.get('group_id', '')
|
||||
|
||||
group_sql_count=''
|
||||
group_sql=''
|
||||
|
||||
if group_id!='':
|
||||
group_sql_count=' WHERE `group_id`=%s'
|
||||
count_data=[group_id]
|
||||
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]
|
||||
|
||||
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['select_id']=options_selected
|
||||
ajax.func_fields['id']=options_options
|
||||
ajax.limit=0
|
||||
|
||||
return ajax.show()
|
||||
"""
|
||||
fields=[['Username', True], ['Options', False]]
|
||||
|
||||
rows=[{'username': 'developer', 'options': ''}]
|
||||
|
|
@ -897,3 +880,4 @@ def pastafari2_get_server_users():
|
|||
|
||||
return json.dumps(arr_return)
|
||||
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue