コード例 #1
0
/**
 * \brief Returns the value of a host property.
 * \param L a Lua state
 * \return number of values returned to Lua
 *
 * - Argument 1 (host): a host
 * - Argument 2 (string): name of the property to get
 * - Return value (string): the value of this property
 */
static int l_host_get_property_value(lua_State * L)
{
  sg_host_t ht = sglua_check_host(L, 1);
  const char *prop = luaL_checkstring(L, 2);
  lua_pushstring(L, sg_host_get_property_value(ht,prop));
  return 1;
}
コード例 #2
0
  const char *name2 = sg_host_get_name(h2);

  /* Get the property list of 'host1' */
  XBT_INFO("Property list for host %s", name1);
  xbt_dict_t props = sg_host_get_properties(h1);

  /* Trying to set a new property */
  xbt_dict_set(props, "NewProp", strdup("newValue"), NULL);

  /* Print the properties of 'host1' */
  xbt_dict_foreach(props, cursor, key, data) {
    XBT_INFO("\tProperty: %s has value: %s", key, data);
  }

  /* Try to get a property that does not exist */
  value = sg_host_get_property_value(h1, noexist);
  XBT_INFO("\tProperty: %s has value: %s", noexist, value?value:"Undefined (NULL)");

  /* Get the property list of 'host2' */
  XBT_INFO("Property list for host %s", name2);
  props = sg_host_get_properties(h2);

  /* Print the properties of 'host2' */
  xbt_dict_foreach(props, cursor, key, data) {
    XBT_INFO("\tProperty: %s on host: %s", key, data);
  }

  /* Modify an existing property test. First check it exists */
  XBT_INFO("Modify an existing property");

  value = sg_host_get_property_value(h2, exist);