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
2123namespace cloyster ::services {
2224
@@ -28,7 +30,20 @@ namespace cloyster::services {
2830 * provisioning process of compute and service nodes in a cluster using xCAT.
2931 */
3032class 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+
3144private:
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_
0 commit comments