Skip to content

Commit

Permalink
Implement Doxygen in (almost) all the headers
Browse files Browse the repository at this point in the history
Signed-off-by: Lucas Gracioso <[email protected]>
  • Loading branch information
lbgracioso committed May 16, 2024
1 parent 2c286f9 commit c31c232
Show file tree
Hide file tree
Showing 19 changed files with 1,217 additions and 0 deletions.
37 changes: 37 additions & 0 deletions include/cloysterhpc/NFS.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
#include <cloysterhpc/services/IService.h>
#include <string>

/**
* @class NFS
* @brief A class representing the NFS service configuration.
*
* This class provides methods for configuring, enabling, disabling, starting,
* and stopping the NFS service.
*/
class NFS : public IService {
private:
std::string m_directoryName;
Expand All @@ -19,17 +26,47 @@ class NFS : public IService {
boost::asio::ip::address m_address;

public:
/**
* @brief Constructs an NFS object with the specified parameters.
*
* @param directoryName The name of the directory to be shared via NFS.
* @param directoryPath The path of the directory to be shared via NFS.
* @param address The IP address of the NFS server.
* @param permissions The permissions for the NFS share.
*/
NFS(const std::string& directoryName, const std::string& directoryPath,
const boost::asio::ip::address& address,
const std::string& permissions);

/**
* @brief Configures the NFS service with the specified settings.
*/
void configure();

/**
* @brief Enables the NFS service.
*/
void enable() final;

/**
* @brief Disables the NFS service.
*/
void disable() final;

/**
* @brief Starts the NFS service.
*/
void start() final;

/**
* @brief Stops the NFS service.
*/
void stop() final;

private:
/**
* @brief Sets the full path of the NFS share.
*/
void setFullPath();
};

Expand Down
160 changes: 160 additions & 0 deletions include/cloysterhpc/answerfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,26 @@

using boost::asio::ip::address;

/**
* @class AnswerFile
* @brief Manages configuration settings for a cluster environment.
*
* This class loads, parses, and validates various configuration settings from
* an answer file used for setting up and managing a cluster.
*/
class AnswerFile {
#ifdef BUILD_TESTING
public:
#else
private:
#endif
/**
* @struct AFNetwork
* @brief Holds network configuration details.
*
* This structure contains optional settings related to network
* configuration.
*/
struct AFNetwork {
std::optional<address> subnet_mask;
std::optional<address> gateway;
Expand All @@ -30,30 +44,62 @@ class AnswerFile {
std::optional<std::string> con_mac_addr;
};

/**
* @struct AFInformation
* @brief Holds general information settings.
*
* This structure contains settings for cluster name, company name, and
* administrator email.
*/
struct AFInformation {
std::string cluster_name;
std::string company_name;
std::string administrator_email;
};

/**
* @struct AFTime
* @brief Holds time-related settings.
*
* This structure contains settings for timezone, timeserver, and locale.
*/
struct AFTime {
std::string timezone;
std::string timeserver;
std::string locale;
};

/**
* @struct AFHostname
* @brief Holds hostname and domain name settings.
*
* This structure contains the hostname and domain name settings.
*/
struct AFHostname {
std::string hostname;
std::string domain_name;
};

/**
* @struct AFSystem
* @brief Holds system-related settings.
*
* This structure contains settings for disk image, OS distribution,
* version, and kernel.
*/
struct AFSystem {
std::filesystem::path disk_image;
OS::Distro distro;
std::string version;
std::string kernel;
};

/**
* @struct AFNode
* @brief Holds individual node settings.
*
* This structure contains optional settings for individual nodes.
*/
struct AFNode {
std::optional<std::string> prefix;
std::optional<std::string> padding;
Expand All @@ -71,6 +117,13 @@ class AnswerFile {
std::optional<std::string> bmc_serialspeed;
};

/**
* @struct AFNodes
* @brief Holds settings for multiple nodes.
*
* This structure contains generic node settings and a list of specific node
* settings.
*/
struct AFNodes {
std::optional<AFNode> generic;
std::vector<AFNode> nodes;
Expand All @@ -79,27 +132,129 @@ class AnswerFile {
std::filesystem::path m_path;
inifile m_ini;

/**
* @brief Loads the configuration options from the answer file.
*
* This function call methods to parse the answerfile and loads the
* configuration settings.
*/
void loadOptions();

/**
* @brief Converts a string to an address type.
*
* @param addr The string representation of the address.
* @return The converted address.
*/
address convertStringToAddress(const std::string& addr);

/**
* @brief Loads the external network configuration.
*
* This function parses and loads the settings for the external network.
*/
void loadExternalNetwork();

/**
* @brief Loads the management network configuration.
*
* This function parses and loads the settings for the management network.
*/
void loadManagementNetwork();

/**
* @brief Loads the application network configuration.
*
* This function parses and loads the settings for the application network.
*/
void loadApplicationNetwork();

/**
* @brief Loads the general information settings.
*
* This function parses and loads the cluster information settings.
*/
void loadInformation();

/**
* @brief Loads the time-related settings.
*
* This function parses and loads the time settings.
*/
void loadTimeSettings();

/**
* @brief Loads the hostname settings.
*
* This function parses and loads the hostname settings.
*/
void loadHostnameSettings();

/**
* @brief Loads the system settings.
*
* This function parses and loads the system configuration settings.
*/
void loadSystemSettings();

/**
* @brief Loads the node settings.
*
* This function parses and loads the settings for all nodes.
*/
void loadNodes();

/**
* @brief Loads the settings for a specific node.
*
* @param section The section in the answer file representing the node.
* @return The node settings.
*/
AFNode loadNode(const std::string& section);

/**
* @brief Validates the settings for a node.
*
* @param node The node to validate.
* @return The validated node settings.
*/
AFNode validateNode(AFNode node);

/**
* @brief Validates an attribute against a generic attribute.
*
* @tparam T The type of the attribute.
* @param sectionName The name of the section containing the attribute.
* @param attributeName The name of the attribute.
* @param objectAttr The attribute to validate.
* @param genericAttr The generic attribute to validate against.
*/
template <typename T>
void validateAttribute(const std::string& sectionName,
const std::string& attributeName, T& objectAttr, const T& genericAttr);

/**
* @brief Converts a network address and validates it.
*
* @tparam T The type of the network address.
* @param section The section containing the address.
* @param fieldName The name of the field representing the address.
* @param destination The destination to store the converted address.
* @param isOptional Indicates if the field is optional.
*/
template <typename T>
void convertNetworkAddressAndValidate(const std::string& section,
const std::string& fieldName, T& destination, bool isOptional = true);

/**
* @brief Loads the network configuration.
*
* @tparam NetworkType The type of the network configuration.
* @param networkSection The section in the answer file representing the
* network.
* @param network The network configuration to load.
* @param optionalNameservers Indicates if the nameservers are optional.
*/
template <typename NetworkType>
void loadNetwork(const std::string& networkSection, NetworkType& network,
bool optionalNameservers = true);
Expand All @@ -114,6 +269,11 @@ class AnswerFile {
AFSystem system;
AFNodes nodes;

/**
* @brief Loads the answer file from the specified path.
*
* @param path The path to the answer file.
*/
void loadFile(const std::filesystem::path& path);

AnswerFile();
Expand Down
Loading

0 comments on commit c31c232

Please sign in to comment.