1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-22 22:03:39 +03:00

B #6354: Reinit authentication after passwd change (#2809)

This commit is contained in:
Pavel Czerný 2023-11-15 13:04:50 +01:00 committed by GitHub
parent c2af378c6a
commit ca64f96f26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 1 deletions

View File

@ -104,6 +104,8 @@ public:
void call(const std::string &method, const std::string &format,
xmlrpc_c::value * const result, ...);
void refresh_authentication();
private:
/**
* Creates a new xml-rpc client with specified options.

View File

@ -298,3 +298,15 @@ int Client::call(const std::string& endpoint, const std::string& method,
return xml_rc;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void Client::refresh_authentication()
{
string err;
if (read_oneauth(one_auth, err) != 0 )
{
NebulaLog::log("XMLRPC", Log::ERROR, err);
}
}

View File

@ -828,8 +828,17 @@ class ClusterSet
def monitor(conf)
@mutex.synchronize do
# Get current server raft status, to skip monitor being FOLLOWER
rc = @client.call('zone.raftstatus')
if OpenNebula.is_error?(rc)
# Try to reinit the authentication, in case of authentication error
@client = OpenNebula::Client.new if rc.errno == OpenNebula::Error::EAUTHENTICATION
next
end
xml_e = OpenNebula::XMLElement.build_xml(
@client.call('zone.raftstatus'),
rc,
'RAFT'
)

View File

@ -1876,6 +1876,16 @@ void Scheduler::timer_action()
else
{
NebulaLog::log("SCHED", Log::ERROR, "Cannot contact oned: " + msg);
int errcode = xmlrpc_c::value_int(values[2]);
if (errcode == 0x00100) // Authentication error
{
NebulaLog::log("SCHED", Log::INFO, "Trying to reinit the authentication");
Client::client()->refresh_authentication();
}
return;
}
}