+ delete radicals;
+
+ // Add a router. It is magically used thanks to the way in which surf_routing_cluster is written,
+ // and it's very useful to connect clusters together
+ XBT_DEBUG(" ");
+ XBT_DEBUG("<router id=\"%s\"/>", cluster->router_id);
+ char *newid = NULL;
+ s_sg_platf_router_cbarg_t router;
+ memset(&router, 0, sizeof(router));
+ router.id = cluster->router_id;
+ if (!router.id || !strcmp(router.id, ""))
+ router.id = newid = bprintf("%s%s_router%s", cluster->prefix, cluster->id, cluster->suffix);
+ sg_platf_new_router(&router);
+ current_as->router_ = (simgrid::surf::NetCard*) xbt_lib_get_or_null(as_router_lib, router.id, ROUTING_ASR_LEVEL);
+ free(newid);
+
+ //Make the backbone
+ if ((cluster->bb_bw != 0) || (cluster->bb_lat != 0)) {
+
+ memset(&link, 0, sizeof(link));
+ link.id = bprintf("%s_backbone", cluster->id);
+ link.bandwidth = cluster->bb_bw;
+ link.latency = cluster->bb_lat;
+ link.policy = cluster->bb_sharing_policy;
+
+ XBT_DEBUG("<link\tid=\"%s\" bw=\"%f\" lat=\"%f\"/>", link.id, cluster->bb_bw, cluster->bb_lat);
+ sg_platf_new_link(&link);
+
+ routing_cluster_add_backbone(Link::byName(link.id));
+ free((char*)link.id);
+ }
+
+ XBT_DEBUG("</AS>");
+ sg_platf_new_AS_seal();
+
+ simgrid::surf::on_cluster(cluster);
+}
+void routing_cluster_add_backbone(simgrid::surf::Link* bb) {
+ simgrid::surf::AsCluster *cluster = dynamic_cast<simgrid::surf::AsCluster*>(current_routing);
+
+ xbt_assert(cluster, "Only hosts from Cluster can get a backbone.");
+ xbt_assert(nullptr == cluster->backbone_, "Cluster %s already has a backbone link!", cluster->name());
+
+ cluster->backbone_ = bb;
+ XBT_DEBUG("Add a backbone to AS '%s'", current_routing->name());
+}
+
+void sg_platf_new_cabinet(sg_platf_cabinet_cbarg_t cabinet)
+{
+ std::vector<int> *radicals = explodesRadical(cabinet->radical);
+
+ for (int radical : *radicals) {
+ char *hostname = bprintf("%s%d%s", cabinet->prefix, radical, cabinet->suffix);
+ s_sg_platf_host_cbarg_t host;
+ memset(&host, 0, sizeof(host));
+ host.pstate = 0;
+ host.core_amount = 1;
+ host.id = hostname;
+ host.speed_per_pstate = xbt_dynar_new(sizeof(double), NULL);
+ xbt_dynar_push(host.speed_per_pstate,&cabinet->speed);
+ sg_platf_new_host(&host);
+ xbt_dynar_free(&host.speed_per_pstate);
+
+ s_sg_platf_link_cbarg_t link;
+ memset(&link, 0, sizeof(link));
+ link.policy = SURF_LINK_FULLDUPLEX;
+ link.latency = cabinet->lat;
+ link.bandwidth = cabinet->bw;
+ link.id = bprintf("link_%s",hostname);
+ sg_platf_new_link(&link);
+ free((char*)link.id);
+
+ s_sg_platf_host_link_cbarg_t host_link;
+ memset(&host_link, 0, sizeof(host_link));
+ host_link.id = hostname;
+ host_link.link_up = bprintf("link_%s_UP",hostname);
+ host_link.link_down = bprintf("link_%s_DOWN",hostname);
+ sg_platf_new_hostlink(&host_link);
+ free((char*)host_link.link_up);
+ free((char*)host_link.link_down);
+
+ free(hostname);
+ }
+ delete(radicals);