Ejemplo n.º 1
0
/**
 * @brief
 * 	-__pbs_statvnode() - returns information about virtual nodes (vnodes)
 *
 * @param[in] c - communication handle
 * @param[in] id - object id
 * @param[in] attrib - pointer to attribute list
 * @param[in] extend - extend string for encoding req
 *
 * @return	structure handle
 * @retval	pointer to batch_status struct		Success
 * @retval	NULL					error
 *
 */
struct batch_status *
__pbs_statvnode(int c, char *id, struct attrl *attrib, char *extend)
{
	int                   rc;
	struct batch_status  *ret = NULL;

	/* initialize the thread context data, if not already initialized */
	if (pbs_client_thread_init_thread_context() != 0)
		return NULL;

	/* first verify the attributes, if verification is enabled */
	rc = pbs_verify_attributes(c, PBS_BATCH_StatusNode,
		MGR_OBJ_NODE, MGR_CMD_NONE, (struct attropl *) attrib);
	if (rc)
		return NULL;

	if (pbs_client_thread_lock_connection(c) != 0)
		return NULL;

	ret = PBSD_status(c, PBS_BATCH_StatusNode, id, attrib, extend);

	/* unlock the thread lock and update the thread context data */
	if (pbs_client_thread_unlock_connection(c) != 0)
		return NULL;

	return ret;
}
Ejemplo n.º 2
0
/**
 * @brief
 *	-send manager request and read reply.
 *
 * @param[in] c - communication handle
 * @param[in] function - req type
 * @param[in] command - command
 * @param[in] objtype - object type
 * @param[in] objname - object name
 * @param[in] aoplp - attribute list
 * @param[in] extend - extend string for req
 *
 * @return	int
 * @retval	0	success
 * @retval	!0	error
 *
 */ 
int
PBSD_manager(int c, int function, int command, int objtype, char *objname, struct attropl *aoplp, char *extend)
{
	int i;
	struct batch_reply *reply;
	int rc;

	/* initialize the thread context data, if not initialized */
	if (pbs_client_thread_init_thread_context() != 0)
		return pbs_errno;

	/* verify the object name if creating a new one */
	if (command == MGR_CMD_CREATE)
		if (pbs_verify_object_name(objtype, objname) != 0)
			return pbs_errno;

	/* now verify the attributes, if verification is enabled */
	if ((pbs_verify_attributes(c, function, objtype,
		command, aoplp)) != 0)
		return pbs_errno;

	/* lock pthread mutex here for this connection */
	/* blocking call, waits for mutex release */
	if (pbs_client_thread_lock_connection(c) != 0)
		return pbs_errno;

	/* send the manage request */
	i = PBSD_mgr_put(c, function, command, objtype, objname, aoplp, extend, 0, NULL);
	if (i) {
		(void)pbs_client_thread_unlock_connection(c);
		return i;
	}

	/* read reply from stream into presentation element */

	reply = PBSD_rdrpy(c);

	PBSD_FreeReply(reply);

	rc = connection[c].ch_errno;

	/* unlock the thread lock and update the thread context data */
	if (pbs_client_thread_unlock_connection(c) != 0)
		return pbs_errno;

	return rc;
}
Ejemplo n.º 3
0
/**
 * @brief
 *	Return the status of a hook.
 *
 * @param[in] c - communication handle
 * @param[in] id - object name
 * @param[in] attrib - pointer to attrl structure(list)
 * @param[in] extend - extend string for req
 *
 * @return	structure handle
 * @retval	pointer to attr list	success
 * @retval	NULL			error
 *
 */
struct batch_status *
__pbs_stathook(int c, char *id, struct attrl *attrib, char *extend)
{
	struct batch_status *ret = NULL;
	int                  rc;
	int		    hook_obj;

	if (extend != NULL) {
		if (strcmp(extend, PBS_HOOK) == 0) {
			hook_obj = MGR_OBJ_PBS_HOOK;
		} else if (strcmp(extend, SITE_HOOK) == 0) {
			hook_obj = MGR_OBJ_SITE_HOOK;
		} else {
			return NULL;	/* bad extend value */
		}
	} else {
		hook_obj = MGR_OBJ_SITE_HOOK;
	}

	/* initialize the thread context data, if not already initialized */
	if (pbs_client_thread_init_thread_context() != 0)
		return NULL;

	/* first verify the attributes, if verification is enabled */
	rc = pbs_verify_attributes(c, PBS_BATCH_StatusHook,
		hook_obj, MGR_CMD_NONE, (struct attropl *) attrib);
	if (rc)
		return NULL;

	if (pbs_client_thread_lock_connection(c) != 0)
		return NULL;

	ret = PBSD_status(c, PBS_BATCH_StatusHook, id, attrib, extend);

	/* unlock the thread lock and update the thread context data */
	if (pbs_client_thread_unlock_connection(c) != 0)
		return NULL;

	return ret;
}
Ejemplo n.º 4
0
/**
 * @brief
 *	Passes submit reservation request to PBSD_submit_resv( )
 *
 * @param[in]   c - socket on which connected
 * @param[in]   attrib - the list of attributes for batch request
 * @parma[in]   extend - extension of batch request
 *
 * @return char*
 * @retval SUCCESS returns the reservation ID
 * @retval ERROR NULL
 */
