Ejemplo n.º 1
0
/* Purge the contents of a node record */
extern void purge_node_rec (struct node_record *node_ptr)
{
	xfree(node_ptr->arch);
	xfree(node_ptr->comm_name);
	xfree(node_ptr->features);
	xfree(node_ptr->gres);
	if (node_ptr->gres_list)
		list_destroy(node_ptr->gres_list);
	xfree(node_ptr->name);
	xfree(node_ptr->node_hostname);
	xfree(node_ptr->os);
	xfree(node_ptr->part_pptr);
	xfree(node_ptr->reason);
	select_g_select_nodeinfo_free(node_ptr->select_nodeinfo);
}
Ejemplo n.º 2
0
extern int select_g_select_nodeinfo_unpack(dynamic_plugin_data_t **nodeinfo,
					   Buf buffer,
					   uint16_t protocol_version)
{
	dynamic_plugin_data_t *nodeinfo_ptr = NULL;

	if (slurm_select_init(0) < 0)
		return SLURM_ERROR;

	nodeinfo_ptr = xmalloc(sizeof(dynamic_plugin_data_t));
	*nodeinfo = nodeinfo_ptr;

	if (protocol_version >= SLURM_2_5_PROTOCOL_VERSION) {
		int i;
		uint32_t plugin_id;
		safe_unpack32(&plugin_id, buffer);
		for (i=0; i<select_context_cnt; i++)
			if (*(ops[i].plugin_id) == plugin_id) {
				nodeinfo_ptr->plugin_id = i;
				break;
			}
		if (i >= select_context_cnt) {
			error("we don't have select plugin type %u",plugin_id);
			goto unpack_error;
		}
	} else {
		nodeinfo_ptr->plugin_id = select_context_default;
		error("select_g_select_nodeinfo_unpack: protocol_version"
		      " %hu not supported", protocol_version);
		goto unpack_error;
	}

	if ((*(ops[nodeinfo_ptr->plugin_id].nodeinfo_unpack))
	   ((select_nodeinfo_t **)&nodeinfo_ptr->data, buffer,
	    protocol_version) != SLURM_SUCCESS)
		goto unpack_error;

	return SLURM_SUCCESS;

unpack_error:
	select_g_select_nodeinfo_free(nodeinfo_ptr);
	*nodeinfo = NULL;
	error("select_g_select_nodeinfo_unpack: unpack error");
	return SLURM_ERROR;
}
Ejemplo n.º 3
0
/* Purge the contents of a node record */
extern void purge_node_rec (struct node_record *node_ptr)
{
	xfree(node_ptr->arch);
	xfree(node_ptr->comm_name);
	xfree(node_ptr->cpu_spec_list);
	xfree(node_ptr->features);
	xfree(node_ptr->gres);
	FREE_NULL_LIST(node_ptr->gres_list);
	xfree(node_ptr->name);
	xfree(node_ptr->node_hostname);
	FREE_NULL_BITMAP(node_ptr->node_spec_bitmap);
	xfree(node_ptr->os);
	xfree(node_ptr->part_pptr);
	xfree(node_ptr->power);
	xfree(node_ptr->reason);
	xfree(node_ptr->version);
	acct_gather_energy_destroy(node_ptr->energy);
	ext_sensors_destroy(node_ptr->ext_sensors);
	select_g_select_nodeinfo_free(node_ptr->select_nodeinfo);
	xfree(node_ptr->tres_str);
}
Ejemplo n.º 4
0
extern int select_g_select_nodeinfo_unpack(dynamic_plugin_data_t **nodeinfo,
					   Buf buffer,
					   uint16_t protocol_version)
{
	dynamic_plugin_data_t *nodeinfo_ptr = NULL;

	if (slurm_select_init(0) < 0)
		return SLURM_ERROR;

	nodeinfo_ptr = xmalloc(sizeof(dynamic_plugin_data_t));
	*nodeinfo = nodeinfo_ptr;

	if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
		int i;
		uint32_t plugin_id;
		safe_unpack32(&plugin_id, buffer);
		for (i = 0; i < select_context_cnt; i++) {
			if (*(ops[i].plugin_id) == plugin_id) {
				nodeinfo_ptr->plugin_id = i;
				break;
			}
		}
		if (i >= select_context_cnt) {
			/*
			 * cons_res and cons_tres have equivalent pack logic,
			 * so we can switch without a cold-start
			 */
			bool retry = false;
			if (plugin_id == SELECT_PLUGIN_CONS_RES) {
				plugin_id = SELECT_PLUGIN_CONS_TRES;
				retry = true;
			} else if (plugin_id == SELECT_PLUGIN_CONS_TRES) {
				plugin_id = SELECT_PLUGIN_CONS_RES;
				retry = true;
			} else if (plugin_id == SELECT_PLUGIN_CRAY_CONS_RES) {
				plugin_id = SELECT_PLUGIN_CRAY_CONS_TRES;
				retry = true;
			} else if (plugin_id == SELECT_PLUGIN_CRAY_CONS_TRES) {
				plugin_id = SELECT_PLUGIN_CRAY_CONS_RES;
				retry = true;
			}
			if (retry) {
				for (i = 0; i < select_context_cnt; i++) {
					if (*(ops[i].plugin_id) == plugin_id) {
						nodeinfo_ptr->plugin_id = i;
						break;
					}
				}
			}
		}
		if (i >= select_context_cnt) {
			error("%s: select plugin %s not found", __func__,
			      _plugin_id2name(plugin_id));
			goto unpack_error;
		}
	} else {
		nodeinfo_ptr->plugin_id = select_context_default;
		error("%s: protocol_version %hu not supported", __func__,
		      protocol_version);
		goto unpack_error;
	}

	if ((*(ops[nodeinfo_ptr->plugin_id].nodeinfo_unpack))
	   ((select_nodeinfo_t **)&nodeinfo_ptr->data, buffer,
	    protocol_version) != SLURM_SUCCESS)
		goto unpack_error;

	return SLURM_SUCCESS;

unpack_error:
	select_g_select_nodeinfo_free(nodeinfo_ptr);
	*nodeinfo = NULL;
	error("%s: unpack error", __func__);
	return SLURM_ERROR;
}