mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Merge branch 'bugfix/uuid-server-clone' into 'dev'
Fix server clones following uuid migration See merge request crafty-controller/crafty-4!741
This commit is contained in:
commit
6a71b7d28c
@ -7,6 +7,7 @@ TBD
|
||||
### Bug fixes
|
||||
- Fix migrator issue when jumping versions ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/734))
|
||||
- Fix backend issue causing error when restoring backups in 4.3.x ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/736))
|
||||
- Fix backend issue causing error when cloning servers in 4.3.x ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/741))
|
||||
### Tweaks
|
||||
- Clean up remaining http handler references ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/733))
|
||||
- Remove version disclosure on login page ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/737))
|
||||
|
@ -33,6 +33,17 @@ class ApiServersServerActionHandler(BaseApiHandler):
|
||||
self.controller.crafty_perms.can_create_server(auth_data[4]["user_id"])
|
||||
or auth_data[4]["superuser"]
|
||||
):
|
||||
srv_object = self.controller.servers.get_server_instance_by_id(
|
||||
server_id
|
||||
)
|
||||
if srv_object.check_running():
|
||||
return self.finish_json(
|
||||
409,
|
||||
{
|
||||
"status": "error",
|
||||
"error": "Server Running!",
|
||||
},
|
||||
)
|
||||
self._clone_server(server_id, auth_data[4]["user_id"])
|
||||
return self.finish_json(200, {"status": "ok"})
|
||||
return self.finish_json(
|
||||
@ -67,20 +78,29 @@ class ApiServersServerActionHandler(BaseApiHandler):
|
||||
name_counter += 1
|
||||
new_server_name = server_data.get("server_name") + f" (Copy {name_counter})"
|
||||
|
||||
new_server_id = self.controller.servers.create_server(
|
||||
new_server_name,
|
||||
None,
|
||||
"",
|
||||
None,
|
||||
server_data.get("executable"),
|
||||
None,
|
||||
server_data.get("stop_command"),
|
||||
server_data.get("type"),
|
||||
user_id,
|
||||
server_data.get("server_port"),
|
||||
new_server_id = self.helper.create_uuid()
|
||||
new_server_path = os.path.join(self.helper.servers_dir, new_server_id)
|
||||
new_backup_path = os.path.join(self.helper.backup_path, new_server_id)
|
||||
new_server_command = str(server_data.get("execution_command")).replace(
|
||||
server_id, new_server_id
|
||||
)
|
||||
new_server_log_path = server_data.get("log_path").replace(
|
||||
server_id, new_server_id
|
||||
)
|
||||
|
||||
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(
|
||||
user_id,
|
||||
@ -92,18 +112,6 @@ class ApiServersServerActionHandler(BaseApiHandler):
|
||||
# copy the old server
|
||||
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):
|
||||
mask = self.controller.server_perms.get_permissions_mask(
|
||||
role.role_id, server_id
|
||||
|
Loading…
Reference in New Issue
Block a user