char *
__pbs_submit_resv(int c, struct attropl *attrib, char *extend)
{
	struct attropl *pal;
	int rc;
	char *ret;

	for (pal = attrib; pal; pal = pal->next)
		pal->op = SET;		/* force operator to SET */

	/* initialize the thread context data, if not already initialized */
	if (pbs_client_thread_init_thread_context() != 0)
		return (char *)NULL;

	/* first verify the attributes, if verification is enabled */
	rc = pbs_verify_attributes(c, PBS_BATCH_SubmitResv,
		MGR_OBJ_RESV, MGR_CMD_NONE, attrib);
	if (rc)
		return (char *)NULL;

	/* lock pthread mutex here for this connection */
	/* blocking call, waits for mutex release */
	if (pbs_client_thread_lock_connection(c) != 0)
		return (char *)NULL;

	/* initiate the queueing of the reservation  */

	/* Queue job with null string for job id */
	ret = PBSD_submit_resv(c, "", attrib, extend);

	/* unlock the thread lock and update the thread context data */
	if (pbs_client_thread_unlock_connection(c) != 0)
		return (char *) NULL;

	return ret;
}
Ejemplo n.º 5
0
/**
 * @brief
 *	-submit job request
 *
 * @param[in] c - communication handle
 * @param[in] attrib - ponter to attr list
 * @param[in] script - job script
 * @param[in] destination - host where job submitted
 * @param[in] extend - buffer to hold cred info
 *
 * @return      string
 * @retval      jobid   success
 * @retval      NULL    error
 *
 */
char *
__pbs_submit(int c, struct attropl  *attrib, char *script, char *destination, char *extend)
{
	struct attropl		*pal;
	char			*return_jobid = NULL;
	int			rc;
	struct pbs_client_thread_context *ptr;
	struct cred_info	*cred_info = NULL;

	/* initialize the thread context data, if not already initialized */
	if (pbs_client_thread_init_thread_context() != 0)
		return return_jobid;

	ptr = (struct pbs_client_thread_context *)
		pbs_client_thread_get_context_data();
	if (!ptr) {
		pbs_errno = PBSE_INTERNAL;
		return return_jobid;
	}

	/* first verify the attributes, if verification is enabled */
	rc = pbs_verify_attributes(c, PBS_BATCH_QueueJob,
		MGR_OBJ_JOB, MGR_CMD_NONE, attrib);
	if (rc)
		return return_jobid;

	/* lock pthread mutex here for this connection */
	/* blocking call, waits for mutex release */
	if (pbs_client_thread_lock_connection(c) != 0)
		return return_jobid;

	/* first be sure that the script is readable if specified ... */

	if ((script != NULL) && (*script != '\0')) {
		if (access(script, R_OK) != 0) {
			pbs_errno = PBSE_BADSCRIPT;
			if ((connection[c].ch_errtxt = strdup("cannot access script file")) == NULL)
				pbs_errno = PBSE_SYSTEM;
			goto error;
		}
	}

	/* initiate the queueing of the job */

	for (pal = attrib; pal; pal = pal->next)
		pal->op = SET;		/* force operator to SET */

	/* Queue job with null string for job id */
	return_jobid = PBSD_queuejob(c, "", destination, attrib, extend, 0, NULL);
	if (return_jobid == NULL)
		goto error;

	/* send script across */

	if ((script != NULL) && (*script != '\0')) {
		if ((rc = PBSD_jscript(c, script, 0, NULL)) != 0) {
			if (rc == PBSE_JOBSCRIPTMAXSIZE)
				pbs_errno = rc;
			else
				pbs_errno = PBSE_BADSCRIPT;
			goto error;
		}
	}

	/* OK, the script got across, apparently, so we are */
	/* ready to commit 				    */

	cred_info = (struct cred_info *) ptr->th_cred_info;

	/* opaque information */
	if (cred_info && cred_info->cred_len > 0) {
		if (PBSD_jcred(c, cred_info->cred_type,
			cred_info->cred_buf,
			cred_info->cred_len, 0, NULL) != 0) {
			pbs_errno = PBSE_BADCRED;
			goto error;
		}
	}

	if (PBSD_commit(c, return_jobid, 0, NULL) != 0)
		goto error;

	/* unlock the thread lock and update the thread context data */
	if (pbs_client_thread_unlock_connection(c) != 0)
		return NULL;

	return return_jobid;
error:
	(void)pbs_client_thread_unlock_connection(c);
	return NULL;
}