Skip to content
This repository was archived by the owner on Apr 16, 2026. It is now read-only.

Commit 56f01aa

Browse files
committed
Add confluent support
1 parent 56a9e89 commit 56f01aa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+4382
-1107
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,3 +323,5 @@ test/output/**
323323
CMakePresets.json
324324
CMakeUserPresets.json
325325
.aider*
326+
deploy*.txt
327+
test/vms/

include/cloysterhpc/diskImage.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include <cloysterhpc/models/os.h>
1313

14+
// @FIXME: Add proper namespace
1415
/**
1516
* @class DiskImage
1617
* @brief Manages disk image paths and validation for known images.
@@ -22,7 +23,7 @@ class DiskImage {
2223
private:
2324
std::filesystem::path m_path;
2425
std::optional<cloyster::models::OS::Distro> m_distro = std::nullopt;
25-
26+
2627
// BUG: This is bad design, and also overrides what's inside the map
2728
// variable on the class that holds the checksums.
2829
/**

include/cloysterhpc/functions.h

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ constexpr std::unique_ptr<B> makeUniqueDerived(Args... args)
3333
return static_cast<std::unique_ptr<B>>(std::make_unique<T>(args...));
3434
}
3535

36+
37+
// @FIXME: File utilities functions should live in services::files namespace
38+
3639
using models::OS;
3740
using services::IRunner;
3841

@@ -282,7 +285,7 @@ void moveFilesWithExtension(
282285
std::string getHttpStatus(const auto& url, const std::size_t maxRetries = 3)
283286
{
284287
auto runner = cloyster::Singleton<IRunner>::get();
285-
auto opts = cloyster::Singleton<services::Options>::get();
288+
auto opts = cloyster::Singleton<const services::Options>::get();
286289
if (opts->shouldSkip("http-status")) {
287290
LOG_WARN("Skipping HTTP status check for {}, assuming 200 (reason: "
288291
"--skip=http-status in the command line)",
@@ -304,18 +307,32 @@ std::string getHttpStatus(const auto& url, const std::size_t maxRetries = 3)
304307
for (std::size_t i = 0; i < maxRetries; ++i) {
305308
header = getHttpStatusInner(url, runner);
306309
LOG_DEBUG("HTTP status of {}: {}", url, header);
307-
if (!header.starts_with("5")) {
308-
LOG_DEBUG("HTTP {} error, retry {}", header, i);
310+
if (header.starts_with("2")) {
311+
return header;
312+
} else if (header.starts_with("5")) {
313+
LOG_DEBUG("HTTP INTERNAL SERVER ERROR {} error, retring ...{}", header, i);
314+
return header;
315+
} else {
316+
LOG_DEBUG("HTTP {} error, retrying ...{}", header, i);
309317
return header;
310318
}
311319
}
312320
return header;
313321
};
314322

315-
[[noreturn]] void abort(const fmt::string_view& fmt, auto&&... args)
323+
[[noreturn]]
324+
void abort(const fmt::string_view& fmt, auto&&... args)
325+
{
326+
throw std::runtime_error(
327+
fmt::format(fmt::runtime(fmt), std::forward<decltype(args)>(args)...));
328+
}
329+
330+
void abortif(const bool cond, const fmt::string_view& fmt, auto&&... args)
316331
{
332+
if (cond) {
317333
throw std::runtime_error(
318334
fmt::format(fmt::runtime(fmt), std::forward<decltype(args)>(args)...));
335+
}
319336
}
320337

321338
TEST_SUITE_END();

include/cloysterhpc/models/answerfile.h

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ struct AFNode {
3737
std::optional<std::string> sockets;
3838
std::optional<std::string> cores_per_socket;
3939
std::optional<std::string> threads_per_core;
40+
std::optional<std::string> cpus_per_node;
41+
std::optional<std::string> real_memory;
4042
std::optional<std::string> bmc_address;
4143
std::optional<std::string> bmc_username;
4244
std::optional<std::string> bmc_password;
@@ -122,7 +124,22 @@ class AnswerFile {
122124
std::filesystem::path disk_image;
123125
OS::Distro distro;
124126
std::string version;
125-
std::string kernel;
127+
std::optional<std::string> kernel;
128+
std::string provisioner;
129+
};
130+
131+
struct AFSlurm {
132+
std::string mariadb_root_password;
133+
std::string slurmdb_password;
134+
std::string storage_password;
135+
std::string partition_name;
136+
};
137+
138+
struct AFProvisionerConfig {
139+
std::string bmcuser;
140+
std::string bmcpass;
141+
std::string rootpass;
142+
std::string grubpass;
126143
};
127144

128145
/**
@@ -135,6 +152,8 @@ class AnswerFile {
135152
struct AFNodes {
136153
std::optional<AFNode> generic;
137154
std::vector<AFNode> nodes;
155+
156+
auto nodesNames() const -> std::vector<std::string>;
138157
};
139158

140159
struct AFPostfix {
@@ -339,6 +358,8 @@ class AnswerFile {
339358
void dumpNetwork(
340359
const AFNetwork& network, const std::string& networkSection);
341360

361+
void loadSlurm();
362+
342363
public:
343364
AFNetwork external;
344365
AFNetwork management;
@@ -351,6 +372,7 @@ class AnswerFile {
351372
AFNodes nodes;
352373
AFPostfix postfix;
353374
AFOFED ofed;
375+
AFSlurm slurm;
354376

355377
/**
356378
* @brief Loads the answer file from the specified path.
@@ -360,6 +382,9 @@ class AnswerFile {
360382
void loadFile(const std::filesystem::path& path);
361383
void dumpFile(const std::filesystem::path& path);
362384

385+
386+
[[nodiscard]] auto path() const -> const std::filesystem::path&;
387+
363388
AnswerFile();
364389
explicit AnswerFile(const std::filesystem::path& path);
365390
};

include/cloysterhpc/models/cluster.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#ifndef CLOYSTERHPC_CLUSTER_H_
77
#define CLOYSTERHPC_CLUSTER_H_
88

9+
#include "answerfile.h"
910
#include <filesystem>
1011
#include <memory>
1112
#include <optional>
@@ -51,7 +52,7 @@ class Cluster {
5152
* @enum Provisioner
5253
* @brief Enumeration for cluster provisioners.
5354
*/
54-
enum class Provisioner { xCAT };
55+
enum class Provisioner { xCAT, Confluent };
5556

