+ 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;
+ }
+
+ lua_pushstring(L, "id");
+ type = lua_gettable(L, -2);
+ if (type != LUA_TSTRING) {
+ XBT_ERROR("Attribute 'id' must be specified for any host_link and must be a string.");
+ }
+ netcard.id = lua_tostring(L, -1);
+ lua_pop(L, 1);
+
+ lua_pushstring(L, "up");
+ type = lua_gettable(L, -2);
+ if (type != LUA_TSTRING && type != LUA_TNUMBER) {
+ XBT_ERROR("Attribute 'up' must be specified for host_link and must either be a string or a number.");
+ }
+ netcard.link_up = lua_tostring(L, -1);
+ lua_pop(L, 1);
+
+ lua_pushstring(L, "down");
+ type = lua_gettable(L, -2);
+ if (type != LUA_TSTRING && type != LUA_TNUMBER) {
+ XBT_ERROR("Attribute 'down' must be specified for host_link and must either be a string or a number.");
+ }
+ netcard.link_down = lua_tostring(L, -1);
+ lua_pop(L, 1);
+
+ XBT_DEBUG("Create a host_link for host %s", netcard.id);
+ sg_platf_new_netcard(&netcard);