Skip to content

Commit 808812f

Browse files
[CLOYSTER-165] Generate answer file based on TUI data (#91)
* Fixes an outragous number of bugs and warnings Signed-off-by: Vinícius Ferrão <[email protected]> Fixed more outrageous bugs. The program is now able to at least boot a compute node again Signed-off-by: Vinícius Ferrão <[email protected]> Disable cosmetic warnings Pin spdlog version Run clang-format Handle copy to temporary file error Fix message in CMakeLists.txt Handle error in answerfile minor version Fix routing error disabling the VM network Enable Managed network again Fix answerfile version handling Fix copyFile implementation Fix typos, change variables names and fix throw. * Fix typos in the documentation. * Fix typos on LOG messages. * Change variable names to be more accurate with the context. * Rethrow should also follow the golden rule of: throw by value and catch by reference. Signed-off-by: Vinícius Ferrão <[email protected]> Clearning more warnings Fix the last warnings Remove std::exit call, and raise an exception instead Run clang-format Added version ranges to conanfile.txt This change will keep the project more reliable while still getting updates from upstream on minor versions. Signed-off-by: Vinícius Ferrão <[email protected]> Last try to fix clang-format Signed-off-by: Vinícius Ferrão <[email protected]> * Add code to dump answerfile information * Start adding code to dump model (aka cluster) data * Dump cluster data to answerfile * Remove the `ini` parameter in most of answerfile functions This parameter was unneeded, we can use the member m_ini parameter * Reformat some files * Dump the answerfile * presenter: fix issues when counting available nics * Fix some warnings regarding return statements One is for the lack of one, the other is code after one * Fix typing and remote URL * Make the dump answerfile name passable by parameter * Fix lint --------- Signed-off-by: Vinícius Ferrão <[email protected]> Co-authored-by: Vinícius Ferrão <[email protected]>
1 parent d635115 commit 808812f

File tree

9 files changed

+369
-52
lines changed

9 files changed

+369
-52
lines changed

include/cloysterhpc/answerfile.h

Lines changed: 51 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,29 @@
1616

1717
using boost::asio::ip::address;
1818

19+
/**
20+
* @struct AFNode
21+
* @brief Holds individual node settings.
22+
*
23+
* This structure contains optional settings for individual nodes.
24+
*/
25+
struct AFNode {
26+
std::optional<std::string> prefix;
27+
std::optional<std::string> padding;
28+
std::optional<address> start_ip = address();
29+
std::optional<std::string> hostname;
30+
std::optional<std::string> root_password;
31+
std::optional<std::string> mac_address;
32+
std::optional<std::string> sockets;
33+
std::optional<std::string> cores_per_socket;
34+
std::optional<std::string> threads_per_core;
35+
std::optional<std::string> bmc_address;
36+
std::optional<std::string> bmc_username;
37+
std::optional<std::string> bmc_password;
38+
std::optional<std::string> bmc_serialport;
39+
std::optional<std::string> bmc_serialspeed;
40+
};
41+
1942
/**
2043
* @class AnswerFile
2144
* @brief Manages configuration settings for a cluster environment.
@@ -96,29 +119,6 @@ class AnswerFile {
96119
std::string kernel;
97120
};
98121

99-
/**
100-
* @struct AFNode
101-
* @brief Holds individual node settings.
102-
*
103-
* This structure contains optional settings for individual nodes.
104-
*/
105-
struct AFNode {
106-
std::optional<std::string> prefix;
107-
std::optional<std::string> padding;
108-
std::optional<address> start_ip = address();
109-
std::optional<std::string> hostname;
110-
std::optional<std::string> root_password;
111-
std::optional<std::string> mac_address;
112-
std::optional<std::string> sockets;
113-
std::optional<std::string> cores_per_socket;
114-
std::optional<std::string> threads_per_core;
115-
std::optional<std::string> bmc_address;
116-
std::optional<std::string> bmc_username;
117-
std::optional<std::string> bmc_password;
118-
std::optional<std::string> bmc_serialport;
119-
std::optional<std::string> bmc_serialspeed;
120-
};
121-
122122
/**
123123
* @struct AFNodes
124124
* @brief Holds settings for multiple nodes.
@@ -156,6 +156,12 @@ class AnswerFile {
156156
std::filesystem::path m_path;
157157
inifile m_ini;
158158

159+
/**
160+
* Do the inverse of `loadOptions`, i.e, move the stored settings
161+
* into the answerfile.
162+
*/
163+
void dumpOptions();
164+
159165
/**
160166
* @brief Loads the configuration options from the answer file.
161167
*
@@ -188,13 +194,17 @@ class AnswerFile {
188194
*/
189195
void loadExternalNetwork();
190196

197+
void dumpExternalNetwork();
198+
191199
/**
192200
* @brief Loads the management network configuration.
193201
*
194202
* This function parses and loads the settings for the management network.
195203
*/
196204
void loadManagementNetwork();
197205

206+
void dumpManagementNetwork();
207+
198208
/**
199209
* @brief Loads the service network configuration.
200210
*
@@ -209,34 +219,44 @@ class AnswerFile {
209219
*/
210220
void loadApplicationNetwork();
211221

222+
void dumpApplicationNetwork();
223+
212224
/**
213225
* @brief Loads the general information settings.
214226
*
215227
* This function parses and loads the cluster information settings.
216228
*/
217229
void loadInformation();
218230

231+
void dumpInformation();
232+
219233
/**
220234
* @brief Loads the time-related settings.
221235
*
222236
* This function parses and loads the time settings.
223237
*/
224238
void loadTimeSettings();
225239

240+
void dumpTimeSettings();
241+
226242
/**
227243
* @brief Loads the hostname settings.
228244
*
229245
* This function parses and loads the hostname settings.
230246
*/
231247
void loadHostnameSettings();
232248

249+
void dumpHostnameSettings();
250+
233251
/**
234252
* @brief Loads the system settings.
235253
*
236254
* This function parses and loads the system configuration settings.
237255
*/
238256
void loadSystemSettings();
239257

258+
void dumpSystemSettings();
259+
240260
/**
241261
* @brief Loads the node settings.
242262
*
@@ -246,7 +266,10 @@ class AnswerFile {
246266
void loadTools();
247267
void loadNVHPC();
248268

269+
void dumpNodes();
270+
249271
void loadPostfix();
272+
void dumpPostfix();
250273

251274
bool checkEnabled(const std::string& section);
252275
/**
@@ -300,10 +323,12 @@ class AnswerFile {
300323
* @param network The network configuration to load.
301324
* @param optionalNameservers Indicates if the nameservers are optional.
302325
*/
303-
template <typename NetworkType>
304-
void loadNetwork(const std::string& networkSection, NetworkType& network,
326+
void loadNetwork(const std::string& networkSection, AFNetwork& network,
305327
bool optionalNameservers = true);
306328

329+
void dumpNetwork(
330+
const AFNetwork& network, const std::string& networkSection);
331+
307332
public:
308333
AFNetwork external;
309334
AFNetwork management;
@@ -322,6 +347,7 @@ class AnswerFile {
322347
* @param path The path to the answer file.
323348
*/
324349
void loadFile(const std::filesystem::path& path);
350+
void dumpFile(const std::filesystem::path& path);
325351
std::vector<std::shared_ptr<ITool>> getTools();
326352

327353
AnswerFile();

include/cloysterhpc/cluster.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,9 @@ class Cluster {
236236
*
237237
* @param answerfilePath Path to the answer file.
238238
*/
239-
void fillData(const std::string& answerfilePath);
239+
void fillData(const std::filesystem::path& answerfilePath);
240+
241+
void dumpData(const std::filesystem::path& answerfilePath);
240242

241243
#ifndef NDEBUG
242244
void printNetworks(

include/cloysterhpc/presenter/PresenterNetwork.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ class NetworkCreator {
4242
bool checkIfInterfaceRegistered(std::string_view interface);
4343

4444
void saveNetworksToModel(Cluster& model);
45+
46+
std::size_t getSelectedInterfaces();
4547
};
4648

4749
class PresenterNetwork : public Presenter {

0 commit comments

Comments
 (0)