#include <simgrid/s4u/Host.hpp>
#include <simgrid/s4u/VirtualMachine.hpp>
-#include "xbt/asserts.hpp"
-#include "src/include/simgrid/sg_config.hpp"
#include "src/kernel/EngineImpl.hpp"
#include "src/kernel/resource/CpuImpl.hpp"
#include "src/kernel/resource/DiskImpl.hpp"
+#include "src/kernel/resource/HostImpl.hpp"
#include "src/kernel/resource/NetworkModel.hpp"
#include "src/kernel/resource/SplitDuplexLinkImpl.hpp"
#include "src/kernel/resource/StandardLinkImpl.hpp"
#include "src/kernel/resource/VirtualMachineImpl.hpp"
-#include "src/surf/HostImpl.hpp"
+#include "src/simgrid/module.hpp"
+#include "src/simgrid/sg_config.hpp"
+#include "xbt/asserts.hpp"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_platform, kernel, "Kernel platform-related information");
{
auto* engine = s4u::Engine::get_instance();
/* workaroud: first netzoneImpl will be the root netzone.
- * Without globals and with current surf_*_model_description init functions, we need
+ * Without globals and with current model description init functions (see module.hpp), we need
* the root netzone to exist when creating the models.
- * This was usually done at sg_platf.cpp, during XML parsing */
+ * This is usually done at sg_platf.cpp, during XML parsing */
if (not engine->get_netzone_root()) {
engine->set_netzone_root(&piface_);
/* root netzone set, initialize models */
simgrid::s4u::Engine::on_platform_creation();
- /* Initialize the surf models. That must be done after we got all config, and before we need the models.
+ /* Initialize the models. That must be done after we got all config, and before we need the models.
* That is, after the last <config> tag, if any, and before the first of cluster|peer|zone|trace|trace_cb
*
* I'm not sure for <trace> and <trace_cb>, there may be a bug here
* but cluster and peer come down to zone creations, so putting this verification here is correct.
*/
simgrid_host_models().init_from_flag_value();
- surf_vm_model_init_HL13();
+ simgrid_vm_model_init_HL13();
}
xbt_enforce(nullptr == engine->netpoint_by_name_or_null(get_name()),
return;
/* If src and dst are in the same netzone, life is good */
- if (src_ancestor == dst_ancestor) { /* SURF_ROUTING_BASE */
+ if (src_ancestor == dst_ancestor) { /* ROUTING_BASE */
route.link_list_ = std::move(links);
common_ancestor->get_local_route(src, dst, &route, latency);
links = std::move(route.link_list_);
{
std::vector<NetPoint*> vertices = get_vertices();
- for (auto const& my_src : vertices) {
- for (auto const& my_dst : vertices) {
+ for (auto const* my_src : vertices) {
+ for (auto const* my_dst : vertices) {
if (my_src == my_dst)
continue;
}
}
+void NetZoneImpl::set_gateway(const std::string& name, NetPoint* router)
+{
+ xbt_enforce(not sealed_, "Impossible to create gateway: %s. NetZone %s already sealed", name.c_str(), get_cname());
+ if (auto gateway_it = gateways_.find(name); gateway_it != gateways_.end())
+ xbt_die("Impossible to create a gateway named %s. It already exists", name.c_str());
+ else
+ gateways_[name] = router;
+}
+
+NetPoint* NetZoneImpl::get_gateway() const
+{
+ xbt_enforce(not gateways_.empty(), "No default gateway has been defined for NetZone '%s'. Try to seal it first", get_cname());
+ xbt_enforce(gateways_.size() < 2, "NetZone '%s' has more than one gateway, please provide a gateway name", get_cname());
+ auto gateway_it = gateways_.find("default");
+ xbt_enforce(gateway_it != gateways_.end(), "NetZone '%s' hasno default gateway, please define one", get_cname());
+ return gateway_it->second;
+}
+
void NetZoneImpl::seal()
{
/* already sealed netzone */
return;
do_seal(); // derived class' specific sealing procedure
+ // for zone with a single host, this host is its own default gateway
+ if (gateways_.empty() && hosts_.size() == 1)
+ gateways_["default"] = hosts_.begin()->second->get_iface()->get_netpoint();
+
/* seals sub-netzones and hosts */
for (auto* host : get_all_hosts()) {
host->seal();