Adding SSH executor
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
// Add executors here
|
||||
#include <daggy/executors/task/DaggyRunnerTaskExecutor.hpp>
|
||||
#include <daggy/executors/task/ForkingTaskExecutor.hpp>
|
||||
#include <daggy/executors/task/SSHTaskExecutor.hpp>
|
||||
|
||||
#ifdef DAGGY_ENABLE_SLURM
|
||||
#include <daggy/executors/task/SlurmTaskExecutor.hpp>
|
||||
@@ -208,7 +209,45 @@ std::unique_ptr<de::TaskExecutor> executorFactory(const rj::Value &config)
|
||||
"DaggyRunnerExecutor runners must be an array of urls");
|
||||
exe->addRunner(runners[i].GetString());
|
||||
}
|
||||
}
|
||||
else if (name == "SSHTaskExecutor") {
|
||||
if (!execConfig.HasMember("hosts"))
|
||||
throw std::runtime_error(
|
||||
"SSHTaskExecutor config needs at least one host");
|
||||
|
||||
std::unordered_map<std::string,
|
||||
daggy::executors::task::SSHTaskExecutor::RemoteHost>
|
||||
remoteHosts;
|
||||
|
||||
const auto &hosts = execConfig["hosts"];
|
||||
if (!hosts.IsObject())
|
||||
throw std::runtime_error(
|
||||
"SSHTaskExecutor hosts must be a dictionary of host => {cores, "
|
||||
"memoryMB}");
|
||||
|
||||
for (auto it = hosts.MemberBegin(); it != hosts.MemberEnd(); ++it) {
|
||||
if (!it->name.IsString())
|
||||
throw std::runtime_error("Hostnames names must be a string.");
|
||||
if (!it->value.IsObject())
|
||||
throw std::runtime_error("Hostname definitions must be an object.");
|
||||
const std::string hostName = it->name.GetString();
|
||||
|
||||
const auto &caps = it->value.GetObject();
|
||||
|
||||
if (!caps.HasMember("cores"))
|
||||
throw std::runtime_error("Host " + hostName +
|
||||
" is missing cores count.");
|
||||
if (!caps.HasMember("memoryMB"))
|
||||
throw std::runtime_error("Host " + hostName +
|
||||
" is missing memoryMB size.");
|
||||
|
||||
size_t cores = caps["cores"].GetInt64();
|
||||
size_t mem = caps["memoryMB"].GetInt64();
|
||||
remoteHosts.emplace(hostName,
|
||||
daggy::executors::task::SSHTaskExecutor::RemoteHost{
|
||||
.cores = cores, .memoryMB = mem});
|
||||
}
|
||||
auto exe = std::make_unique<de::SSHTaskExecutor>(remoteHosts);
|
||||
return exe;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user