Ejemplo n.º 1
0
/**
 * @brief
 * 	Returns TRUE if the name passed in is an attribute.
 *
 * @note
 * 	This must not be called with object of type MGR_OBJ_SITE_HOOK or MGR_OBJ_PBS_HOOK.
 *
 * @param[in]	object - type of object
 * @param[in]	name  - name of the attribute
 * @param[in]	attr_type  - type of the attribute
 *
 * @eturn int
 * @retval	TRUE - means if the input is an attribute of the given 'object' type
 *        	    and 'attr_type'.
 * @retval	FALSE - otherwise.
 *
 */
int
is_attr(int object, char *name, int attr_type)
{
	struct ecl_attribute_def *attr_def = NULL;

	if ((object == MGR_OBJ_SITE_HOOK) || (object == MGR_OBJ_PBS_HOOK)) {
		return FALSE;
	}

	else if (object == MGR_OBJ_RSC) {
		return TRUE;
	}

	if ((attr_def = ecl_find_attr_in_def(ecl_svr_attr_def, name, ecl_svr_attr_size)) != NULL) {
		/* Make sure that the attribute types match */
		if (get_attr_type(*attr_def) & attr_type)
			return TRUE;
		else
			return FALSE;
	} else if ((attr_def = ecl_find_attr_in_def(ecl_node_attr_def, name, ecl_node_attr_size)) != NULL) {
		/* Make sure that the attribute types match */
		if (get_attr_type(*attr_def) & attr_type)
			return TRUE;
		else
			return FALSE;
	} else if ((attr_def = ecl_find_attr_in_def(ecl_que_attr_def, name, ecl_que_attr_size)) != NULL) {
		/* Make sure that the attribute types match */
		if (get_attr_type(*attr_def) & attr_type)
			return TRUE;
		else
			return FALSE;
	} else if ((attr_def = ecl_find_attr_in_def(ecl_sched_attr_def, name, ecl_sched_attr_size)) != NULL) {
		/* Make sure that the attribute types match */
		if (get_attr_type(*attr_def) & attr_type)
			return TRUE;
		else
			return FALSE;
	}

	return FALSE;
}
Ejemplo n.º 2
0
/**
 * @brief
 *	Name: ecl_findattr
 *
 * @par		Functionality:
 *		1. Find the attribute in the list associated with the
 *		parent_object by calling ecl_find_attr_in_def().
 *
 * @see
 *
 * @param[in]	parent_object	-	Parent Object Type
 * @param[in]	pattr		-	list of attributes
 *
 * @return	pointer to the ecl_attribute_def structure
 * @retval	Return value: Address of the ecl_attribute_def structure
 *		associated with the given attribute, NULL if not found
 *
 * @par		Side effects:
 *		None
 *
 * @par MT-safe: Yes
 */
static struct ecl_attribute_def * ecl_findattr(int parent_object,
        struct attropl *pattr)
{
    switch (parent_object) {
    case MGR_OBJ_JOB:
        return (ecl_find_attr_in_def(ecl_job_attr_def, pattr->name,
                                     ecl_job_attr_size));
    case MGR_OBJ_SERVER:
        return (ecl_find_attr_in_def(ecl_svr_attr_def, pattr->name,
                                     ecl_svr_attr_size));
    case MGR_OBJ_SCHED:
        return (ecl_find_attr_in_def(ecl_sched_attr_def, pattr->name,
                                     ecl_sched_attr_size));
    case MGR_OBJ_QUEUE:
        return (ecl_find_attr_in_def(ecl_que_attr_def, pattr->name,
                                     ecl_que_attr_size));
    case MGR_OBJ_NODE:
    case MGR_OBJ_HOST:
        return (ecl_find_attr_in_def(ecl_node_attr_def, pattr->name,
                                     ecl_node_attr_size));
    case MGR_OBJ_RESV:
        return (ecl_find_attr_in_def(ecl_resv_attr_def, pattr->name,
                                     ecl_resv_attr_size));
    }
    return NULL;
}