depot_deploy: status report

The idea is, that other components may know, when a valid
init.config is available.

Issue #3482
This commit is contained in:
Pirmin Duss 2019-08-19 12:14:29 +02:00 committed by Christian Helmuth
parent 530144b040
commit c0789a6c0e
2 changed files with 33 additions and 0 deletions

View File

@ -133,6 +133,14 @@ class Depot_deploy::Children
child.gen_installation_entry(xml); });
}
size_t count() const
{
size_t count = 0;
_children.for_each([&] (Child const &) {
++count; });
return count;
}
bool any_incomplete() const {
bool result = false;

View File

@ -13,6 +13,7 @@
/* Genode includes */
#include <util/retry.h>
#include <util/reconstructible.h>
#include <base/component.h>
#include <base/attached_rom_dataspace.h>
#include <base/heap.h>
@ -34,6 +35,8 @@ struct Depot_deploy::Main
Expanding_reporter _query_reporter { _env, "query" , "query"};
Expanding_reporter _init_config_reporter { _env, "config", "init.config"};
Constructible<Expanding_reporter> _state_reporter { };
Heap _heap { _env.ram(), _env.rm() };
Children _children { _heap };
@ -48,6 +51,16 @@ struct Depot_deploy::Main
_config.update();
_blueprint.update();
bool const report_state =
_config.xml().has_sub_node("report") &&
_config.xml().sub_node("report").attribute_value("state", false);
_state_reporter.conditional(report_state, _env, "state", "state");
if (_state_reporter.constructed())
_state_reporter->generate([&] (Xml_generator xml) {
xml.attribute("running", true); });
Xml_node const config = _config.xml();
_children.apply_config(config);
@ -76,6 +89,17 @@ struct Depot_deploy::Main
_children.gen_queries(xml);
});
}
if ((_children.count() > 0UL)
&& !_children.any_incomplete()
&& !_children.any_blueprint_needed()
&& _state_reporter.constructed()) {
_state_reporter->generate([&] (Xml_generator xml) {
xml.attribute("running", false);
xml.attribute("count", _children.count());
});
}
}
Main(Env &env) : _env(env)
@ -83,6 +107,7 @@ struct Depot_deploy::Main
_config .sigh(_config_handler);
_blueprint.sigh(_config_handler);
_handle_config();
}
};