-
Notifications
You must be signed in to change notification settings - Fork 392
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5922 from bvanav648/RDK-53740-MigrationPreparer-x…
…umo4 New Thunder Plugin - MigrationPreparer
- Loading branch information
Showing
15 changed files
with
1,750 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
All notable changes to this RDK Service will be documented in this file. | ||
|
||
Each RDK Service has a CHANGELOG file that contains all changes done so far. When version is updated, add a entry in the CHANGELOG.md at the top with user friendly information on what was changed with the new version. Please don't mention JIRA tickets in CHANGELOG. | ||
|
||
Please Add entry in the CHANGELOG for each version change and indicate the type of change with these labels: | ||
Added for new features. | ||
Changed for changes in existing functionality. | ||
Deprecated for soon-to-be removed features. | ||
Removed for now removed features. | ||
Fixed for any bug fixes. | ||
Security in case of vulnerabilities. | ||
|
||
Changes in CHANGELOG should be updated when commits are added to the main or release branches. There should be one CHANGELOG entry per JIRA Ticket. This is not enforced on sprint branches since there could be multiple changes for the same JIRA ticket during development. | ||
|
||
For more details, refer to versioning section under Main README. | ||
|
||
## [1.0.0] - 2024-12-01 | ||
### Added | ||
- New RDK Service MigrationPreparer to aid the Data Harvesting process, where it exposes APIs to applications such as ResidentApp and others to store user settings in a standardized format (as a JSON file) suitable for EntOS consumption. The MigrationPreparer Thunder plugin will exist only in the RDKV ecosystem. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# If not stated otherwise in this file or this component's LICENSE file the | ||
# following copyright and licenses apply: | ||
# | ||
# Copyright 2024 RDK Management | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set(PLUGIN_NAME MigrationPreparer) | ||
set(MODULE_NAME ${NAMESPACE}${PLUGIN_NAME}) | ||
set(PLUGIN_IMPLEMENTATION ${MODULE_NAME}Implementation) | ||
|
||
set(PLUGIN_MIGRATIONPREPARER_AUTOSTART "true" CACHE STRING "Automatically start MigrationPreparer plugin") | ||
set(PLUGIN_MIGRATIONPREPARER_STARTUPORDER "" CACHE STRING "To configure startup order of MigrationPreparer plugin") | ||
set(PLUGIN_MIGRATIONPREPARER_MODE "Off" CACHE STRING "Controls if the plugin should run in process or out of process") | ||
|
||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") | ||
|
||
find_package(${NAMESPACE}Plugins REQUIRED) | ||
find_package(${NAMESPACE}Definitions REQUIRED) | ||
find_package(CompileSettingsDebug CONFIG REQUIRED) | ||
|
||
add_library(${MODULE_NAME} SHARED | ||
MigrationPreparer.cpp | ||
MigrationPreparerJsonRpc.cpp | ||
Module.cpp) | ||
|
||
set_target_properties(${MODULE_NAME} PROPERTIES | ||
CXX_STANDARD 11 | ||
CXX_STANDARD_REQUIRED YES) | ||
|
||
target_link_libraries(${MODULE_NAME} | ||
PRIVATE | ||
CompileSettingsDebug::CompileSettingsDebug | ||
${NAMESPACE}Plugins::${NAMESPACE}Plugins | ||
${NAMESPACE}Definitions::${NAMESPACE}Definitions) | ||
|
||
install(TARGETS ${MODULE_NAME} | ||
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/${STORAGE_DIRECTORY}/plugins) | ||
|
||
set_target_properties(${MODULE_NAME} PROPERTIES | ||
CXX_STANDARD 11 | ||
CXX_STANDARD_REQUIRED YES) | ||
|
||
target_include_directories(${MODULE_NAME} PRIVATE ../helpers) | ||
target_include_directories(${MODULE_NAME} PRIVATE ../common) | ||
target_include_directories(${MODULE_NAME} PRIVATE ./) | ||
|
||
add_library(${PLUGIN_IMPLEMENTATION} SHARED | ||
MigrationPreparerImplementation.cpp | ||
Module.cpp) | ||
|
||
set_target_properties(${PLUGIN_IMPLEMENTATION} PROPERTIES | ||
CXX_STANDARD 11 | ||
CXX_STANDARD_REQUIRED YES) | ||
|
||
target_include_directories(${PLUGIN_IMPLEMENTATION} PRIVATE ../helpers) | ||
target_include_directories(${PLUGIN_IMPLEMENTATION} PRIVATE ../common) | ||
target_include_directories(${PLUGIN_IMPLEMENTATION} PRIVATE ./) | ||
|
||
# if (RDK_SERVICE_L2_TEST) | ||
# find_library(TESTMOCKLIB_LIBRARIES NAMES TestMocklib) | ||
# if (TESTMOCKLIB_LIBRARIES) | ||
# message ("linking mock libraries ${TESTMOCKLIB_LIBRARIES} library") | ||
# target_link_libraries(${PLUGIN_IMPLEMENTATION} PRIVATE ${TESTMOCKLIB_LIBRARIES}) | ||
# else (TESTMOCKLIB_LIBRARIES) | ||
# message ("Require ${TESTMOCKLIB_LIBRARIES} library") | ||
# endif (TESTMOCKLIB_LIBRARIES) | ||
# endif (RDK_SERVICES_L2_TEST) | ||
|
||
target_link_libraries(${PLUGIN_IMPLEMENTATION} | ||
PRIVATE | ||
CompileSettingsDebug::CompileSettingsDebug | ||
${NAMESPACE}Plugins::${NAMESPACE}Plugins | ||
${RBUS_LIBRARIES}) | ||
|
||
install(TARGETS ${PLUGIN_IMPLEMENTATION} | ||
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/${STORAGE_DIRECTORY}/plugins) | ||
|
||
write_config(${PLUGIN_NAME}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
callsign = "org.rdk.MigrationPreparer" | ||
precondition = ["Platform"] | ||
autostart = "@PLUGIN_MIGRATIONPREPARER_AUTOSTART@" | ||
startuporder = "@PLUGIN_MIGRATIONPREPARER_STARTUPORDER@" | ||
|
||
configuration = JSON() | ||
|
||
rootobject = JSON() | ||
rootobject.add("mode", "@PLUGIN_MIGRATIONPREPARER_MODE@") | ||
rootobject.add("locator", "lib@[email protected]") | ||
configuration.add("root", rootobject) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
set(autostart ${PLUGIN_MIGRATIONPREPARER_AUTOSTART}) | ||
set(preconditions Platform) | ||
|
||
if(PLUGIN_MIGRATIONPREPARER_STARTUPORDER) | ||
set (startuporder ${PLUGIN_MIGRATIONPREPARER_STARTUPORDER}) | ||
endif() | ||
|
||
map() | ||
key(root) | ||
map() | ||
kv(mode ${PLUGIN_MIGRATIONPREPARER_MODE}) | ||
kv(locator lib${PLUGIN_IMPLEMENTATION}.so) | ||
end() | ||
end() | ||
ans(configuration) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
/* | ||
* If not stated otherwise in this file or this component's LICENSE file the | ||
* following copyright and licenses apply: | ||
* | ||
* Copyright 2024 RDK Management | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "MigrationPreparer.h" | ||
|
||
#define API_VERSION_NUMBER_MAJOR 1 | ||
#define API_VERSION_NUMBER_MINOR 0 | ||
#define API_VERSION_NUMBER_PATCH 0 | ||
|
||
namespace WPEFramework | ||
{ | ||
|
||
namespace { | ||
|
||
static Plugin::Metadata<Plugin::MigrationPreparer> metadata( | ||
// Version (Major, Minor, Patch) | ||
API_VERSION_NUMBER_MAJOR, API_VERSION_NUMBER_MINOR, API_VERSION_NUMBER_PATCH, | ||
// Preconditions | ||
{}, | ||
// Terminations | ||
{}, | ||
// Controls | ||
{} | ||
); | ||
} | ||
|
||
namespace Plugin | ||
{ | ||
|
||
/* | ||
*Register MigrationPreparer module as wpeframework plugin | ||
**/ | ||
SERVICE_REGISTRATION(MigrationPreparer, API_VERSION_NUMBER_MAJOR, API_VERSION_NUMBER_MINOR, API_VERSION_NUMBER_PATCH); | ||
|
||
MigrationPreparer::MigrationPreparer() : _service(nullptr), _connectionId(0), _migrationPreparer(nullptr) | ||
{ | ||
SYSLOG(Logging::Startup, (_T("MigrationPreparer Constructor"))); | ||
RegisterAll(); | ||
} | ||
|
||
MigrationPreparer::~MigrationPreparer() | ||
{ | ||
SYSLOG(Logging::Shutdown, (string(_T("MigrationPreparer Destructor")))); | ||
UnregisterAll(); | ||
} | ||
|
||
const string MigrationPreparer::Initialize(PluginHost::IShell* service) | ||
{ | ||
string message=""; | ||
|
||
ASSERT(nullptr != service); | ||
ASSERT(nullptr == _service); | ||
ASSERT(nullptr == _migrationPreparer); | ||
ASSERT(0 == _connectionId); | ||
|
||
SYSLOG(Logging::Startup, (_T("MigrationPreparer::Initialize: PID=%u"), getpid())); | ||
|
||
_service = service; | ||
_service->AddRef(); | ||
_migrationPreparer = _service->Root<Exchange::IMigrationPreparer>(_connectionId, 5000, _T("MigrationPreparerImplementation")); | ||
|
||
if(nullptr == _migrationPreparer) | ||
{ | ||
SYSLOG(Logging::Startup, (_T("MigrationPreparer::Initialize: Failed to initialise MigrationPreparer plugin"))); | ||
message = _T("MigrationPreparer plugin could not be initialised"); | ||
} | ||
|
||
if (0 != message.length()) | ||
{ | ||
Deinitialize(service); | ||
} | ||
|
||
return message; | ||
} | ||
|
||
void MigrationPreparer::Deinitialize(PluginHost::IShell* service) | ||
{ | ||
ASSERT(_service == service); | ||
|
||
SYSLOG(Logging::Shutdown, (string(_T("MigrationPreparer::Deinitialize")))); | ||
|
||
if (nullptr != _migrationPreparer) | ||
{ | ||
// Stop processing: | ||
RPC::IRemoteConnection* connection = service->RemoteConnection(_connectionId); | ||
VARIABLE_IS_NOT_USED uint32_t result = _migrationPreparer->Release(); | ||
|
||
_migrationPreparer = nullptr; | ||
|
||
// It should have been the last reference we are releasing, | ||
// so it should endup in a DESTRUCTION_SUCCEEDED, if not we | ||
// are leaking... | ||
ASSERT(result == Core::ERROR_DESTRUCTION_SUCCEEDED); | ||
|
||
// If this was running in a (container) process... | ||
if (nullptr != connection) | ||
{ | ||
// Lets trigger the cleanup sequence for | ||
// out-of-process code. Which will guard | ||
// that unwilling processes, get shot if | ||
// not stopped friendly :-) | ||
connection->Terminate(); | ||
connection->Release(); | ||
} | ||
} | ||
|
||
_connectionId = 0; | ||
_service->Release(); | ||
_service = nullptr; | ||
SYSLOG(Logging::Shutdown, (string(_T("MigrationPreparer de-initialised")))); | ||
} | ||
|
||
string MigrationPreparer::Information() const | ||
{ | ||
return (string("{\"service\": \"") + string("org.rdk.MigrationPreparer") + string("\"}")); | ||
} | ||
|
||
} // namespace Plugin | ||
} // namespace WPEFramework |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
* If not stated otherwise in this file or this component's LICENSE file the | ||
* following copyright and licenses apply: | ||
* | ||
* Copyright 2024 RDK Management | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "Module.h" | ||
#include <interfaces/json/JsonData_MigrationPreparer.h> | ||
#include <interfaces/json/JMigrationPreparer.h> | ||
#include <interfaces/IMigrationPreparer.h> | ||
#include "UtilsLogging.h" | ||
#include "tracing/Logging.h" | ||
#include "UtilsJsonRpc.h" | ||
#include <mutex> | ||
|
||
// PLUGIN SPECIFIC CUSTOM ERROR CODES | ||
#define ERROR_CREATE 4 | ||
#define ERROR_OPEN 5 | ||
#define ERROR_WRITE 6 | ||
#define ERROR_NAME 7 | ||
#define ERROR_DELETE 8 | ||
#define ERROR_SET 9 | ||
#define ERROR_RESET 10 | ||
#define ERROR_INVALID 11 | ||
#define ERROR_NOFILE 12 | ||
#define ERROR_FILEEMPTY 13 | ||
|
||
namespace WPEFramework { | ||
namespace Plugin { | ||
|
||
class MigrationPreparer: public PluginHost::IPlugin, public PluginHost::JSONRPC | ||
{ | ||
public: | ||
// We do not allow this plugin to be copied !! | ||
MigrationPreparer(const MigrationPreparer&) = delete; | ||
MigrationPreparer& operator=(const MigrationPreparer&) = delete; | ||
|
||
MigrationPreparer(); | ||
virtual ~MigrationPreparer(); | ||
|
||
BEGIN_INTERFACE_MAP(MigrationPreparer) | ||
INTERFACE_ENTRY(PluginHost::IPlugin) | ||
INTERFACE_ENTRY(PluginHost::IDispatcher) | ||
INTERFACE_AGGREGATE(Exchange::IMigrationPreparer, _migrationPreparer) | ||
END_INTERFACE_MAP | ||
|
||
// IPlugin methods | ||
// ------------------------------------------------------------------------------------------------------- | ||
const string Initialize(PluginHost::IShell* service) override; | ||
void Deinitialize(PluginHost::IShell* service) override; | ||
string Information() const override; | ||
|
||
private: | ||
void RegisterAll(); | ||
void UnregisterAll(); | ||
|
||
uint32_t endpoint_write(const JsonObject& parameters, JsonObject& response); | ||
uint32_t endpoint_read(const JsonObject& parameters, JsonObject& response); | ||
uint32_t endpoint_delete(const JsonObject& parameters, JsonObject& response); | ||
uint32_t endpoint_getComponentReadiness(const JsonObject& parameters, JsonData::MigrationPreparer::GetcomponentreadinessResultData& response); | ||
uint32_t endpoint_setComponentReadiness(const JsonObject& parameters, JsonObject& response); | ||
uint32_t endpoint_reset(const JsonObject& parameters, JsonObject& response); | ||
|
||
private: | ||
PluginHost::IShell* _service{}; | ||
uint32_t _connectionId{}; | ||
Exchange::IMigrationPreparer* _migrationPreparer{}; | ||
}; | ||
|
||
} // namespace Plugin | ||
} // namespace WPEFramework |
Oops, something went wrong.