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

Commit 20b39b5

Browse files
committed
Remove CATTUS_... environment variables in favor of --force + --skip flags
1 parent c9a2fa2 commit 20b39b5

13 files changed

Lines changed: 271 additions & 71 deletions

File tree

include/cloysterhpc/cloyster.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <cloysterhpc/services/log.h>
1010
#include <fmt/format.h>
1111
#include <magic_enum/magic_enum.hpp>
12+
#include <set>
1213
#include <string>
1314

1415
namespace cloyster {
@@ -22,6 +23,12 @@ extern bool runAsDaemon;
2223
extern std::string logLevelInput;
2324
extern std::string answerfile;
2425
extern std::string customRepofilePath;
26+
27+
extern std::set<std::string> skipSteps;
28+
extern std::set<std::string> forceSteps;
29+
30+
bool shouldSkip(const std::string& step);
31+
bool shouldForce(const std::string& step);
2532
}
2633

2734
#endif // CLOYSTERHPC_CLOYSTER_H_

include/cloysterhpc/functions.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,13 @@ void installFile(const std::filesystem::path& path, std::string&& data);
190190

191191
bool exists(const std::filesystem::path& path);
192192

193-
void createHTTPRepo(const std::string_view repoName);
193+
struct HTTPRepo {
194+
std::filesystem::path directory;
195+
std::string name;
196+
std::string url;
197+
};
198+
199+
HTTPRepo createHTTPRepo(const std::string_view repoName);
194200

195201
} // namespace cloyster
196202

include/cloysterhpc/models/os.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,5 +131,18 @@ class OS {
131131
void printData() const;
132132
};
133133

134+
134135
}; // namespace cloyster::models
136+
137+
template <>
138+
struct fmt::formatter<cloyster::models::OS> : formatter<string_view> {
139+
template <typename FormatContext>
140+
auto format(const cloyster::models::OS& osinfo, FormatContext& ctx) const
141+
-> decltype(ctx.out())
142+
{
143+
return fmt::format_to(ctx.out(), "OS(distro={}, kernel={})", osinfo.getDistroString(), osinfo.getKernel());
144+
}
145+
};
146+
147+
135148
#endif // CLOYSTERHPC_OS_H_

include/cloysterhpc/patterns/singleton.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef CLOYSTER_SINGLETON_H
2-
#define CLOYSTER_SINGLETON_H
1+
#ifndef CLOYSTER_SINGLETON_H_
2+
#define CLOYSTER_SINGLETON_H_
33

44
#include <memory>
55
#include <mutex>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#ifndef CLOYSTER_OSSERVICE_H_
2+
#define CLOYSTER_OSSERVICE_H_
3+
4+
#include <string>
5+
6+
#include <cloysterhpc/models/os.h>
7+
8+
namespace cloyster::services {
9+
10+
using cloyster::models::OS;
11+
12+
class IOSService {
13+
public:
14+
[[nodiscard]] IOSService(const IOSService&) = default;
15+
IOSService(IOSService&&) = delete;
16+
IOSService& operator=(const IOSService&) = default;
17+
IOSService& operator=(IOSService&&) = delete;
18+
IOSService() = default;
19+
virtual ~IOSService() = default;
20+
21+
[[nodiscard]] virtual std::string getKernelVersion() const = 0;
22+
23+
static std::unique_ptr<IOSService> factory(const OS& osinfo);
24+
};
25+
26+
class ELOSService final : public IOSService {
27+
public:
28+
[[nodiscard]] std::string getKernelVersion() const override;
29+
};
30+
31+
32+
};
33+
34+
#endif

include/cloysterhpc/services/xcat.h

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,19 @@
66
#ifndef CLOYSTERHPC_XCAT_H_
77
#define CLOYSTERHPC_XCAT_H_
88

9+
#include <filesystem>
10+
#include <string>
11+
12+
#include <fmt/format.h>
13+
#include <fmt/ranges.h> // for std::vector formatters
14+
#include <magic_enum/magic_enum.hpp>
15+
916
#include <cloysterhpc/const.h>
1017
#include <cloysterhpc/services/execution.h>
1118
#include <cloysterhpc/services/log.h>
1219
#include <cloysterhpc/services/provisioner.h>
1320
#include <cloysterhpc/services/shell.h>
1421

15-
#include <magic_enum/magic_enum.hpp>
16-
17-
#include <filesystem>
18-
#include <memory>
19-
#include <string>
2022

