Skip to content

Commit 145d5ee

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

File tree

6 files changed

+396
-182
lines changed

6 files changed

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

src/core/cm/imagemanager/imageprovider.hpp

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

0 commit comments

Comments
 (0)