Skip to content
Snippets Groups Projects
Commit f955a04c authored by bpwilcox's avatar bpwilcox
Browse files

reverse order of shutdown nodes

shutdown nodes in reverse order of bringup
parent ea39ef2b
No related branches found
No related tags found
No related merge requests found
......@@ -67,7 +67,7 @@ protected:
bool changeStateForNode(const std::string & node_name, std::uint8_t transition);
// For each node in the map, transition to the new target state
bool changeStateForAllNodes(std::uint8_t transition);
bool changeStateForAllNodes(std::uint8_t transition, bool reverse_order = false);
// Convenience function to highlight the output on the console
void message(const std::string & msg);
......
......@@ -126,11 +126,20 @@ LifecycleManager::changeStateForNode(const std::string & node_name, std::uint8_t
}
bool
LifecycleManager::changeStateForAllNodes(std::uint8_t transition)
LifecycleManager::changeStateForAllNodes(std::uint8_t transition, bool reverse_order)
{
for (const auto & kv : node_map_) {
if (!changeStateForNode(kv.first, transition)) {
return false;
if (!reverse_order) {
for (auto & node_name : node_names_) {
if (!changeStateForNode(node_name, transition)) {
return false;
}
}
} else {
std::vector<std::string>::reverse_iterator rit;
for (rit = node_names_.rbegin(); rit != node_names_.rend(); ++rit) {
if (!changeStateForNode(*rit, transition)) {
return false;
}
}
}
......@@ -154,9 +163,9 @@ void
LifecycleManager::shutdownAllNodes()
{
message("Deactivate, cleanup, and shutdown nodes");
changeStateForAllNodes(Transition::TRANSITION_DEACTIVATE);
changeStateForAllNodes(Transition::TRANSITION_CLEANUP);
changeStateForAllNodes(Transition::TRANSITION_UNCONFIGURED_SHUTDOWN);
changeStateForAllNodes(Transition::TRANSITION_DEACTIVATE, true);
changeStateForAllNodes(Transition::TRANSITION_CLEANUP, true);
changeStateForAllNodes(Transition::TRANSITION_UNCONFIGURED_SHUTDOWN, true);
}
void
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment