Skip to content

Commit

Permalink
Fixes RELEASE builds
Browse files Browse the repository at this point in the history
Signed-off-by: Vinícius Ferrão <[email protected]>
  • Loading branch information
viniciusferrao committed May 11, 2024
1 parent af32d3f commit 3fd1afa
Show file tree
Hide file tree
Showing 26 changed files with 142 additions and 139 deletions.
3 changes: 3 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"cacheVariables": {
"CMAKE_C_COMPILER": "gcc",
"CMAKE_CXX_COMPILER": "g++",
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
"CMAKE_BUILD_TYPE": "Release"
}
},
{
Expand All @@ -73,7 +73,7 @@
"cacheVariables": {
"CMAKE_C_COMPILER": "clang",
"CMAKE_CXX_COMPILER": "clang++",
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
"CMAKE_BUILD_TYPE": "Release"
}
}
],
Expand Down
6 changes: 3 additions & 3 deletions include/cloysterhpc/services/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@
}
#else
// Disabled for RELEASE builds
#define LOG_TRACE(...) (void)0
#define LOG_DEBUG(...) (void)0
#define LOG_ASSERT(x, msg) (void)0
#define LOG_TRACE(...) (void)0;
#define LOG_DEBUG(...) (void)0;
#define LOG_ASSERT(x, msg) (void)0;
#endif

