First draft of the new snapshot system and database changes

This commit is contained in:
WolverinDEV
2020-07-30 20:25:45 +02:00
parent c60119af00
commit 72abd7e20e
20 changed files with 1558 additions and 961 deletions
+16 -19
View File
@@ -102,7 +102,7 @@ command_result QueryClient::handleCommand(Command& cmd) {
case string_hash("bindinglist"):
return this->handleCommandBindingList(cmd);
case string_hash("serversnapshotdeploy"): {
#if 1
#if 0
return this->handleCommandServerSnapshotDeploy(cmd);
#else
auto cmd_str = cmd.build();
@@ -911,33 +911,30 @@ command_result QueryClient::handleCommandServerSnapshotDeployNew(const ts::comma
if(this->server) {
return command_result{error::not_implemented};
ACTION_REQUIRES_GLOBAL_PERMISSION(permission::b_virtualserver_snapshot_deploy, 1);
//host = this->server->properties()[property::VIRTUALSERVER_HOST].as<string>();
//port = this->server->properties()[property::VIRTUALSERVER_PORT].as<uint16_t>();
} else {
ACTION_REQUIRES_INSTANCE_PERMISSION(permission::b_virtualserver_snapshot_deploy, 1);
}
std::string error{};
unique_lock server_create_lock(serverInstance->getVoiceServerManager()->server_create_lock);
//TODO: Create a server if no exists
auto result = serverInstance->getVoiceServerManager()->deploy_snapshot(error, this->server, command);
{ /* TODO: Only check if we're creating a new server */
auto instances = serverInstance->getVoiceServerManager()->serverInstances();
if(config::server::max_virtual_server != -1 && instances.size() > config::server::max_virtual_server)
using SnapshotDeployResult = VirtualServerManager::SnapshotDeployResult;
switch (result) {
case SnapshotDeployResult::SUCCESS:
break;
case SnapshotDeployResult::REACHED_SERVER_ID_LIMIT:
return command_result{error::server_max_vs_reached, "You cant create anymore virtual servers. (Server ID limit reached)"};
case SnapshotDeployResult::REACHED_SOFTWARE_SERVER_LIMIT:
return command_result{error::server_max_vs_reached, "You cant create anymore virtual servers. (Software limit reached)"};
case SnapshotDeployResult::REACHED_CONFIG_SERVER_LIMIT:
return command_result{error::server_max_vs_reached, "You reached the via config.yml enabled virtual server limit."};
if(instances.size() >= 65535)
return command_result{error::server_max_vs_reached, "You cant create anymore virtual servers. (Software limit reached)"};
case SnapshotDeployResult::CUSTOM_ERROR:
return command_result{error::vs_critical, error};
}
server_create_lock.unlock();
//TODO: Stop the server completely
if(!serverInstance->getVoiceServerManager()->deploy_snapshot(error, 111, command)) {
//TODO: Delete server is it was new
return command_result{error::vs_critical, error};
}
return command_result{error::ok};
}