- xbt_lib_cursor_t cursor;
- void **data;
- char *name;
-
- /* Initialize MSG and WKS hosts */
- XBT_DEBUG("Initialize MSG and WKS hosts");
- xbt_lib_foreach(host_lib, cursor, name, data) {
- if(data[SURF_WKS_LEVEL]){
- XBT_DEBUG("\tSee surf host %s",name);
- SIMIX_host_create(name, data[SURF_WKS_LEVEL], NULL);
- __MSG_host_create((smx_host_t)data[SIMIX_HOST_LEVEL]);
- }
+int console_add_backbone(lua_State *L) {
+ s_sg_platf_link_cbarg_t link;
+ memset(&link,0,sizeof(link));
+ int type;
+
+ link.properties = NULL;
+
+ if (!lua_istable(L, -1)) {
+ XBT_ERROR
+ ("Bad Arguments to create backbone in Lua. Should be a table with named arguments.");
+ return -1;
+ }
+
+ lua_pushstring(L, "id");
+ type = lua_gettable(L, -2);
+ if (type != LUA_TSTRING) {
+ XBT_ERROR("Attribute 'id' must be specified for backbone and must be a string.");
+ }
+ link.id = lua_tostring(L, -1);
+ lua_pop(L, 1);
+
+ lua_pushstring(L, "bandwidth");
+ type = lua_gettable(L, -2);
+ if (type != LUA_TSTRING && type != LUA_TNUMBER) {
+ XBT_ERROR("Attribute 'bandwidth' must be specified for backbone and must either be a string (in the right format; see docs) or a number.");
+ }
+ link.bandwidth = surf_parse_get_bandwidth(lua_tostring(L, -1));
+ lua_pop(L, 1);
+
+ lua_pushstring(L, "lat");
+ type = lua_gettable(L, -2);
+ if (type != LUA_TSTRING && type != LUA_TNUMBER) {
+ XBT_ERROR("Attribute 'lat' must be specified for backbone and must either be a string (in the right format; see docs) or a number.");
+ }
+ link.latency = surf_parse_get_time(lua_tostring(L, -1));
+ lua_pop(L, 1);
+
+ link.initiallyOn = 1;
+
+ lua_pushstring(L, "sharing_policy");
+ type = lua_gettable(L, -2);
+ const char* policy = lua_tostring(L, -1);
+ if (policy && !strcmp(policy,"FULLDUPLEX")) {
+ link.policy = SURF_LINK_FULLDUPLEX;
+ } else if (policy && !strcmp(policy,"FATPIPE")) {
+ link.policy = SURF_LINK_FATPIPE;
+ } else {
+ link.policy = SURF_LINK_SHARED;
+ }
+
+ sg_platf_new_link(&link);
+ routing_cluster_add_backbone(sg_link_by_name(link.id));
+
+ return 0;
+}
+
+int console_add_host___link(lua_State *L) {
+ s_sg_platf_host_link_cbarg_t netcard;
+ memset(&netcard,0,sizeof(netcard));
+ int type;
+
+ // we get values from the table passed as argument
+ if (!lua_istable(L, -1)) {
+ XBT_ERROR
+ ("Bad Arguments to create host_link in Lua. Should be a table with named arguments.");
+ return -1;