activation: Make activation flow common
The activation flow has a lot of duplicate code such as checking
the digital signatures and creating associations, with a few
differences depending on the choice of bmc layout configuration.
This makes the code hard to maintain since changes and additions
to the activation flow need to be done on more than one place, and
also the function becomes bigger and harder to follow. This would
be made worse when additional layout supports are added such as
eMMC code update support.
Make the flow common and move the specific code to its subdirectory.
This requires create a new function to handle the end of the
update so that we support implementations that are async (need to
wait for systemd service files to finish).
Still need an if/else statement to differentiate the implementations
that are synchronous like the static layout and the async ones like
the ubi layout since the async ones have the flash write function
return immediately and can call the flash write success later on,
for the sync ones need to set the activation value to Active after
calling flash write success:
Async (ubi):
activation(Activating)
flashWrite()
return Activating
onFlashWriteSuccess()
activation(Active)
Synchronous (static):
activation(Activating)
flashWrite()
onFlashWriteSuccess()
activation(Active)
return Active
By making the code common, the static layout gains some additional
features which may not be of consequence due to the short duration
of the update, but does not hurt and allow us to remove the if/else
blocks:
- Progress interface
- Blocks transition interface
- Updatable association before reboot is done
The static layout will also subscribe to systemd signals even
though they're not used, but again this is to keep the code as
common as possible.
Tested: Verified code update worked and expected d-bus interfaces
and values were set during ubi and static update.
Change-Id: I20a0b752fe3905cca5b6220c88f65eb64d155d75
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/ubi/flash.cpp b/ubi/flash.cpp
index ffa9348..c58eefc 100644
--- a/ubi/flash.cpp
+++ b/ubi/flash.cpp
@@ -67,11 +67,25 @@
Activation::activation(
softwareServer::Activation::Activations::Failed);
}
- else if ((rwVolumeCreated && roVolumeCreated) || // Volumes were created
- (ubootEnvVarsUpdated)) // Environment variables were updated
+ else if (rwVolumeCreated && roVolumeCreated) // Volumes were created
{
- Activation::activation(
- softwareServer::Activation::Activations::Activating);
+ if (!ubootEnvVarsUpdated)
+ {
+ activationProgress->progress(90);
+
+ // Set the priority which triggers the service that updates the
+ // environment variables.
+ if (!Activation::redundancyPriority)
+ {
+ Activation::redundancyPriority =
+ std::make_unique<RedundancyPriority>(bus, path, *this,
+ 0);
+ }
+ }
+ else // Environment variables were updated
+ {
+ Activation::onFlashWriteSuccess();
+ }
}
}