Fix server clones following uuid migration

This commit is contained in:
amcmanu3 2024-04-01 17:02:27 -04:00
parent 9dffc25cc8
commit 432421f362

View File

@ -67,20 +67,29 @@ class ApiServersServerActionHandler(BaseApiHandler):
name_counter += 1 name_counter += 1
new_server_name = server_data.get("server_name") + f" (Copy {name_counter})" new_server_name = server_data.get("server_name") + f" (Copy {name_counter})"
new_server_id = self.controller.servers.create_server( new_server_id = self.helper.create_uuid()
new_server_name, new_server_path = os.path.join(self.helper.servers_dir, new_server_id)
None, new_backup_path = os.path.join(self.helper.backup_path, new_server_id)
"", new_server_command = str(server_data.get("execution_command")).replace(
None, server_id, new_server_id
server_data.get("executable"), )
None, new_server_log_path = server_data.get("log_path").replace(
server_data.get("stop_command"), server_id, new_server_id
server_data.get("type"),
user_id,
server_data.get("server_port"),
) )
new_server_path = os.path.join(self.helper.servers_dir, new_server_id) self.controller.register_server(
new_server_name,
new_server_id,
new_server_path,
new_backup_path,
new_server_command,
server_data.get("executable"),
new_server_log_path,
server_data.get("stop_command"),
server_data.get("server_port"),
user_id,
server_data.get("type"),
)
self.controller.management.add_to_audit_log( self.controller.management.add_to_audit_log(
user_id, user_id,
@ -92,18 +101,6 @@ class ApiServersServerActionHandler(BaseApiHandler):
# copy the old server # copy the old server
FileHelpers.copy_dir(server_data.get("path"), new_server_path) FileHelpers.copy_dir(server_data.get("path"), new_server_path)
# TODO get old server DB data to individual variables
new_server_command = str(server_data.get("execution_command"))
new_server_log_file = str(
self.helper.get_os_understandable_path(server_data.get("log_path"))
)
server: Servers = self.controller.servers.get_server_obj(new_server_id)
server.path = new_server_path
server.log_path = new_server_log_file
server.execution_command = new_server_command
self.controller.servers.update_server(server)
for role in self.controller.server_perms.get_server_roles(server_id): for role in self.controller.server_perms.get_server_roles(server_id):
mask = self.controller.server_perms.get_permissions_mask( mask = self.controller.server_perms.get_permissions_mask(
role.role_id, server_id role.role_id, server_id