Update module is the service within the Agent responsible to deal with software update.
The Update module is only available on Linux devices.
Update module expects that Agent is run in working directory with no ' character in it.
The Update module can:
init()
Init the Update module
Mandatory to be called before doing any update, or calling any other
API.
This function is called by the agent on boot when Update is activated in
agent config.
getstatus(sync)
Retrieves the status of the last update done or the status of current
update is an update is in progress.
Using the sync parameter, the function can be requested to be blocking
to wait for the end of current update if any.
Returns:
- "in_progress" if an update is in progress but blocking behavior was
not requested
- "ok" in case of success of the last update process
- nil, error string describing the error that happened during
processing the last update.
localupdate(path, sync)
Triggers an update using a local file as update package. The local file
to use can given as parameter or will be pick in drop folder.
Using the sync parameter, the function can be requested to be blocking
to wait for the end of the whole update process.
Returns:
- "in_progress" if the package was accepted (package analysis
returned no error) but blocking behavior was not requested
- "ok" in case of success of the whole update process if blocking
behavior was requested
- nil, error string describing the error that happened while doing the
update (an error can appear either before or during package analysis
or during package processing if blocking behavior was requested)
Those data tables contain a great part of the state of the Update module.
There are ways to access them:
local updatec = require"agent.update.common"
p(updatec.data.swlist)
...
-- data.swlist.lastupdatestatus= (integer) result code of last update job
-- data.swlist.lastupdateerrstr= (string) description of the error (if any) for last update
-- data.swlist.components: (table) contains "installed"/"provisionned" software components
-- data.swlist.components[uid] (table) contains the description of a component
-- data.swlist.components[uid].name: string
-- data.swlist.components[uid].uid: unique id of the component
-- data.swlist.components[uid].version (string) version of this component
-- data.swlist.components[uid].provides (table) with features provided by this components
-- data.swlist.components[uid].depends (table) with features/components needed by this components
-- data.swlist.components[uid].parameters: (table) with parameters given in update package at install time
-- data.swlist.components[uid].force (boolean) whether this component was installed using dependency checking
Here is a small sample:
:updatec.data.swlist
{
lastupdatestatus = 200,
appuid = 7,
components = {
[0] = {
uid = 0,
name = "platform",
force = true,
provides = {
RadioHardware = "MC8705",
Agent = "0.7 - Build: 7063",
AleosSoftware = "4.2.5.005",
AleosHardware = "12180306000700000000000000000000",
RadioSoftware = "T1_0_4_3CAP R460 CNSZXD00000128 2011/11/15 10:22:30" },
version = "N/A" },
[7] = {
version = "testversion",
uid = 7,
name = "@sys.appcon.serial_modbus_test",
parameters = {
purge = false,
autostart = true } } },
lastupdateerrstr = "All components successfuly updated" }
The Update module can use several protocol to retrieve update package.
See SoftwareUpdate command in Device Management commands
They must conform with Software Update Package Format.
The workflow is quite simple, and can be illustrated like this:
The following sections give more details about each step.
SoftwareUpdate command description in Device Management commands gives some clues, but package hosting is still to be defined.
When some Software Update Package has been downloaded, Update module will be alerted and then:
If the update package seems correctly built, the Update module can process with each update.
This means that Update module will alert all the components responsible for processing each update.
There is two types of update, the target path will be used to differentiate them:
Rq. Choice of update type may be done on a case by case basis. For example, OSGI bundle update is likely to be done with type #2 because OSGI framework is responsible to update OSGI bundles.
As previously stated, Update module forward the update of each component to asset application or install script execution.
Those information can be useful to develop the application or the install script
The aims of those retries and timeout is:
In order to achieve those goals, there are the mechanisms used for retries and timeout:
The retry number and the timeout duration can be configured using update configuration table.
The update will be successful only if all components are correctly updated; so if any of the component update failed, the whole update job is failed.
If an component update fails before the end:
When an error occurs, the Update module will try to forward the error description the server, depending on the realm of possibilities of the protocol that provided the update.
Finally, when Update module can compute the overall result of the update, it will report it to the server using the appropriate protocol.
The install script functionality is triggered when an update package contains a component with package field beginning by "@sys.update." like "@sys.update.packagename".
Note: This feature will define/reference a Component that like any other Component:
Some constraints about install script with
example of update package with embedded install script.
$ ls -la package/
-rw-r--r-- 1 lbarthelemy lbarthelemy 0 2009-10-29 17:30 Manifest
drwxr-xr-x 2 lbarthelemy lbarthelemy 4096 2009-10-29 17:28 HouseApp
$ cat Manifest
local update = {}
update.version = "1.2"
update.components = {
{
name = "@sys.update.HouseApp",
location = "HouseApp",
version = 1.2
}
...
}
$ ls -la HouseApp/
-rwxr--r-- 1 lbarthelemy lbarthelemy 0 2009-10-29 17:30 run
-rw-r--r-- 1 lbarthelemy lbarthelemy 0 2009-10-29 17:30 HouseApp
-rw-r--r-- 1 lbarthelemy lbarthelemy 0 2009-10-29 17:30 another_file
-rw-r--r-- 1 lbarthelemy lbarthelemy 0 2009-10-29 17:29 install.lua -> THIS IS THE FILE that will used as install script
drwxr-xr-x 2 lbarthelemy lbarthelemy 4096 2009-10-29 17:28 some_data
The update script will be run in the Agent environment, with access to all functionalities.
Furthermore, some info will be provided in a table as parameter of the script to ease the development of the script:
This Lua code can be put in an install.lua file in an update package.
-- retrieve parameter giving access to some info
local param = ...
local res,err = some_custom_action_to_do(param.script_dir)
-- check error and report it using error function
if not res then error("Error while running install scrip:"..(err or "nil")) end
--else success
Basic Idea: running an update job using an update package copied on the target by the user. No need to do M3DA Command implying Platform services server.
Expected usage: Initial Agent configuration, ...
localupdate()
WARNING
Don't set config update.localpkgname parameter with a name that contains ' character, if so the update will fail at update checking step.
FAQ:
INFO
This Manifest file should work with out of the box (i.e. from git) Agent with correct defaulconfig.lua file
-- Global information
{
version = "YourInitialVersionHere",
-- Components information
components = {
{
name = "@sys.update.startupconfig",
location = "/scripts",
version = "componentInitialVersion"
}
} -- end of Components information
} -- end of Manifest
Those codes are the error code returned by the update module.
Those codes will also be used to acknowledge
error code | error cause | Meaning |
---|---|---|
450 | Invalid update file name | The absolute path of update file contains a bad character " ' " |
451 | Cannot parse the update file name correctly | The absolute path of update file isn't in good format |
452 | Cannot create folder to extract update package | |
453 | Cannot extract update package | |
454 | Cannot open manifest file | Cannot open or find manifest file |
455 | Cannot read manifest file | The manifest file cannot be read |
456 | Cannot load manifest chunk | Cannot load the manifest file as Lua a chunk |
457 | Manifest file is not valid lua file | There are syntaxe lua error in the manifest file |
458 | Manifest file doesn't returns a table but | The loading and executing manifest file doesn't return a Lua table |
459 | Dependency error for a component | This kind of error is detected by checking the dependency of the component in the manifest file: it has to match installed software |
460 | Package protect failed | |
479 | Manifest error | This error is detected by checking the dependency, version, provide, format... of the components in the manifest file. It includes the error code number 459 |
error code | error cause | Meaning |
---|---|---|
461 | Too much retries for component | Cannot send EMP commands to component (unexisting component) or component doesn't return a response. |
462 | SoftwareUpdate command was not correctly executed by asset | The EMP SoftwareUpdate cmd was not correctly accepted/executed by asset |
463 | Alertnextcomponent error | Error while alerting the asset: e.g. the asset is not connected |
464 | Cannot find folder or manifest file of current update | Cannot find folder or manifest file while starting dispatch the components from current update |
465 | Update step is not successfully finished | Cannot find the result code error while doing update steps |
471 | User update callback failed | Asset : The user callback function is failed, a non-integrer number is returned in the callback function |
472 | No User update callback set | Asset : No user update callback function is set |
600 | Update aborted by user request | Asset application used update request API to abort the update |
error code | error cause | Meaning |
---|---|---|
473 | Update path is not valid | dispatch updators : update path is not valid |
473 | Sub path is not valid | dispatch updators : sub path update is not valid (no shortcut matching the path) |
474 | install.lua file does not exist | installscript updators : there is any install.lua file in given location |
475 | Cannot load install.lua script | installscript updators : cannot load install.lua script |
476 | Script execution error | installscript updators : cannot execute install.lua script |
477 | ApplicationContainer is not activated | appcon Updator: ApplicationContainer updater cannot be run because ApplicationContainer is not activated |
478 | ApplicationContainer updater result | appcon Updator: ApplicationContainer updater failed while installing/uninstalling applications |
error code | error cause | Meaning |
---|---|---|
-1 | Update module is not activated | Activation of update module can be done in RA configuration 'agent.config.update.activate' (true or false) |
551 | Wrong params in SoftwareUpdate command | Need package url and package signature in SoftwareUpdate command |
552 | Error while doing http request | Error while doing http request to download update package |
553 | Signature mismatch for update archive | The md5 signature of package is different before and after download |
554 | Bad update informations | The url of package or signature of package is not valid |
555 | Not enough free space to download package | |
556 | invalid current update | Current update or protocol setting is not valid |
557 | unsupported protocol | The 'localupdate' or 'm3da' protocol is not found |
558 | Update rejected by update module | SoftwareUpdate command tries to notify a new available update to module update, but this command is rejected |
error code | error cause | Meaning |
---|---|---|
501 | Cannot get free space on device | |
502 | Not enough space to extract package | |
503 | Cannot get the number of files in package | |
504 | Cannot get the size of package without extracting it | |
505 | Malformed update data | Malformed update data: unknown internal error |
506 | Other update was already in progress | Other update was already in progress, only one update at the same time, new update is rejected |
489 -> 499 | project dependent error | These numbers represent errors in according to projets of clients, they are defined by application clients |