summaryrefslogtreecommitdiffstats
path: root/static
diff options
context:
space:
mode:
authorLei YU <mine260309@gmail.com>2019-02-28 14:26:37 +0800
committerLei YU <mine260309@gmail.com>2019-03-13 11:01:53 +0800
commit6da3dae3b40bdbe9663b94e1f36dd3e2833d9c14 (patch)
tree87542e570ae26f49a051a867d124c1fca9ee7b7b /static
parent6cecc9b4a8e11327b5c59924c2865da5865f7d7d (diff)
downloadopenpower-pnor-code-mgmt-6da3dae3b40bdbe9663b94e1f36dd3e2833d9c14.tar.gz
openpower-pnor-code-mgmt-6da3dae3b40bdbe9663b94e1f36dd3e2833d9c14.zip
Static layout: Do not update PNOR when host is on
Static layout only has 1 active and functional PNOR. When host is running, do not update PNOR. This is done by checking the return value of freeSpace(), and if it returns false, it means there is no space for PNOR because the host is running and erase() returns false. Tested: Verify the status becomes Failed when trying to activate a PNOR while host is running. Change-Id: Ie2986b0c6fd29557685f67eb77ccc29709e1669a Signed-off-by: Lei YU <mine260309@gmail.com>
Diffstat (limited to 'static')
-rw-r--r--static/activation_static.cpp14
-rw-r--r--static/item_updater_static.cpp6
-rw-r--r--static/item_updater_static.hpp2
3 files changed, 14 insertions, 8 deletions
diff --git a/static/activation_static.cpp b/static/activation_static.cpp
index 9768d4157..193d6b32a 100644
--- a/static/activation_static.cpp
+++ b/static/activation_static.cpp
@@ -19,6 +19,7 @@ using namespace phosphor::logging;
auto ActivationStatic::activation(Activations value) -> Activations
{
+ auto ret = value;
if (value != softwareServer::Activation::Activations::Active)
{
redundancyPriority.reset(nullptr);
@@ -26,9 +27,14 @@ auto ActivationStatic::activation(Activations value) -> Activations
if (value == softwareServer::Activation::Activations::Activating)
{
- parent.freeSpace();
- startActivation();
- return softwareServer::Activation::activation(value);
+ if (parent.freeSpace())
+ {
+ startActivation();
+ }
+ else
+ {
+ ret = softwareServer::Activation::Activations::Failed;
+ }
}
else
{
@@ -36,7 +42,7 @@ auto ActivationStatic::activation(Activations value) -> Activations
activationProgress.reset(nullptr);
}
- return softwareServer::Activation::activation(value);
+ return softwareServer::Activation::activation(ret);
}
void ActivationStatic::startActivation()
diff --git a/static/item_updater_static.cpp b/static/item_updater_static.cpp
index 628f824f4..140d5cc5b 100644
--- a/static/item_updater_static.cpp
+++ b/static/item_updater_static.cpp
@@ -335,7 +335,7 @@ void ItemUpdaterStatic::deleteAll()
// There is no implementation for this interface
}
-void ItemUpdaterStatic::freeSpace()
+bool ItemUpdaterStatic::freeSpace()
{
// For now assume static layout only has 1 active PNOR,
// so erase the active PNOR
@@ -344,10 +344,10 @@ void ItemUpdaterStatic::freeSpace()
if (iter.second.get()->activation() ==
server::Activation::Activations::Active)
{
- erase(iter.second->versionId);
- break;
+ return erase(iter.second->versionId);
}
}
+ return false;
}
void ItemUpdaterStatic::updateFunctionalAssociation(
diff --git a/static/item_updater_static.hpp b/static/item_updater_static.hpp
index 75afedade..c3f273d37 100644
--- a/static/item_updater_static.hpp
+++ b/static/item_updater_static.hpp
@@ -33,7 +33,7 @@ class ItemUpdaterStatic : public ItemUpdater
void deleteAll() override;
- void freeSpace() override;
+ bool freeSpace() override;
void updateFunctionalAssociation(const std::string& versionId) override;
OpenPOWER on IntegriCloud