5657
private:
5758
std::string m_name;
@@ -177,7 +178,7 @@ class Cluster {
177178
std::optional<OFED> getOFED() const;
178179
void setOFED(OFED::Kind kind, std::string version = "latest");
179180

180-
std::optional<std::unique_ptr<QueueSystem>>& getQueueSystem();
181+
[[nodiscard]] const std::optional<std::unique_ptr<QueueSystem>>& getQueueSystem() const;
181182
void setQueueSystem(QueueSystem::Kind kind);
182183

183184
std::optional<services::Postfix>& getMailSystem();
@@ -230,9 +231,9 @@ class Cluster {
230231
/**
231232
* @brief Fills cluster data from the specified answer file.
232233
*
233-
* @param answerfilePath Path to the answer file.
234+
* @param answerfile, the AnswerFile instance
234235
*/
235-
void fillData(const std::filesystem::path& answerfilePath);
236+
void fillData(const AnswerFile& answerfile);
236237

237238
void dumpData(const std::filesystem::path& answerfilePath);
238239

include/cloysterhpc/models/os.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <cloysterhpc/const.h>
1010
#include <fmt/format.h>
1111
#include <gsl/gsl-lite.hpp>
12+
#include <optional>
1213
#include <string>
1314
#include <variant>
1415

@@ -66,7 +67,7 @@ class OS {
6667
std::variant<std::monostate, Family> m_family;
6768
std::variant<std::monostate, Platform> m_platform;
6869
std::variant<std::monostate, Distro> m_distro;
69-
std::string m_kernel;
70+
std::optional<std::string> m_kernel; // kernel version may be uninitialized
7071
unsigned m_majorVersion {};
7172
unsigned m_minorVersion {};
7273

@@ -108,7 +109,7 @@ class OS {
108109
void setDistro(Distro distro);
109110
void setDistro(std::string_view distro);
110111

111-
[[nodiscard]] std::string_view getKernel() const;
112+
[[nodiscard]] std::optional<std::string_view> getKernel() const;
112113
void setKernel(std::string_view kernel);
113114

114115
[[nodiscard]] std::string getVersion() const;

include/cloysterhpc/network.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
using boost::asio::ip::address;
1616

17+
// @FIXME: This should be in a namespace
1718
/* TODO: Refactoring is necessary
1819
* m_domainName is also available here since non-default networks may
1920
* exist on the entire cluster and they should have their own domain.

include/cloysterhpc/patterns/singleton.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include <memory>
66
#include <mutex>
77

8+
#include <cloysterhpc/services/log.h>
9+
810
namespace cloyster {
911

1012
/**
Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +0,0 @@
1-
#ifndef CLOYSTERHPC_PATTERNS_STRONGTYPEDEF_H_
2-
#define CLOYSTERHPC_PATTERNS_STRONGTYPEDEF_H_
3-
4-
namespace cloyster {
5-
6-
// NewType template (from your previous context)
7-
template <typename T, typename Tag> struct Wrapper {
8-
T value;
9-
explicit Wrapper(const T& v)
10-
: value(v)
11-
{
12-
}
13-
explicit operator T() const { return value; }
14-
};
15-
16-
};
17-
18-
#endif

include/cloysterhpc/patterns/wrapper.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ifndef CLOYSTERHPC_PATTERNS_WRAPPER_H_
22
#define CLOYSTERHPC_PATTERNS_WRAPPER_H_
33

4+
#include <filesystem>
5+
46
namespace cloyster {
57
/**
68
* @class Wrapper
@@ -31,7 +33,8 @@ namespace cloyster {
3133
* processUser(email); // Error: Email is not User
3234
* @endcode
3335
*/
34-
template <typename T, typename Tag> class Wrapper final {
36+
template <typename T, typename Tag>
37+
class Wrapper final {
3538
T value;
3639

3740
public:

0 commit comments

Comments
 (0)