Skip to content

Commit a105d9b

Browse files
committed
cm: imagemanager: add initial image manager interfaces and doc
Signed-off-by: Oleksandr Grytsov <[email protected]>
1 parent 05356bc commit a105d9b

File tree

5 files changed

+371
-152
lines changed

5 files changed

+371
-152
lines changed

src/core/cm/imagemanager/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ set(TARGET_NAME imagemanager)
1414
# Headers
1515
# ######################################################################################################################
1616

17-
set(HEADERS imageprovider.hpp)
17+
set(HEADERS itf/updateitemlisterner.hpp)
1818

1919
# ######################################################################################################################
2020
# Target
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
# Image manager
2+
3+
Image manager stores update item images and provide update item image info for other modules.
4+
5+
It implements the following interfaces:
6+
7+
* [aos::cm::imagemanager::ImageMangerItf]() - image manager to manage update items images;
8+
* [aos::cm::imagemanager::UpdateItemNotifierItf]() - update item notifier to notify other modules about update items;
9+
* [aos::cm::launcher::ImageInfoProviderItf]() - update item provider for [launcher]() module;
10+
action.
11+
12+
It requires the following interfaces:
13+
14+
* TODO: add required interfaces.
15+
16+
```mermaid
17+
classDiagram
18+
class ImageManager["aos::cm::imagemanager::ImageManager"] {
19+
}
20+
21+
class ImageManagerItf["aos::cm::imagemanager::ImageMangerItf"] {
22+
<<interface>>
23+
}
24+
25+
class UpdateItemNotifierItf ["aos::cm::imagemanager::UpdateItemNotifierItf"] {
26+
<<interface>>
27+
}
28+
29+
class ImageInfoProviderItf ["aos::cm::launcher::ImageInforProviderItf"] {
30+
<<interface>>
31+
}
32+
33+
ImageManager <|.. ImageManagerItf
34+
ImageManager <|.. UpdateItemNotifierItf
35+
ImageManager <|.. ImageInfoProviderItf
36+
```
37+
38+
## Initialization
39+
40+
During initialization:
41+
42+
* verifies integrity of each item and removes corrupted or not fully installed items;
43+
* removes outdated items.
44+
45+
## Removing outdated items
46+
47+
Image manager has configuration parameter that indicates how long cached update items should be stored on file system.
48+
If update item is in cached state more than configured timeout, this item should be completely removed from the unit.
49+
50+
For this purpose, image manager checks and removes outdated items during initialization and also performs periodic check
51+
for outdated items (with subsequent removal).
52+
53+
## aos::cm::imagemanager::ImageMangerItf
54+
55+
### GetUpdateItemsStatuses
56+
57+
Returns currently installed images statuses for each update item. It returns only active update items versions.
58+
59+
### InstallUpdateItem
60+
61+
Installs update item images.
62+
63+
This method performs the following actions:
64+
65+
* decrypts update item images and verifies signature;
66+
* unpacks certain update item types images in order to retrieve metadata or/and modify it and store it in the internal
67+
storage. It is required to provide frequently used data to other modules;
68+
* cached outdate items for revert purpose;
69+
* if case when installation of any desired update item image fails, error with corresponding update item status is
70+
returned and all artifacts of this update item version are removed from file system.
71+
72+
This method maintains update item versions as following:
73+
74+
* if there is no such update item already installed, this update item is installed normally;
75+
* if there is already such update item installed then versions of installed and requested update items compares and next
76+
actions are performed based on version comparison result:
77+
* if requested item version is less than installed item version, version mismatch error is returned;
78+
* if requested item version equals to installed item version and requested item images differ from installed item
79+
images, then differ requested images should be installed over existing differ images. Otherwise, no action is
80+
performed and installed status for all images is returned;
81+
* if requested item version is greater than installed item version, requested item is installed normally and then
82+
existing item is marked as cached. It is required to perform update item revert. If there are cached version of this
83+
item before install, this item version is completely removed from file system before install requested one. Image
84+
manager doesn't keep more than two versions (one active and one cached) of the same item at the same time;
85+
* if there is already such update item installed but in cached state, then versions of cached and requested update
86+
items compares and next actions are performed based on version comparison result:
87+
* if version of cached item is less than requested item version, requested item version is installed normally;
88+
* if version of cached item equals to requested item version, cached version becomes active if all images of cached
89+
item are identical to all images of requested item. Otherwise, images are updated and item becomes active;
90+
* if version of cached item is grated then requested then cached item is removed and requested item normally
91+
installed.
92+
93+
### UninstallUpdateItem
94+
95+
Uninstalls update item images.
96+
97+
This method performs the following actions:
98+
99+
* mark requested update item as cached. If there is already cached version of the requested item, the cached version is
100+
removed in order to have only one cached version of update item at the same time.
101+
102+
### RevertUpdateItem
103+
104+
Reverts update item images.
105+
106+
This method performs the following actions:
107+
108+
* if there is active and cached version of requested item, active version is removed from file system and cached version
109+
is marked as active;
110+
* if there is only active version of requested item, it is remove from file system;
111+
* if there is only cached version of requested item, `not found` error is returned.
112+
113+
## aos::cm::imagemanager::UpdateItemNotifierItf
114+
115+
Notifies subscribers about changing update item states.
116+
117+
### SubscribeListener
118+
119+
Subscribes to changing update item states.
120+
121+
### UnsubscribeListener
122+
123+
Unsubscribes from changing update item states.
124+
125+
## aos::cm::imagemanager::UpdateItemListenerItf
126+
127+
### OnUpdateItemRemoved
128+
129+
This method is called for each registered listener when specified update item is completely removed from file system.
130+
It is required to perform cleanup operation by other modules e.g. remove associated instances etc.
131+
It is not called when update item becomes cached.
132+
133+
## aos::cm::launcher::ImageInfoProviderItf
134+
135+
### GetItemImages
136+
137+
Returns list of images infos for specified update item. The image info contains such information as image ID, platform
138+
info, URL to download, size, checksum etc.
139+
140+
### GetServiceConfig
141+
142+
Returns service config for specified update item image. The item should be the service type. For other types `not found`
143+
is returned.
144+
145+
### GetImageConfig
146+
147+
Returns image config for specified update item image. The item should be the service type. For other types `not found`
148+
is returned.

src/core/cm/imagemanager/imageprovider.hpp

Lines changed: 0 additions & 151 deletions
This file was deleted.

0 commit comments

Comments
 (0)