From 19d3bf6036b2b7a1495b5d5e46fb78df1215a9b3 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sun, 19 Nov 2023 21:28:08 +0100 Subject: [PATCH] Add what's missing to obey the deprecation warning on add_route with 4 parameters in python --- include/simgrid/s4u/NetZone.hpp | 2 ++ src/bindings/python/simgrid_python.cpp | 16 ++++++++++++++-- teshsuite/python/platform-mix/platform-mix.py | 10 +++++++--- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/include/simgrid/s4u/NetZone.hpp b/include/simgrid/s4u/NetZone.hpp index afe33bd54d..76125f3c49 100644 --- a/include/simgrid/s4u/NetZone.hpp +++ b/include/simgrid/s4u/NetZone.hpp @@ -6,6 +6,7 @@ #ifndef SIMGRID_S4U_NETZONE_HPP #define SIMGRID_S4U_NETZONE_HPP +#include "simgrid/s4u/Host.hpp" #include #include #include @@ -61,6 +62,7 @@ public: /** @brief Get the gateway associated to this netzone */ kernel::routing::NetPoint* get_gateway() const; kernel::routing::NetPoint* get_gateway(const std::string& name) const; + void set_gateway(s4u::Host* router) { set_gateway(router->get_netpoint()); } void set_gateway(kernel::routing::NetPoint* router); void set_gateway(const std::string& name, kernel::routing::NetPoint* router); diff --git a/src/bindings/python/simgrid_python.cpp b/src/bindings/python/simgrid_python.cpp index 97fa4d3302..7cac37dac4 100644 --- a/src/bindings/python/simgrid_python.cpp +++ b/src/bindings/python/simgrid_python.cpp @@ -250,11 +250,19 @@ PYBIND11_MODULE(simgrid, m) .def("add_route", py::overload_cast&, bool>(&simgrid::s4u::NetZone::add_route), - "Add a route between 2 netpoints") + "Add a route between 2 hosts") .def("add_route", py::overload_cast&>(&simgrid::s4u::NetZone::add_route), - "Add a route between 2 netpoints") + "Add a route between 2 hosts") + .def("add_route", + py::overload_cast&, bool>(&simgrid::s4u::NetZone::add_route), + "Add a route between 2 netzones. The gateway of each zone gets used.") + .def("add_route", + py::overload_cast&>(&simgrid::s4u::NetZone::add_route), + "Add a route between 2 netzones. The gateway of each zone gets used.") .def("create_host", py::overload_cast(&simgrid::s4u::NetZone::create_host), "Creates a host") .def("create_host", @@ -286,6 +294,10 @@ PYBIND11_MODULE(simgrid, m) .def("create_router", &simgrid::s4u::NetZone::create_router, "Create a router") .def("set_parent", &simgrid::s4u::NetZone::set_parent, "Set the parent of this zone") .def("set_property", &simgrid::s4u::NetZone::set_property, "Add a property to this zone") + .def("set_gateway", py::overload_cast(&simgrid::s4u::NetZone::set_gateway), + "Specify the gateway of this zone, to be used for inter-zone routes") + .def("set_gateway", py::overload_cast(&simgrid::s4u::NetZone::set_gateway), + "Specify the gateway of this zone, to be used for inter-zone routes") .def_property_readonly("netpoint", &simgrid::s4u::NetZone::get_netpoint, "Retrieve the netpoint associated to this zone") .def("seal", &simgrid::s4u::NetZone::seal, "Seal this NetZone") diff --git a/teshsuite/python/platform-mix/platform-mix.py b/teshsuite/python/platform-mix/platform-mix.py index 5bab3cbfe4..9859b541ae 100644 --- a/teshsuite/python/platform-mix/platform-mix.py +++ b/teshsuite/python/platform-mix/platform-mix.py @@ -59,6 +59,7 @@ def load_platform(): host1.create_disk("disk1", 1e5, 1e4).seal() host1.create_disk("disk2", "1MBps", "1Mbps").seal() host1.seal() + dijkstra.set_gateway(host1) host2 = dijkstra.create_host("host2", ["1Gf", "1Mf"]).seal() hosts.append(host2) link1 = dijkstra.create_link("link1_up", [1e9]).set_latency(1e-3).set_concurrency_limit(10).seal() @@ -72,6 +73,7 @@ def load_platform(): this_actor.info(msg_base + vivaldi.name) vivaldi.set_parent(root) host3 = vivaldi.create_host("host3", 1e9).set_coordinates("1 1 1").seal() + vivaldi.set_gateway(host3) host4 = vivaldi.create_host("host4", "1Gf").set_coordinates("2 2 2").seal() hosts.append(host3) hosts.append(host4) @@ -81,6 +83,7 @@ def load_platform(): this_actor.info(msg_base + empty.name) empty.set_parent(root) host5 = empty.create_host("host5", 1e9) + empty.set_gateway(host5) hosts.append(host5) empty.seal() @@ -89,6 +92,7 @@ def load_platform(): this_actor.info(msg_base + wifi.name) wifi.set_parent(root) router = wifi.create_router("wifi_router") + wifi.set_gateway(router) wifi.set_property("access_point", "wifi_router") host6 = wifi.create_host( "host6", ["100.0Mf", "50.0Mf", "20.0Mf"]).seal() @@ -101,9 +105,9 @@ def load_platform(): link_a = vivaldi.create_link("linkA", 1e9).seal() link_b = vivaldi.create_link("linkB", "1GBps").seal() link_c = vivaldi.create_link("linkC", "1GBps").seal() - root.add_route(dijkstra.netpoint, vivaldi.netpoint, host1.netpoint, host3.netpoint, [LinkInRoute(link_a)], True) - root.add_route(vivaldi.netpoint, empty.netpoint, host3.netpoint, host5.netpoint, [LinkInRoute(link_b)], True) - root.add_route(empty.netpoint, wifi.netpoint, host5.netpoint, router, [LinkInRoute(link_c)], True) + root.add_route(dijkstra, vivaldi, [link_a]) + root.add_route(vivaldi, empty, [link_b]) + root.add_route(empty, wifi, [link_c]) # create actors Sender/Receiver Actor.create("sender", hosts[0], Sender(hosts)) -- 2.20.1