Changelog: https://roxy-wi.org/changelog#6_3_11
pull/364/head v6.3.11.0
Aidaho 2 years ago
parent c1a4daa5a6
commit 9be5ce07f5

@ -793,11 +793,12 @@ def upload_ssh_key():
groups = sql.select_groups(id=group_id)
for group in groups:
user_group = group.name
if ssh_mod.upload_ssh_key(name, user_group, key):
try:
ssh_mod.upload_ssh_key(f'{name}_{user_group}', user_group, key)
data = {'status': 'done'}
return dict(data)
else:
data = {'status': 'error: check all fields'}
except Exception as e:
data = {'status': f'{e}'}
return dict(data)
@ -815,7 +816,7 @@ def create_server():
login, group_id, role_id = sql.get_username_groupid_from_api_token(token)
try:
if server_mod.create_server(hostname, ip, group_id, virt, 1, master_id, cred_id, port, desc, 0, 0, 0, 0, '1', role_id=role_id, token=token):
if server_mod.create_server(hostname, ip, group_id, virt, 1, master_id, cred_id, port, desc, 0, 0, 0, 0, role_id=role_id, token=token):
data = {'status': 'done'}
roxywi_common.logging(ip, f'A new server {hostname} has been created', roxywi=1, keep_history=1, service='server')
return dict(data)

@ -92,18 +92,15 @@ def create_ssh_cread_api(name: str, enable: str, group: str, username: str, pass
def upload_ssh_key(name: str, user_group: str, key: str) -> bool:
if '..' in name:
print('error: nice try')
return False
raise Exception('error: nice try')
if name == '':
print('error: please select credentials first')
return False
raise Exception('error: please select credentials first')
try:
key = paramiko.pkey.load_private_key(key)
except Exception as e:
print(f'error: Cannot save SSH key file: {e}')
return False
raise Exception(f'error: Cannot save SSH key file: {e}')
lib_path = get_config.get_config_var('main', 'lib_path')
full_dir = f'{lib_path}/keys/'
@ -126,8 +123,7 @@ def upload_ssh_key(name: str, user_group: str, key: str) -> bool:
try:
key.write_private_key_file(ssh_keys)
except Exception as e:
print(f'error: Cannot save SSH key file: {e}')
return False
raise Exception(f'error: Cannot save SSH key file: {e}')
else:
print(f'success: SSH key has been saved into: {ssh_keys}')
@ -135,10 +131,9 @@ def upload_ssh_key(name: str, user_group: str, key: str) -> bool:
os.chmod(ssh_keys, 0o600)
except IOError as e:
roxywi_common.logging('Roxy-WI server', e.args[0], roxywi=1)
return False
raise Exception(f'error: something went wrong: {e}')
roxywi_common.logging("Roxy-WI server", f"A new SSH cert has been uploaded {ssh_keys}", roxywi=1, login=1)
return True
def update_ssh_key() -> None:

@ -847,7 +847,10 @@ if form.getvalue('ssh_cert'):
name = common.checkAjaxInput(form.getvalue('name'))
key = form.getvalue('ssh_cert')
ssh_mod.upload_ssh_key(name, user_group, key)
try:
ssh_mod.upload_ssh_key(name, user_group, key)
except Exception as e:
print(e)
if form.getvalue('new_receiver'):
import modules.alerting.alerting as alerting

Loading…
Cancel
Save