Aug_23_2023-Dev

This commit is contained in:
Ned Wright
2023-08-23 14:15:32 +00:00
parent 702c1184ea
commit b25fd8def5
115 changed files with 8292 additions and 1189 deletions

View File

@@ -177,6 +177,16 @@ FogAuthenticator::registerAgent(
request << details;
}
auto i_agent_details = Singleton::Consume<I_AgentDetails>::by<FogAuthenticator>();
if (
i_agent_details->getOrchestrationMode() == OrchestrationMode::HYBRID ||
getSettingWithDefault<string>("management", "profileManagedMode") == "declarative"
) {
request << make_pair("managedMode", "declarative");
} else {
request << make_pair("managedMode", "management");
}
if (details_resolver->isReverseProxy()) {
request << make_pair("reverse_proxy", "true");
}
@@ -202,7 +212,6 @@ FogAuthenticator::registerAgent(
auto fog_messaging = Singleton::Consume<I_Messaging>::by<FogAuthenticator>();
if (fog_messaging->sendObject(request, HTTPMethod::POST, fog_address_ex + "/agents")) {
dbgDebug(D_ORCHESTRATOR) << "Agent has registered successfully.";
auto i_agent_details = Singleton::Consume<I_AgentDetails>::by<FogAuthenticator>();
i_agent_details->setAgentId(request.getAgentId());
i_agent_details->setProfileId(request.getProfileId());
i_agent_details->setTenantId(request.getTenantId());
@@ -252,7 +261,7 @@ FogAuthenticator::getAccessToken(const UserCredentials &user_credentials) const
}
dbgInfo(D_ORCHESTRATOR) << "New access token was saved";
fog_messaging->loadAccessToken();
Singleton::Consume<I_AgentDetails>::by<FogAuthenticator>()->loadAccessToken();
return AccessToken(request.getAccessToken(), chrono::seconds(request.getExpirationTime()));
}

View File

@@ -117,13 +117,20 @@ FogCommunication::downloadAttributeFile(const GetResourceFile &resourse_file)
}
Maybe<void>
FogCommunication::sendPolicyVersion(const string &policy_version) const
FogCommunication::sendPolicyVersion(const string &policy_version, const string &policy_versions) const
{
PolicyVersionPatchRequest request(policy_version);
PolicyVersionPatchRequest request(policy_version, policy_versions);
auto fog_messaging = Singleton::Consume<I_Messaging>::by<FogCommunication>();
dbgTrace(D_ORCHESTRATOR)
<< "Sending patch request to the fog. Policy version: "
<< policy_version
<< " , Policy versions: "
<< policy_versions;
if (fog_messaging->sendNoReplyObject(request, HTTPMethod::PATCH, fog_address_ex + "/agents")) {
dbgInfo(D_ORCHESTRATOR)
dbgTrace(D_ORCHESTRATOR)
<< "Patch request was sent successfully to the fog."
<< " Policy versions: "
<< policy_versions
<< " Policy version: "
<< policy_version;
return Maybe<void>();

View File

@@ -157,7 +157,7 @@ HybridCommunication::downloadAttributeFile(const GetResourceFile &resourse_file)
}
Maybe<void>
HybridCommunication::sendPolicyVersion(const string &policy_version) const
HybridCommunication::sendPolicyVersion(const string &policy_version, const string &) const
{
dbgFlow(D_ORCHESTRATOR);
policy_version.empty();

View File

@@ -175,7 +175,7 @@ LocalCommunication::setAddressExtenesion(const string &)
}
Maybe<void>
LocalCommunication::sendPolicyVersion(const string &) const
LocalCommunication::sendPolicyVersion(const string &, const string &) const
{
dbgTrace(D_ORCHESTRATOR) << "Agent in offline mode, no need to send policy version";
return Maybe<void>();

View File

@@ -75,9 +75,9 @@ public:
}
Maybe<void>
sendPolicyVersion(const string &policy_version) const override
sendPolicyVersion(const string &policy_version, const string &policy_versions) const override
{
return i_update_comm_impl->sendPolicyVersion(policy_version);
return i_update_comm_impl->sendPolicyVersion(policy_version, policy_versions);
}
Maybe<string>

View File

@@ -39,9 +39,9 @@ public:
}
Maybe<void>
sendPolicyVersion(const string &version)
sendPolicyVersion(const string &version, const string &policy_versions)
{
return local_communication.sendPolicyVersion(version);
return local_communication.sendPolicyVersion(version, policy_versions);
}
Maybe<string>
@@ -228,6 +228,6 @@ TEST_F(LocalCommunicationTest, setAddressExtenesion)
TEST_F(LocalCommunicationTest, sendPolicyVersion)
{
auto res = sendPolicyVersion("12");
auto res = sendPolicyVersion("12", "");
EXPECT_TRUE(res.ok());
}