2123
namespace cloyster::services {
2224

@@ -28,7 +30,20 @@ namespace cloyster::services {
2830
* provisioning process of compute and service nodes in a cluster using xCAT.
2931
*/
3032
class XCAT : public Provisioner {
33+
public:
34+
struct Image {
35+
std::vector<std::string_view> otherpkgs = {};
36+
// @TODO: We need to support more than one osimage (:
37+
// this can be a default osimage though
38+
std::string osimage;
39+
std::filesystem::path chroot;
40+
std::vector<std::string> postinstall = { "#!/bin/sh\n\n" };
41+
std::vector<std::string> synclists;
42+
};
43+
3144
private:
45+
Image m_stateless;
46+
3247
/**
3348
* @enum ImageType
3449
* @brief Defines the types of OS images.
@@ -45,15 +60,6 @@ class XCAT : public Provisioner {
4560
*/
4661
enum class NodeType { Compute, Service };
4762

48-
struct {
49-
std::vector<std::string_view> otherpkgs = {};
50-
// @TODO: We need to support more than one osimage (:
51-
// this can be a default osimage though
52-
std::string osimage;
53-
std::filesystem::path chroot;
54-
std::vector<std::string> postinstall = { "#!/bin/sh\n\n" };
55-
std::vector<std::string> synclists;
56-
} m_stateless;
5763

5864
static void setDHCPInterfaces(std::string_view interface);
5965
static void setDomain(std::string_view domain);
@@ -107,13 +113,6 @@ class XCAT : public Provisioner {
107113
*/
108114
void configureTimeService();
109115

110-
/**
111-
* @brief Configures InfiniBand settings.
112-
*
113-
* This function sets up InfiniBand interconnect settings.
114-
*/
115-
void configureInfiniband();
116-
117116
/**
118117
* @brief Configures SLURM settings.
119118
*
@@ -263,8 +262,31 @@ class XCAT : public Provisioner {
263262
* This function resets the nodes.
264263
*/
265264
static void resetNodes();
265+
266+
/**
267+
* @brief Configures InfiniBand settings.
268+
*
269+
* This function sets up InfiniBand interconnect settings.
270+
*/
271+
void configureInfiniband();
272+
273+
/**
274+
* @brief Return the Image
275+
*/
276+
[[nodiscard]] Image getImage() const;
277+
};
278+
266279
};
267280

281+
template <>
282+
struct fmt::formatter<cloyster::services::XCAT::Image> : formatter<string_view> {
283+
template <typename FormatContext>
284+
auto format(const cloyster::services::XCAT::Image& image, FormatContext& ctx) const
285+
-> decltype(ctx.out())
286+
{
287+
return fmt::format_to(ctx.out(), "XCAT::Image({}, {})",
288+
image.osimage, image.otherpkgs);
289+
}
268290
};
269291

270292
#endif // CLOYSTERHPC_XCAT_H_

src/cloyster.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,18 @@ std::string logLevelInput
1212
= fmt::format("{}", magic_enum::enum_name(Log::Level::Info));
1313
std::string answerfile = "";
1414
std::string customRepofilePath = "";
15+
16+
std::set<std::string> skipSteps{};
17+
std::set<std::string> forceSteps{};
18+
19+
bool shouldSkip(const std::string& step)
20+
{
21+
return skipSteps.contains(step);
22+
}
23+
24+
bool shouldForce(const std::string& step)
25+
{
26+
return forceSteps.contains(step);
27+
}
28+
1529
}

src/diskImage.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7+
#include <cloysterhpc/cloyster.h>
78
#include <cloysterhpc/diskImage.h>
89
#include <cloysterhpc/functions.h>
910
#include <cloysterhpc/models/os.h>
@@ -78,10 +79,9 @@ bool DiskImage::hasVerifiedChecksum(const std::filesystem::path& path)
7879
return true;
7980
}
8081

81-
LOG_INFO("Verifying disk image checksum... This may take a while")
82-
if (cloyster::getEnvironmentVariable("CATTUS_SKIP_DISK_CHECKSUM") == "1") {
83-
LOG_WARN("Skiping disk the image checksum because "
84-
"CATTUS_SKIP_DISK_CHECKSUM=1");
82+
LOG_INFO("Verifying disk image checksum... This may take a while, use `--skip disk-checksum` to skip")
83+
if (cloyster::shouldSkip("disk-checksum")) {
84+
LOG_WARN("Skiping disk the image checksum because `--skip disk-checksum`");
8585
return true;
8686
}
8787

src/functions.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,14 +385,18 @@ bool exists(const std::filesystem::path& path)
385385
return std::filesystem::exists(path);
386386
}
387387

388-
void createHTTPRepo(const std::string_view repoName)
388+
HTTPRepo createHTTPRepo(const std::string_view repoName)
389389
{
390390
const auto confPath = fmt::format("/etc/httpd/conf.d/{}.conf", repoName);
391+
const auto repoFolder = fmt::format("/var/www/html/repos/{}", repoName);
392+
// @FIXME: Use the HN hostname instead of localhost to make it work in the nodes
393+
HTTPRepo repo(repoFolder, std::string(repoName), fmt::format("http://localhost/repos/{}", repoName));
391394
if (exists(confPath)) {
392395
LOG_WARN("Skipping the creation of HTTP repository, {} already exists", confPath);
393-
return;
396+
return repo;
394397
}
395-
auto repoFolder = fmt::format("/var/www/html/{}", repoName);
398+
399+
cloyster::createDirectory("/var/www/html/repos/");
396400
LOG_INFO("Creating HTTP repository {} at {}", confPath, repoFolder);
397401
auto runner = cloyster::Singleton<BaseRunner>::get();
398402
cloyster::createDirectory(repoFolder);
@@ -409,6 +413,7 @@ IndexOptions FancyIndexing VersionSort NameWidth=* HTMLTable Charset=UTF-8
409413

410414
runner->checkCommand("apachectl configtest");
411415
runner->checkCommand("systemctl restart httpd");
416+
return repo;
412417
}
413418

414419
}; // namespace cloyster

0 commit comments

Comments
 (0)