namespace Log {
Expand Down
6 changes: 3 additions & 3 deletions include/cloysterhpc/view/newt.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ class Newt : public View {

for (const auto& string : tempStrings) {
cStrings.push_back(string.c_str());
LOG_TRACE("Pushed back std::string {}", string.c_str());
LOG_TRACE("Pushed back std::string {}", string.c_str())
}
cStrings.push_back(nullptr);
LOG_TRACE("Pushed back nullptr");
LOG_TRACE("Pushed back nullptr")

#if 1
// goto implementation
Expand Down Expand Up @@ -231,7 +231,7 @@ class Newt : public View {
for (std::size_t i = 0; i < arraySize; i++) {
field[i].text = const_cast<char*>(items[i].first.c_str());
fieldEntries[i] = const_cast<char*>((items[i].second).c_str());
LOG_TRACE("fieldEntries[{}] = {}", i, fieldEntries[i]);
LOG_TRACE("fieldEntries[{}] = {}", i, fieldEntries[i])

// TODO: Check is there's a way to hide &
field[i].value = &fieldEntries[i];
Expand Down
4 changes: 2 additions & 2 deletions src/answerfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void AnswerFile::loadFile(const std::filesystem::path& path)

void AnswerFile::loadOptions()
{
LOG_TRACE("Verify answerfile variables");
LOG_TRACE("Verify answerfile variables")

loadExternalNetwork();
loadManagementNetwork();
Expand Down Expand Up @@ -236,7 +236,7 @@ void AnswerFile::loadNodes()
break;
}

LOG_TRACE("Configure {}", nodeSection);
LOG_TRACE("Configure {}", nodeSection)
AFNode newNode = loadNode(nodeSection);

if (newNode.hostname->empty()) {
Expand Down
70 changes: 35 additions & 35 deletions src/cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include <cloysterhpc/answerfile.h>
#include <cloysterhpc/cluster.h>
#include <cloysterhpc/functions.h>
#include <cloysterhpc/headnode.h>
Expand All @@ -19,7 +20,6 @@
#include <regex>

#ifndef NDEBUG
#include "cloysterhpc/answerfile.h"
#include <fmt/format.h>
#endif

Expand Down Expand Up @@ -276,7 +276,7 @@ void Cluster::printNetworks(
const std::list<std::unique_ptr<Network>>& networks) const
{

LOG_DEBUG("Dump network data:");
LOG_DEBUG("Dump network data:")

#if __cplusplus < 202002L
size_t i, j;
Expand All @@ -285,20 +285,20 @@ void Cluster::printNetworks(
#else
for (size_t i = 0; const auto& network : networks) {
#endif
LOG_DEBUG("Network [{}]", i++);
LOG_DEBUG("Profile: {}", magic_enum::enum_name(network->getProfile()));
LOG_DEBUG("Address: {}", network->getAddress().to_string());
LOG_DEBUG("Subnet Mask: {}", network->getSubnetMask().to_string());
LOG_DEBUG("Gateway: {}", network->getGateway().to_string());
LOG_DEBUG("VLAN: {}", network->getVLAN());
LOG_DEBUG("Domain Name: {}", network->getDomainName());
LOG_DEBUG("Network [{}]", i++)
LOG_DEBUG("Profile: {}", magic_enum::enum_name(network->getProfile()))
LOG_DEBUG("Address: {}", network->getAddress().to_string())
LOG_DEBUG("Subnet Mask: {}", network->getSubnetMask().to_string())
LOG_DEBUG("Gateway: {}", network->getGateway().to_string())
LOG_DEBUG("VLAN: {}", network->getVLAN())
LOG_DEBUG("Domain Name: {}", network->getDomainName())
#if __cplusplus < 202002L
j = 0;
for (const auto& nameserver : network.getNameserver()) {
#else
for (size_t j = 0; const auto& nameserver : network->getNameservers()) {
#endif
LOG_DEBUG("Nameserver [{}]: {}", j++, nameserver.to_string());
LOG_DEBUG("Nameserver [{}]: {}", j++, nameserver.to_string())
}
}
}
Expand All @@ -312,31 +312,31 @@ void Cluster::printConnections()

void Cluster::printData()
{
LOG_DEBUG("Dump cluster data:");
LOG_DEBUG("Cluster attributes defined:");
LOG_DEBUG("Dump cluster data:")
LOG_DEBUG("Cluster attributes defined:")
LOG_DEBUG("OS Data:")
m_headnode.getOS().printData();
LOG_DEBUG("Timezone: {}", getTimezone().getTimezone());
LOG_DEBUG("Locale: {}", getLocale().getLocale());
LOG_DEBUG("Hostname: {}", this->m_headnode.getHostname());
LOG_DEBUG("DomainName: {}", getDomainName());
LOG_DEBUG("FQDN: {}", this->m_headnode.getFQDN());
LOG_DEBUG("Timezone: {}", getTimezone().getTimezone())
LOG_DEBUG("Locale: {}", getLocale().getLocale())
LOG_DEBUG("Hostname: {}", this->m_headnode.getHostname())
LOG_DEBUG("DomainName: {}", getDomainName())
LOG_DEBUG("FQDN: {}", this->m_headnode.getFQDN())

printNetworks(m_network);
printConnections();

LOG_DEBUG("Provisioner: {}", static_cast<int>(getProvisioner()));
// LOG_DEBUG("nodePrefix: {}", nodePrefix);
// LOG_DEBUG("nodePadding: {}", nodePadding);
// LOG_DEBUG("nodeStartIP: {}", nodeStartIP);
// LOG_DEBUG("nodeRootPassword: {}", nodeRootPassword);
LOG_DEBUG("nodeDiskImage: {}", getDiskImage().string());
LOG_DEBUG("Provisioner: {}", static_cast<int>(getProvisioner()))
// LOG_DEBUG("nodePrefix: {}", nodePrefix)
// LOG_DEBUG("nodePadding: {}", nodePadding)
// LOG_DEBUG("nodeStartIP: {}", nodeStartIP)
// LOG_DEBUG("nodeRootPassword: {}", nodeRootPassword)
LOG_DEBUG("nodeDiskImage: {}", getDiskImage().string())

LOG_DEBUG("Update system: {}", (isUpdateSystem() ? "true" : "false"));
// LOG_DEBUG("Remote access: {}", (remoteAccess ? "true" : "false"));
LOG_DEBUG("Update system: {}", (isUpdateSystem() ? "true" : "false"))
// LOG_DEBUG("Remote access: {}", (remoteAccess ? "true" : "false"))

LOG_DEBUG("Firewall: {}", (isFirewall() ? "true" : "false"));
LOG_DEBUG("SELinux: {}", static_cast<int>(getSELinux()));
LOG_DEBUG("Firewall: {}", (isFirewall() ? "true" : "false"))
LOG_DEBUG("SELinux: {}", static_cast<int>(getSELinux()))
}

void Cluster::fillTestData()
Expand Down Expand Up @@ -430,7 +430,7 @@ void Cluster::fillData(const std::string& answerfilePath)

AnswerFile answerfile(answerfilePath);

LOG_TRACE("Configure Management Network");
LOG_TRACE("Configure Management Network")
// Management Network
auto managementNetwork = std::make_unique<Network>(
Network::Profile::Management, Network::Type::Ethernet);
Expand All @@ -454,7 +454,7 @@ void Cluster::fillData(const std::string& answerfilePath)
managementNetwork->setAddress(managementNetwork->calculateAddress(
answerfile.management.con_ip_addr.value()));

LOG_TRACE("Configure External Network");
LOG_TRACE("Configure External Network")
// External Network
auto externalNetwork = std::make_unique<Network>(
Network::Profile::External, Network::Type::Ethernet);
Expand Down Expand Up @@ -495,7 +495,7 @@ void Cluster::fillData(const std::string& answerfilePath)
nodeOS.setKernel(answerfile.system.kernel);
nodeOS.setVersion(answerfile.system.version);

LOG_TRACE("Cluster name: {}", answerfile.information.cluster_name);
LOG_TRACE("Cluster name: {}", answerfile.information.cluster_name)

setName(answerfile.information.cluster_name);
setCompanyName(answerfile.information.company_name);
Expand All @@ -515,7 +515,7 @@ void Cluster::fillData(const std::string& answerfilePath)

addNetwork(std::move(managementNetwork));

LOG_TRACE("Configure Management Connection");
LOG_TRACE("Configure Management Connection")
auto managementConnection
= Connection(&getNetwork(Network::Profile::Management));
managementConnection.setInterface(
Expand All @@ -531,7 +531,7 @@ void Cluster::fillData(const std::string& answerfilePath)

addNetwork(std::move(externalNetwork));

LOG_TRACE("Configure External Connection");
LOG_TRACE("Configure External Connection")
auto externalConnection
= Connection(&getNetwork(Network::Profile::External));
externalConnection.setInterface(answerfile.external.con_interface.value());
Expand Down Expand Up @@ -561,7 +561,7 @@ void Cluster::fillData(const std::string& answerfilePath)

// Infiniband (Application) Network
if (answerfile.application.con_interface.has_value()) {
LOG_TRACE("Configure Application Network");
LOG_TRACE("Configure Application Network")
auto applicationNetwork = std::make_unique<Network>(
Network::Profile::Application, Network::Type::Ethernet);

Expand Down Expand Up @@ -605,10 +605,10 @@ void Cluster::fillData(const std::string& answerfilePath)
setProvisioner(Provisioner::xCAT);
m_headnode.setOS(nodeOS);

LOG_TRACE("Configure Nodes");
LOG_TRACE("Configure Nodes")
for (auto node : answerfile.nodes.nodes) {

LOG_TRACE("Configure node {}", node.hostname.value());
LOG_TRACE("Configure node {}", node.hostname.value())

std::list<Connection> nodeConnections;
auto& connection = nodeConnections.emplace_back(
Expand Down
10 changes: 5 additions & 5 deletions src/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ std::optional<std::string_view> Connection::getInterface() const

void Connection::setInterface(std::string_view interface)
{
LOG_DEBUG("Checking if interface {} exists", interface);
LOG_DEBUG("Checking if interface {} exists", interface)

if (interface == "lo")
throw std::runtime_error("Cannot use the loopback interface");
Expand Down Expand Up @@ -136,7 +136,7 @@ std::optional<std::string_view> Connection::getMAC() const { return m_mac; }

void Connection::setMAC(std::string_view mac)
{
LOG_DEBUG("Checking MAC address: {}", mac);
LOG_DEBUG("Checking MAC address: {}", mac)

if ((mac.size() != 12) && (mac.size() != 14) && (mac.size() != 17))
throw std::runtime_error("Invalid MAC address size");
Expand Down Expand Up @@ -305,9 +305,9 @@ void Connection::dumpConnection() const
magic_enum::enum_name(m_network->getProfile()),
magic_enum::enum_name(m_network->getType()));

LOG_DEBUG("Interface: {}", m_interface.value_or("NONE"));
LOG_DEBUG("MAC Address: {}", m_mac.value_or("NONE"));
LOG_DEBUG("IP Address: {}", getAddress().to_string());
LOG_DEBUG("Interface: {}", m_interface.value_or("NONE"))
LOG_DEBUG("MAC Address: {}", m_mac.value_or("NONE"))
LOG_DEBUG("IP Address: {}", getAddress().to_string())

LOG_DEBUG("===================================")
}
Expand Down
8 changes: 4 additions & 4 deletions src/diskImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ bool DiskImage::isKnownImage(const std::filesystem::path& path)
{
for (const auto& image : m_knownImageFilename)
if (path.filename().string() == image) {
LOG_TRACE("Disk image is recognized");
LOG_TRACE("Disk image is recognized")
return true;
}

Expand All @@ -42,11 +42,11 @@ bool DiskImage::isKnownImage(const std::filesystem::path& path)
bool DiskImage::hasVerifiedChecksum(const std::filesystem::path& path)
{
if (!isKnownImage(path)) {
LOG_TRACE("Disk image is unknown. Can't verify checksum");
LOG_TRACE("Disk image is unknown. Can't verify checksum")
return false;
}

LOG_TRACE("Verifying disk image checksum... This may take a while");
LOG_TRACE("Verifying disk image checksum... This may take a while")

std::unordered_map<std::string, std::string> hash_map = {
{ "rhel-8.8-x86_64-dvd.iso",
Expand Down Expand Up @@ -82,7 +82,7 @@ bool DiskImage::hasVerifiedChecksum(const std::filesystem::path& path)
filter.release();

if (output == isoHash) {
LOG_TRACE("Checksum - The disk image is valid");
LOG_TRACE("Checksum - The disk image is valid")
return true;
}

Expand Down
Loading

0 comments on commit 3fd1afa

Please sign in to comment.