Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
171 commits
Select commit Hold shift + click to select a range
7a8c3b5
sm: tests: add UT
Dec 10, 2025
47cab2e
sm: smclient: update deps
Dec 10, 2025
9e5a694
sm: cmake: make smclient build
Dec 10, 2025
5b55c76
fixup! sm: tests: add UT
Dec 12, 2025
aae7c6c
cm: add database module
mykola-kobets-epam Dec 11, 2025
f29f1d1
cm: database: remove imagemanager::storage::StorageItf implementation
mykola-kobets-epam Dec 11, 2025
936a8fb
cm: database: add InstanceIdent::mType to database
mykola-kobets-epam Dec 11, 2025
41d5342
cm: database: update launcher:StorageItf implementation
mykola-kobets-epam Dec 11, 2025
fab995d
pbconvert: add convert for sm message
Dec 12, 2025
f33dd90
sm: smclient: add handlers for incomig msg
Dec 12, 2025
a32fbce
sm: smclient: update UT
Dec 12, 2025
9cc8146
cm: database: implement imagemanager storage
Dec 15, 2025
553dcae
iam: config: handle node info cpu parameters
mlohvynenko Dec 11, 2025
591c9dd
iam: currentnode: use config provided cpu name, arch and variant
mlohvynenko Dec 11, 2025
31e859c
common: jsonprovider: extract NodeConfig JSON conversion functions
Dec 16, 2025
4c58522
cm: unitconfig: add UnitConfig JSON provider
Dec 18, 2025
8745347
cm: unitconfig: add UT
Dec 18, 2025
847db51
cm: cmake: enable unitconfig
Dec 18, 2025
b1e739d
cm: cmake: add required Poco modules to find_package
al1img Dec 16, 2025
672024b
cm: communication: add setting item type for UpdateItemInfo
al1img Dec 16, 2025
98f393a
common: fileserver: implement FileServerItf interface from core library
Dec 18, 2025
195ecb4
cm: networkmanager: adapt to core NodeNetworkItf interface
Dec 18, 2025
99da793
sm: image: remove imagehandler
Dec 18, 2025
3cd65de
sm: launcher: remove launcher
Dec 18, 2025
728d822
sm: runner: remove runner
Dec 18, 2025
829c47a
sm: config: remove unused component configurations
Dec 18, 2025
2c52891
sm: database: remove unused storage interfaces
Dec 18, 2025
fc3f8fb
sm: alerts: extract interfaces to separate files
Dec 18, 2025
9d628f4
sm: logprovider: use core logging types
Dec 18, 2025
56cde77
sm: monitoring: fix iamclient namespace
Dec 18, 2025
4485471
sm: iamclient: reorder service initialization
Dec 18, 2025
9a3aab5
sm: aoscore: update sm initialization
Dec 18, 2025
fd8cfca
sm: cmake: add systemd library
Dec 18, 2025
c8ad958
common: utils: fswatcher: stop polling immidiately on stop call
mlohvynenko Dec 18, 2025
10a6349
cm: iamclient: add PublicCurrentNodeService and PublicIdentityService
mlohvynenko Dec 15, 2025
c54754a
cm: iamclient: initialize public cert service first
mlohvynenko Dec 17, 2025
9bec9b8
cm: smcontroller: specify full namespace for CertListenerItf
mlohvynenko Dec 15, 2025
be6dbe8
common: iamclient: log public cert service calls
mlohvynenko Dec 17, 2025
e5c4cba
cm: config: fix alerts and monitoring configs parsing
mlohvynenko Dec 17, 2025
f6c187c
cm: config: handle node info provider config
mlohvynenko Dec 17, 2025
5d228a0
cm: config: handle image manager config
mlohvynenko Dec 17, 2025
8a51baf
cm: config: remove SM controller configuration
mlohvynenko Dec 17, 2025
953ec4c
cm: config: handle DNS config parameters
mlohvynenko Dec 17, 2025
fb8d0f9
cm: config: remove UM controller configuration
mlohvynenko Dec 18, 2025
306c80a
cm: communication: add variant include
mlohvynenko Dec 15, 2025
3b843c8
cm: communication: link cloudprotocol library
mlohvynenko Dec 15, 2025
a39ddd0
cm: communication: log discovery request status and reason
mlohvynenko Dec 17, 2025
8211c54
cm: communication: set request URI
mlohvynenko Dec 17, 2025
e8650c0
cm: communication: handle ws ping messages
mlohvynenko Dec 17, 2025
99b9ade
cm: communication: send messages as binary frames
mlohvynenko Dec 17, 2025
dafc6cc
cm: communication: log recieved binary frame content
mlohvynenko Dec 17, 2025
a5930bc
cm: communication: use a dedicated mutex for subscribers
mlohvynenko Dec 18, 2025
9c473a0
cm: communication: cloudprotocol: do not send empty correlationID
mlohvynenko Dec 18, 2025
c7037c6
cm: communication: use online certificate for connection
mlohvynenko Dec 18, 2025
6e8aec7
cm: app: initialize and start application
mlohvynenko Dec 15, 2025
7ad531e
iam: config: use OS and Architecture from NodeInfoConfig
mlohvynenko Dec 18, 2025
1754dcf
cm: config: update image manager config
mlohvynenko Dec 19, 2025
698b307
cm: config: remove deprecated fields
mlohvynenko Dec 19, 2025
6d3d2e5
cm: config: tests: update test cases for monitoring and alerts
mlohvynenko Dec 19, 2025
c9252a4
cm: config: parse fileserver URL
mlohvynenko Dec 19, 2025
a0c607c
cm: app: initialize and start fileserver
mlohvynenko Dec 19, 2025
15b6318
cm: config: set default dns storage path to /var/aos/dns
mlohvynenko Dec 19, 2025
bbb6edc
cm: communication: use certificate hostname for service discovery URL
mlohvynenko Dec 19, 2025
dca6ac7
cm: smcontroller: create server credentials during Start phase
Dec 19, 2025
fc0c5b7
sm: resourcemanager: handle missing resource info file gracefully
Dec 19, 2025
bb148e6
iam: currentnode: populate OS info without uname call
mlohvynenko Dec 19, 2025
39e1acb
sm: smclient: wait for node instances status in UT
mlohvynenko Dec 19, 2025
6fd826b
cm: app: initialize monitoring with cloud connection
mlohvynenko Dec 19, 2025
b611f2b
cm: app: initialize alerts with cloud connection
mlohvynenko Dec 19, 2025
6f4c013
sm: monitoring: set partition name
mlohvynenko Dec 19, 2025
30b1115
sm: alerts: fix aler module and start it in sm app
mlohvynenko Dec 19, 2025
9535762
sm: alers: fix static analysis issue
mlohvynenko Dec 20, 2025
2fa25b0
cm: database: fix build after launcher subject processing
mykola-kobets-epam Dec 20, 2025
234bd91
common: ocispec: add parsing rootfs node in image config
al1img Dec 19, 2025
be8fcd9
common: utils: move ChangeOwner implementation to filesystem
al1img Dec 22, 2025
ac18e32
common: utils: refactor image utils
al1img Dec 22, 2025
6769b76
sm: imagemanager: implement image handler
al1img Dec 22, 2025
1fa45c4
sm: launcher: add initial runtime skeletons and factory
al1img Dec 23, 2025
a3cb644
common: config: raise exception instead of returning errors
al1img Dec 23, 2025
7aa45d0
common: utils: json: add GetNames method to retrieve node name list
al1img Dec 23, 2025
d953255
sm: config: add launcher config parsing
al1img Dec 23, 2025
3ec5d6c
sm: app: add runtimes initialization
al1img Dec 23, 2025
3494419
cm: iam: mp: sm: add rdynamic link option for better stack trace
al1img Dec 23, 2025
e1b00b2
common: cm: sm: iam: mp: unify init log
al1img Dec 23, 2025
0e118d3
common: pbconvert: add converting arch and os infos in runtime info
al1img Dec 24, 2025
1379830
cm: config: remove fcrypt node and get CACert from config root
al1img Dec 26, 2025
75775c0
iam: identhandler: fix visidentifier test
al1img Dec 26, 2025
41792f6
iam: sm: use common::utils::ExecCommand to execute external commands
al1img Dec 26, 2025
6007005
all: remove common/utils/logmodule.hpp and use core logger.hpp
al1img Dec 26, 2025
ca94619
cm: utils: implement UID, GID validators
al1img Dec 26, 2025
ac255b1
cm: app: add launcher initialization and starting
al1img Dec 26, 2025
89fc3a3
cm: networkmanager: wrap other modules errors
al1img Dec 26, 2025
5784390
iam: identhandler: use DeferRelease from core lib in visidentifier
al1img Dec 29, 2025
3f3d019
cm: config: add parsing of image manager mRemoveOutdatedPeriod option
al1img Dec 30, 2025
5145a27
cm: app: use cMaxNumConcurrentItems for space allocator items count
al1img Dec 30, 2025
41fa377
common: ocispec: fix usage of renamed CreateExampleRuntimeConfig
al1img Dec 30, 2025
9a7f3b3
sm: config: add image manager config parsing
al1img Dec 30, 2025
d2b4fe8
sm: app: add image manager initialization
al1img Dec 30, 2025
5ebaf01
common: utils: move JoinPath method from config to common utils
al1img Dec 30, 2025
af6defb
common: network: use std::vector instead of aos::Array
al1img Jan 2, 2026
fb8ed43
cm: networkmanager: tests: remove tests namespace
al1img Jan 2, 2026
c72fa4d
sm: launcher: add plugin field into runtime config
al1img Jan 2, 2026
24cab54
sm: config: parse runtime config plugins
al1img Jan 2, 2026
cb002df
iam: iamserver: add check if cmd args is not empty before executing
al1img Jan 2, 2026
41e19a0
iam: iamserver: use nodeID field name in log
al1img Jan 4, 2026
d8582db
common: utils: add NameUUID function to generate name based UUID
al1img Jan 4, 2026
fc5616e
sm: launcher: use name based UUID for generating runtimes ID
al1img Jan 4, 2026
b46f640
common: pbconvert: add owner ID field to instance info
al1img Jan 5, 2026
5863752
common: pbconvert: add parsing instance info monitoring params
al1img Jan 5, 2026
ecc29f3
Revert "sm: launcher: remove launcher"
mlohvynenko Jan 5, 2026
279491f
sm: resourcemanager: update resource info provider itf
al1img Jan 6, 2026
7793968
sm: launcher: utils: handle empty units list in SystemdUpdateChecker
mlohvynenko Jan 6, 2026
a9d1e79
launcher: runtimes: utils: log received systemd unit status
mlohvynenko Jan 8, 2026
4520509
sm: config: set empty runtime config objects
mlohvynenko Jan 8, 2026
e792448
sm: launcher: config: pass workingDir to runtime configs
mlohvynenko Jan 8, 2026
eb3c171
sm: launcher: implement rootfs runtime
mlohvynenko Jan 8, 2026
11dfac2
iam: identhandler: disable VISIdentifier to prevent crash on shutdown
Jan 7, 2026
4e4d867
all: rename correlationID to correlationId
mlohvynenko Jan 9, 2026
e27c6cb
cm: communication: remove timeouted messages from send queue
mlohvynenko Jan 9, 2026
48bd5ae
cm: communication: do not expect ack for ack messages
mlohvynenko Jan 9, 2026
1fa1653
cm: communication: parse decrypt and verify infos as optional
al1img Jan 12, 2026
bca0215
cm: communication: tests: refactor to use mocks from core lib
al1img Jan 12, 2026
7241472
cm: communication: use relative path in http and websocket requests
al1img Jan 12, 2026
a469714
cm: communication: implement "overrideServiceDiscoveryUrl"
al1img Jan 12, 2026
b828cb4
cm: communication: log formatting fixes
al1img Jan 12, 2026
0f090ed
common: downloader: refactor error messages
al1img Jan 12, 2026
d91d769
cm: communication: use subject id instead of codename for subjects
al1img Jan 13, 2026
6517575
common: downloader: fix downloading log
al1img Jan 14, 2026
6aa119f
sm: launcher: container: add runner implementation
al1img Dec 26, 2025
e31912d
sm: luancher: container: update and refactor runner
al1img Dec 27, 2025
bc77a8f
sm: launcher: container: add file system class implementation
al1img Dec 28, 2025
bc0126c
sm: launcher: container: add initial instance class and unit test
al1img Dec 29, 2025
12ac5e2
sm: launcher: container: add container config parsing
al1img Jan 4, 2026
4d611b4
launcher: container: add creating host fs whiteouts on init
al1img Jan 5, 2026
4554b08
cm: config: tests: fix test config formatting
al1img Jan 5, 2026
731f20b
sm: launcher: container: add loading and creating OCI configs
al1img Jan 5, 2026
3e097d3
sm: launcher: container: add ListDir method to file system helper
al1img Jan 5, 2026
1571685
sm: launcher: container: stop active instances on start
al1img Jan 6, 2026
ba39b5d
sm: launcher: container: add process fields to runtime config
al1img Jan 5, 2026
1e1b215
sm: launcher: container: add cgroups path to runtime config
al1img Jan 5, 2026
ab0e61f
sm: launcher: container: add root field to runtime config
al1img Jan 5, 2026
b482eb7
sm: launcher: container: add runtime config helper functions
al1img Jan 6, 2026
77d4c45
sm: launcher: container: add binding host dirs
al1img Jan 6, 2026
e13402e
sm: launcher: container: add network ns to runtime config
al1img Jan 6, 2026
3e0322d
sm: launcher: container: add Aos env vars to runtime config
al1img Jan 6, 2026
6d21ebe
sm: launcher: container: apply image config on runtime config
al1img Jan 6, 2026
1e4bff4
sm: launcher: container: apply service config on runtime config
al1img Jan 6, 2026
76e3544
sm: launcher: container: add resources to runtime config
al1img Jan 6, 2026
34e1d27
sm: launcher: container: apply storage state to runtime config
al1img Jan 6, 2026
a902833
sm: launcher: container: add override env vars to runtime config
al1img Jan 7, 2026
41de1f7
sm: launcher: container: add preparing service state and storage
al1img Jan 7, 2026
541fa0e
sm: launcher: container: add preparing service rootfs
al1img Jan 7, 2026
f555cb1
sm: launcher: container: add setup network
al1img Jan 7, 2026
3622b41
common: utils: make JoinPath to take variadic arguments
al1img Jan 7, 2026
0e9b287
sm: launcher: container: add stop instance implementation
al1img Jan 7, 2026
beabef6
sm: launcher: container: implement sending instance statuses
al1img Jan 7, 2026
d9fec9e
sm: launcher: runtimes: remove semicolon after end of namespace
al1img Jan 13, 2026
1f3280b
sm: launcher: container: tests: disable host device tests
al1img Jan 14, 2026
7f384ae
sm: launcher: container: fix lint warnings
al1img Jan 15, 2026
b06c7bf
sm: app: pass hasher to network manager init
Jan 15, 2026
1d0c7c8
sm: database: rename AddInstanceInfo to UpdateInstanceInfo
mlohvynenko Jan 15, 2026
0f9bfbd
sm: launcher: runtimes: rootfs: set preinstalled and type fields
mlohvynenko Jan 15, 2026
e98f960
common: utils: fsplatform: implement GetBlockDevice method
mlohvynenko Jan 16, 2026
897dbf4
common: utils: use block device to set quota
mlohvynenko Jan 16, 2026
ca2ff14
Revert "sm: app: pass hasher to network manager init"
Jan 17, 2026
14994de
sm: database: add support for storing bridge interface name
Jan 17, 2026
8c3a55c
common: pbconvert: add converting version in instance info
al1img Jan 19, 2026
27a02ae
sm: app: add image manager to launcher
al1img Jan 19, 2026
764d476
sm: launcher: container: fix updating instance run status
al1img Jan 19, 2026
d05ab27
sm: launcher: container: fix creating mount points
al1img Jan 19, 2026
1ccc3e7
cm: database: persist version in launcher::InstanceInfo
mykola-kobets-epam Jan 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/cm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@
# Dependencies
# ######################################################################################################################

