Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

feat/ota-4174/direct ostree update of IP Secondary #1500

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ Our versioning scheme is `YEAR.N` where `N` is incremented whenever a new releas

## [??? (unreleased)]

### Added

- Ostree update on IP Secondaries: [PR](https://github.com/advancedtelematic/aktualizr/pull/1500)

## [2019.11] - 2019-12-12

### Added
Expand Down
1 change: 1 addition & 0 deletions src/aktualizr_get/get.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "get.h"
#include "crypto/keymanager.h"
#include "http/httpclient.h"
#include "storage/invstorage.h"

std::string aktualizrGet(Config &config, const std::string &url) {
auto storage = INvStorage::newStorage(config.storage);
Expand Down
12 changes: 6 additions & 6 deletions src/aktualizr_primary/secondary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ class SecondaryWaiter {

LOG_INFO << "Accepted connection from a secondary: (" << sec_ip << ":" << sec_port << ")";
try {
auto sec_creation_res = Uptane::IpUptaneSecondary::create(sec_ip, sec_port, con_socket_.native_handle());
if (sec_creation_res.first) {
connected_secondaries_.push_back(sec_creation_res.second);
auto sec = Uptane::IpUptaneSecondary::create(sec_ip, sec_port, con_socket_.native_handle());
if (sec != nullptr) {
connected_secondaries_.push_back(sec);
}
} catch (const std::exception& exc) {
LOG_ERROR << "Failed to initialize a secondary: " << exc.what();
Expand Down Expand Up @@ -146,9 +146,9 @@ static Secondaries createIPSecondaries(const IPSecondariesConfig& config) {
SecondaryWaiter sec_waiter{config.secondaries_wait_port, config.secondaries_timeout_s, result};

for (auto& ip_sec_cfg : config.secondaries_cfg) {
auto sec_creation_res = Uptane::IpUptaneSecondary::connectAndCreate(ip_sec_cfg.ip, ip_sec_cfg.port);
if (sec_creation_res.first) {
result.push_back(sec_creation_res.second);
auto sec = Uptane::IpUptaneSecondary::connectAndCreate(ip_sec_cfg.ip, ip_sec_cfg.port);
if (sec != nullptr) {
result.push_back(sec);
} else {
sec_waiter.addSecondary(ip_sec_cfg.ip, ip_sec_cfg.port);
}
Expand Down
59 changes: 31 additions & 28 deletions src/aktualizr_secondary/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
set(AKTUALIZR_SECONDARY_SRC main.cc)

set(AKTUALIZR_SECONDARY_LIB_SRC
update_agent_file.cc
aktualizr_secondary.cc
aktualizr_secondary_config.cc
aktualizr_secondary_common.cc
aktualizr_secondary_metadata.cc
socket_server.cc
)
secondary_tcp_server.cc
aktualizr_secondary_factory.cc)

# do not link tests with libaktualizr
list(REMOVE_ITEM TEST_LIBS aktualizr_lib)
Expand All @@ -26,18 +26,19 @@ add_library(aktualizr_secondary_lib SHARED
$<TARGET_OBJECTS:utilities>
$<TARGET_OBJECTS:storage>
$<TARGET_OBJECTS:logging>
$<TARGET_OBJECTS:uptane>)
$<TARGET_OBJECTS:uptane>
$<TARGET_OBJECTS:campaign>)
target_link_libraries(aktualizr_secondary_lib ${AKTUALIZR_EXTERNAL_LIBS})
target_include_directories(aktualizr_secondary_lib PUBLIC
$<TARGET_PROPERTY:asn1_lib,INCLUDE_DIRECTORIES>
${PROJECT_SOURCE_DIR}/src/libaktualizr-posix
)
${PROJECT_SOURCE_DIR}/src/libaktualizr-posix)

if (BUILD_ISOTP)
target_sources(aktualizr_secondary_lib PRIVATE $<TARGET_OBJECTS:isotp_conn>)
endif (BUILD_ISOTP)

add_executable(aktualizr-secondary ${AKTUALIZR_SECONDARY_SRC})

target_link_libraries(aktualizr-secondary aktualizr_secondary_lib)
install(TARGETS aktualizr_secondary_lib LIBRARY DESTINATION lib COMPONENT aktualizr)

Expand All @@ -46,45 +47,47 @@ install(TARGETS aktualizr-secondary
RUNTIME DESTINATION bin)

set(ALL_AKTUALIZR_SECONDARY_HEADERS
update_agent.h
update_agent_file.h
aktualizr_secondary.h
aktualizr_secondary_interface.h
aktualizr_secondary_config.h
aktualizr_secondary_common.h
aktualizr_secondary_metadata.h
socket_server.h
)
secondary_tcp_server.h
aktualizr_secondary_factory.h)

include(AddAktualizrTest)

# insert in front, so that the order matches the dependencies to the system libraries
list(INSERT TEST_LIBS 0 aktualizr_secondary_lib)

add_aktualizr_test(NAME aktualizr_secondary_config
SOURCES aktualizr_secondary_config_test.cc PROJECT_WORKING_DIRECTORY LIBRARIES aktualizr_secondary_lib)
SOURCES aktualizr_secondary_config_test.cc PROJECT_WORKING_DIRECTORY)

add_aktualizr_test(NAME aktualizr_secondary_update
SOURCES update_test.cc
ARGS ${PROJECT_BINARY_DIR}/ostree_repo
PROJECT_WORKING_DIRECTORY LIBRARIES aktualizr_secondary_lib)
add_aktualizr_test(NAME secondary_tcp_server
SOURCES secondary_tcp_server_test.cc PROJECT_WORKING_DIRECTORY)

if(BUILD_OSTREE)
add_aktualizr_test(NAME aktualizr_secondary_uptane_verification
SOURCES uptane_verification_test.cc
ARGS ${PROJECT_BINARY_DIR}/ostree_repo
LIBRARIES aktualizr_secondary_lib uptane_generator_lib $<TARGET_OBJECTS:campaign>
PROJECT_WORKING_DIRECTORY )

set_target_properties(t_aktualizr_secondary_uptane_verification PROPERTIES LINK_FLAGS -Wl,--export-dynamic)
target_link_libraries(t_aktualizr_secondary_uptane_verification aktualizr_secondary_lib uptane_generator_lib)

add_aktualizr_test(NAME aktualizr_secondary_uptane
SOURCES uptane_test.cc
LIBRARIES aktualizr_secondary_lib uptane_generator_lib virtual_secondary $<TARGET_OBJECTS:campaign> $<TARGET_OBJECTS:primary> $<TARGET_OBJECTS:http>
target_sources(aktualizr_secondary_lib PRIVATE update_agent_ostree.cc)
list(APPEND AKTUALIZR_SECONDARY_LIB_SRC update_agent_ostree.cc)
list(APPEND ALL_AKTUALIZR_SECONDARY_HEADERS update_agent_ostree.h)

add_aktualizr_test(NAME aktualizr_secondary_ostree SOURCES aktualizr_secondary_ostree_test.cc
ARGS ${PROJECT_BINARY_DIR}/ostree_repo PROJECT_WORKING_DIRECTORY)

set_target_properties(t_aktualizr_secondary_ostree PROPERTIES LINK_FLAGS -Wl,--export-dynamic)
target_link_libraries(t_aktualizr_secondary_ostree aktualizr_secondary_lib uptane_generator_lib)

else(BUILD_OSTREE)
list(APPEND TEST_SOURCES uptane_verification_test.cc uptane_test.cc)
list(APPEND TEST_SOURCES aktualizr_secondary_ostree_test.cc update_agent_ostree.cc)
list(APPEND ALL_AKTUALIZR_SECONDARY_HEADERS update_agent_ostree.h)
endif(BUILD_OSTREE)

add_aktualizr_test(NAME aktualizr_secondary
SOURCES aktualizr_secondary_test.cc
PROJECT_WORKING_DIRECTORY)

target_link_libraries(t_aktualizr_secondary aktualizr_secondary_lib uptane_generator_lib)

# test running the executable with command line option --help
add_test(NAME aktualizr_secondary_cmdline--help COMMAND aktualizr-secondary --help)
# test running the executable with command line option --something
Expand Down
Loading