-void sg_platf_new_cabinet(sg_platf_cabinet_cbarg_t cabinet)
-{
- int start, end, i;
- char *groups , *host_id , *link_id = NULL;
- unsigned int iter;
- xbt_dynar_t radical_elements;
- xbt_dynar_t radical_ends;
-
- //Make all hosts
- radical_elements = xbt_str_split(cabinet->radical, ",");
- xbt_dynar_foreach(radical_elements, iter, groups) {
-
- radical_ends = xbt_str_split(groups, "-");
- start = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 0, char *));
-
- switch (xbt_dynar_length(radical_ends)) {
- case 1:
- end = start;
- break;
- case 2:
- end = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 1, char *));
- break;
- default:
- surf_parse_error("Malformed radical");
- break;
- }
- s_sg_platf_host_cbarg_t host = SG_PLATF_HOST_INITIALIZER;
- memset(&host, 0, sizeof(host));
- host.pstate = 0;
- host.core_amount = 1;
-
- s_sg_platf_link_cbarg_t link = SG_PLATF_LINK_INITIALIZER;
- memset(&link, 0, sizeof(link));
- link.policy = SURF_LINK_FULLDUPLEX;
- link.latency = cabinet->lat;
- link.bandwidth = cabinet->bw;
-
- s_sg_platf_host_link_cbarg_t host_link = SG_PLATF_HOST_LINK_INITIALIZER;
- memset(&host_link, 0, sizeof(host_link));
-
- for (i = start; i <= end; i++) {
- host_id = bprintf("%s%d%s",cabinet->prefix,i,cabinet->suffix);
- link_id = bprintf("link_%s%d%s",cabinet->prefix,i,cabinet->suffix);
- host.id = host_id;
- link.id = link_id;
- host.speed_peak = xbt_dynar_new(sizeof(double), NULL);
- xbt_dynar_push(host.speed_peak,&cabinet->speed);
- sg_platf_new_host(&host);
- xbt_dynar_free(&host.speed_peak);
- sg_platf_new_link(&link);
-
- char* link_up = bprintf("%s_UP",link_id);
- char* link_down = bprintf("%s_DOWN",link_id);
- host_link.id = host_id;
- host_link.link_up = link_up;
- host_link.link_down = link_down;
- sg_platf_new_hostlink(&host_link);
-
- free(host_id);
- free(link_id);
- free(link_up);
- free(link_down);
- }
-
- xbt_dynar_free(&radical_ends);
- }
- xbt_dynar_free(&radical_elements);
-}
-