find_package(Poco REQUIRED Util)
find_package(
Poco
REQUIRED
Crypto
DataSQLite
Net
NetSSL
Util
)

# ######################################################################################################################
# Target properties
Expand All @@ -24,7 +32,9 @@ set(TARGET_PREFIX ${TARGET_PREFIX}_cm)
add_subdirectory(app)
add_subdirectory(communication)
add_subdirectory(config)
# add_subdirectory(database)
add_subdirectory(database)
add_subdirectory(iamclient)
add_subdirectory(networkmanager)
add_subdirectory(smcontroller)
add_subdirectory(unitconfig)
add_subdirectory(utils)
34 changes: 31 additions & 3 deletions src/cm/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,40 @@ set(TARGET_NAME app)
# Sources
# ######################################################################################################################

set(SOURCES app.cpp main.cpp)
set(SOURCES aoscore.cpp app.cpp main.cpp)

# ######################################################################################################################
# Libraries
# ######################################################################################################################

set(LIBRARIES aos::common::logger aos::common::utils aos::common::version aos::core::common::version
aos::core::cm::storagestate Poco::Util
set(LIBRARIES
aos::cm::communication
aos::cm::config
aos::cm::database
aos::cm::iamclient
aos::cm::networkmanager
aos::cm::smcontroller
aos::cm::unitconfig
aos::cm::utils
aos::common::downloader
aos::common::fileserver
aos::common::logger
aos::common::ocispec
aos::common::utils
aos::common::version
aos::core::cm::alerts
aos::core::cm::imagemanager
aos::core::cm::launcher
aos::core::cm::monitoring
aos::core::cm::nodeinfoprovider
aos::core::cm::storagestate
aos::core::cm::unitconfig
aos::core::cm::updatemanager
aos::core::common::crypto
aos::core::common::pkcs11
aos::core::common::spaceallocator
aos::core::common::version
Poco::Util
)

# ######################################################################################################################
Expand All @@ -38,6 +64,8 @@ add_exec(
${SOURCES}
LIBRARIES
${LIBRARIES}
LINK_OPTIONS
-rdynamic
)

# ######################################################################################################################
Expand Down
280 changes: 280 additions & 0 deletions src/cm/app/aoscore.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,280 @@
/*
* Copyright (C) 2025 EPAM Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <common/utils/exception.hpp>
#include <common/version/version.hpp>

#include <cm/utils/uidgidvalidator.hpp>

#include "aoscore.hpp"
#include "envvarhandler.hpp"

namespace aos::cm::app {

/***********************************************************************************************************************
* Public
**********************************************************************************************************************/

void AosCore::Init(const std::string& configFile)
{
auto err = mLogger.Init();
AOS_ERROR_CHECK_AND_THROW(err, "can't initialize logger");

LOG_DBG() << "Aos core size" << Log::Field("size", sizeof(AosCore));

// Initialize Aos modules

err = config::ParseConfig(configFile.empty() ? cDefaultConfigFile : configFile, mConfig);
AOS_ERROR_CHECK_AND_THROW(err, "can't parse config");

// Initialize crypto provider

err = mCryptoProvider.Init();
AOS_ERROR_CHECK_AND_THROW(err, "can't initialize crypto provider");

// Initialize cert loader

err = mCertLoader.Init(mCryptoProvider, mPKCS11Manager);
AOS_ERROR_CHECK_AND_THROW(err, "can't initialize cert loader");

// Initialize crypto helper

err = mCryptoHelper.Init(
mIAMClient, mCryptoProvider, mCertLoader, mConfig.mServiceDiscoveryURL.c_str(), mConfig.mCACert.c_str());
AOS_ERROR_CHECK_AND_THROW(err, "can't initialize crypto helper");

// Initialize file info provider

err = mFileInfoProvider.Init(mCryptoProvider);
AOS_ERROR_CHECK_AND_THROW(err, "can't initialize file info provider");

// Initialize TLS credentials

err = mTLSCredentials.Init(mConfig.mCACert, mIAMClient, mCertLoader, mCryptoProvider);
AOS_ERROR_CHECK_AND_THROW(err, "can't initialize TLS credentials");

// Initialize IAM client

err = mIAMClient.Init(mConfig.mIAMProtectedServerURL, mConfig.mIAMPublicServerURL, mConfig.mCertStorage,
mTLSCredentials, mConfig.mCertStorage.c_str(), false);
AOS_ERROR_CHECK_AND_THROW(err, "can't initialize IAM client");

// Initialize communication

err = mCommunication.Init(mConfig, mIAMClient, mIAMClient, mIAMClient, mCertLoader, mCryptoProvider, mCryptoHelper,
mCryptoProvider, mUpdateManager, mStorageState, mSMController, mLauncher, mIAMClient, mIAMClient);
AOS_ERROR_CHECK_AND_THROW(err, "can't initialize communication");

InitDatabase();
InitStorageState();
InitSMController();

err = mAlerts.Init(mConfig.mAlerts, mCommunication, mCommunication);
AOS_ERROR_CHECK_AND_THROW(err, "can't initialize alerts");

err = mDownloadSpaceAllocator.Init(mConfig.mImageManager.mInstallPath, mPlatformFS, 0, &mImageManager);
AOS_ERROR_CHECK_AND_THROW(err, "can't initialize download space allocator");

err = mInstallSpaceAllocator.Init(mConfig.mImageManager.mInstallPath, mPlatformFS, 0, &mImageManager);
AOS_ERROR_CHECK_AND_THROW(err, "can't initialize install space allocator");

err = mDownloader.Init(&mAlerts);
AOS_ERROR_CHECK_AND_THROW(err, "can't initialize downloader");

err = mFileServer.Init(mConfig.mFileServerURL, mConfig.mImageManager.mInstallPath.CStr());
AOS_ERROR_CHECK_AND_THROW(err, "can't initialize file server");

err = mImageManager.Init(mConfig.mImageManager, mDatabase, mCommunication, mDownloadSpaceAllocator,
mInstallSpaceAllocator, mDownloader, mFileServer, mCryptoHelper, mFileInfoProvider, mOCISpec);
AOS_ERROR_CHECK_AND_THROW(err, "can't initialize image manager");

err = mNodeInfoProvider.Init(mConfig.mNodeInfoProvider, mIAMClient);
AOS_ERROR_CHECK_AND_THROW(err, "can't initialize node info provider");

err = mMonitoring.Init(mConfig.mMonitoring, mCommunication, mCommunication, mLauncher, mNodeInfoProvider);
AOS_ERROR_CHECK_AND_THROW(err, "can't initialize monitoring");

err = mUnitConfig.Init({mConfig.mUnitConfigFile.c_str()}, mNodeInfoProvider, mSMController, mJSONProvider);
AOS_ERROR_CHECK_AND_THROW(err, "can't initialize unit config");

err = mLauncher.Init(mConfig.mLauncher, mNodeInfoProvider, mSMController, mImageManager, mOCISpec, mUnitConfig,
mStorageState, mNetworkManager, mSMController, mAlerts, mIAMClient, utils::IsUIDValid, utils::IsGIDValid,
mDatabase);
AOS_ERROR_CHECK_AND_THROW(err, "can't initialize launcher");

err = mUpdateManager.Init({mConfig.mUnitStatusSendTimeout}, mIAMClient, mIAMClient, mUnitConfig, mNodeInfoProvider,
mImageManager, mLauncher, mCommunication, mCommunication);
AOS_ERROR_CHECK_AND_THROW(err, "can't initialize update manager");

mDNSServer.Init(mConfig.mDNSStoragePath, mConfig.mDNSIP);

err = mNetworkManager.Init(mDatabase, mCryptoProvider, mSMController, mDNSServer);
AOS_ERROR_CHECK_AND_THROW(err, "can't initialize network manager");
}

void AosCore::Start()
{
auto err = mFSWatcher.Start();
AOS_ERROR_CHECK_AND_THROW(err, "can't start FS watcher");

mCleanupManager.AddCleanup([this]() {
if (auto err = mFSWatcher.Stop(); !err.IsNone()) {
LOG_ERR() << "Can't stop FS watcher" << Log::Field(err);
}
});

err = mFileServer.Start();
AOS_ERROR_CHECK_AND_THROW(err, "can't start file server");

mCleanupManager.AddCleanup([this]() {
if (auto err = mFileServer.Stop(); !err.IsNone()) {
LOG_ERR() << "Can't stop file server" << Log::Field(err);
}
});

err = mStorageState.Start();
AOS_ERROR_CHECK_AND_THROW(err, "can't start storage state");

mCleanupManager.AddCleanup([this]() {
if (auto err = mStorageState.Stop(); !err.IsNone()) {
LOG_ERR() << "Can't stop storage state" << Log::Field(err);
}
});

err = mAlerts.Start();
AOS_ERROR_CHECK_AND_THROW(err, "can't start alerts");

mCleanupManager.AddCleanup([this]() {
if (auto err = mAlerts.Stop(); !err.IsNone()) {
LOG_ERR() << "Can't stop alerts" << Log::Field(err);
}
});

err = mNodeInfoProvider.Start();
AOS_ERROR_CHECK_AND_THROW(err, "can't start node info provider");

mCleanupManager.AddCleanup([this]() {
if (auto err = mNodeInfoProvider.Stop(); !err.IsNone()) {
LOG_ERR() << "Can't stop node info provider" << Log::Field(err);
}
});

err = mMonitoring.Start();
AOS_ERROR_CHECK_AND_THROW(err, "can't start monitoring");

mCleanupManager.AddCleanup([this]() {
if (auto err = mMonitoring.Stop(); !err.IsNone()) {
LOG_ERR() << "Can't stop monitoring" << Log::Field(err);
}
});

err = mImageManager.Start();
AOS_ERROR_CHECK_AND_THROW(err, "can't start image manager");

mCleanupManager.AddCleanup([this]() {
if (auto err = mImageManager.Stop(); !err.IsNone()) {
LOG_ERR() << "Can't stop image manager" << Log::Field(err);
}
});

err = mLauncher.Start();
AOS_ERROR_CHECK_AND_THROW(err, "can't start launcher");

mCleanupManager.AddCleanup([this]() {
if (auto err = mLauncher.Stop(); !err.IsNone()) {
LOG_ERR() << "Can't stop launcher" << Log::Field(err);
}
});

err = mSMController.Start();
AOS_ERROR_CHECK_AND_THROW(err, "can't start SM controller");

mCleanupManager.AddCleanup([this]() {
if (auto err = mSMController.Stop(); !err.IsNone()) {
LOG_ERR() << "Can't stop SM controller" << Log::Field(err);
}
});

err = mUpdateManager.Start();
AOS_ERROR_CHECK_AND_THROW(err, "can't start update manager");

mCleanupManager.AddCleanup([this]() {
if (auto err = mUpdateManager.Stop(); !err.IsNone()) {
LOG_ERR() << "Can't stop update manager" << Log::Field(err);
}
});

err = mCommunication.Start();
AOS_ERROR_CHECK_AND_THROW(err, "can't start communication");

mCleanupManager.AddCleanup([this]() {
if (auto err = mCommunication.Stop(); !err.IsNone()) {
LOG_ERR() << "Can't stop communication" << Log::Field(err);
}
});
}

void AosCore::Stop()
{
mCleanupManager.ExecuteCleanups();
}

void AosCore::SetLogBackend(common::logger::Logger::Backend backend)
{
mLogger.SetBackend(backend);
}

void AosCore::SetLogLevel(LogLevel level)
{
mLogger.SetLogLevel(level);
}

/***********************************************************************************************************************
* Private
**********************************************************************************************************************/

void AosCore::InitDatabase()
{
database::Config config;

config.mWorkingDir = mConfig.mWorkingDir;
config.mMigrationPath = mConfig.mMigration.mMigrationPath;
config.mMergedMigrationPath = mConfig.mMigration.mMergedMigrationPath;

auto err = mDatabase.Init(config);
AOS_ERROR_CHECK_AND_THROW(err, "can't initialize database");
}

void AosCore::InitStorageState()
{
mFSWatcher.Init(Time::cMinutes, 10 * Time::cSeconds, {fs::FSEventEnum::eModify});

storagestate::Config config;

auto err = config.mStateDir.Assign(mConfig.mStateDir.c_str());
AOS_ERROR_CHECK_AND_THROW(err, "can't assign state dir to storage state config");

err = config.mStorageDir.Assign(mConfig.mStorageDir.c_str());
AOS_ERROR_CHECK_AND_THROW(err, "can't assign storage dir to storage state config");

err = mStorageState.Init(config, mDatabase, mCommunication, mPlatformFS, mFSWatcher, mCryptoProvider);
AOS_ERROR_CHECK_AND_THROW(err, "can't initialize storage state");
}

void AosCore::InitSMController()
{
smcontroller::Config config;

config.mCACert = mConfig.mCACert;
config.mCertStorage = mConfig.mCertStorage;
config.mCMServerURL = mConfig.mCMServerURL;

auto err = mSMController.Init(config, mCommunication, mIAMClient, mCertLoader, mCryptoProvider, mCommunication,
mAlerts, mCommunication, mCommunication, mMonitoring, mLauncher, mNodeInfoProvider);
AOS_ERROR_CHECK_AND_THROW(err, "can't initialize SM controller");
}

} // namespace aos::cm::app
Loading
Loading